Skip to content

fix(tempo): paginate worklog collection, honour the sync range, and emit ids that join jira - #9164

Merged
klesh merged 2 commits into
apache:mainfrom
pballester:fix/tempo-worklog-pagination
Sep 24, 2026
Merged

klesh merged 2 commits into
apache:mainfrom
pballester:fix/tempo-worklog-pagination

Conversation

@pballester

Copy link
Copy Markdown
Contributor

Summary

Fixes the Tempo worklog collection and conversion described in #9163 — full diagnosis and evidence there. Two commits, kept separate for review:

1. fix(tempo): paginate worklogs and honour the sync time range

  • Drop GetTotalPages: Tempo v4 PageableMetadata has no total, so the page count was always 0 and only the first 1000 worklogs were collected. The collector now uses the helper's undetermined mode and fetches pages until one comes back short.
  • Time bounds via a small pure buildWorklogQuery: full sync → from=timeAfter; incremental → updatedFrom=<last successful collection>; explicit fromDate/toDate options still win. Same bounds for the team and global endpoints (previously the team endpoint always used a rolling now − 90d window).
  • Scope raw data and collector state per team (TeamId in the params, matching TempoTeam.GetParams()), so team scopes of one connection no longer share one incremental state. The extractor tags worklogs with their team_id; the convertor converts one team at a time.

2. fix(tempo): emit worklog issue and author ids that join the jira domain

  • issue_id: jira:JiraIssue:<conn>:<id> (was JiraIssues, which matches nothing the jira plugin generates).
  • author_id: jira:JiraAccount:<conn>:<id> (was the bare Atlassian id).
  • buildIssueIdMapping removed: both branches produced the identical string, so the _tool_jira_issues scan had no effect.

As before, the convertor assumes the Tempo connection id equals the Jira connection id; not changed here to keep the scope tight — happy to follow up (e.g. a scope-config field for the Jira connection) if maintainers want it.

Upgrade note: existing raw rows were stored with TeamId: 0 params, so after this change each team starts with a fresh collector state and does one full sync from timeAfter. Domain rows keep the same ids (tempo:TempoWorklog:<id>) and are overwritten in place.

Tests

  • New unit test TestBuildWorklogQuery (pagination, full vs incremental bounds, explicit options, global endpoint).
  • New e2e TestWorklogExtraction (team-scoped raw params → team_id populated); verified it fails without the fix.
  • TestWorklogDataFlow snapshot updated to the corrected ids.
  • go vet / gofmt clean; golangci-lint reports no new findings in the plugin; e2e run against MySQL 8.0.

Does this close any open issues?

Closes #9163

Screenshots

N/A

The worklog collector computed the page count from metadata.total, which
the Tempo v4 API does not return (PageableMetadata only has count,
offset, limit, next and previous). The page count was therefore always
zero and only the first page (1000 worklogs) was ever collected. Per
team, the collector also ignored the sync policy and always asked for a
rolling window of the last 90 days, so it kept re-fetching the oldest
1000 worklogs of that window and never reached recent ones.

- Drop GetTotalPages so pages are fetched until one comes back short.
- Full sync starts at timeAfter; incremental runs use updatedFrom with
  the last successful collection time; explicit fromDate/toDate options
  still win. Same bounds for the team and the global endpoints.
- Scope raw data and collector state per team (TeamId in the params, as
  TempoTeam.GetParams already declares), so team scopes of the same
  connection no longer share one incremental state; the extractor tags
  worklogs with their team and the convertor converts one team at a time.
The convertor wrote issue ids as jira:JiraIssues:<conn>:<id> (plural)
while the jira plugin generates jira:JiraIssue:<conn>:<id>, and stored
the author as the bare Atlassian account id instead of the
jira:JiraAccount:<conn>:<id> domain id. Tempo worklogs therefore never
joined issues, accounts or the team/user mapping.

Generate both ids in the jira plugin's format. buildIssueIdMapping is
removed: both of its branches produced the same string, so the extra
scan of _tool_jira_issues had no effect.
@pballester
pballester force-pushed the fix/tempo-worklog-pagination branch from cc36dae to 0c2d8d9 Compare September 23, 2026 19:40

@klesh klesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks for your contribution.

@klesh
klesh merged commit 48da53b into apache:main Sep 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][tempo] Worklog collector only fetches the first 1000 worklogs of a rolling 90-day window; converted ids don't join jira

2 participants