Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tempo trace query is recursively shifting the time on every new trace search #87608

Closed
AlissonRS opened this issue May 10, 2024 · 2 comments · Fixed by #87980
Closed

Tempo trace query is recursively shifting the time on every new trace search #87608

AlissonRS opened this issue May 10, 2024 · 2 comments · Fixed by #87980
Assignees
Labels
area/explore area/tracing datasource/Tempo needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating type/bug

Comments

@AlissonRS
Copy link

Describe the bug
When searching for traces, you click on a trace from the list, a right panel appears to query by trace id.

If traceQuery.timeShiftEnabled is enabled, it shifts the time range by subtracting time from the range.from and adding to range.to based on the spanStartTimeShift and spanEndTimeShift. However, on Grafana UI, the original calendar component (from the trace list search on the left side panel) also gets shifted. So every new trace keeps shifting the time recursively.

To Reproduce
Steps to reproduce the behavior:

  1. Provision Tempo datasource on Grafana using the configuration below taken from Grafana Docs
  apiVersion: 1
  
  datasources:
    - name: Tempo
      type: tempo
      uid: EbPG8fYoz
      url: http://localhost:3200
      access: proxy
      basicAuth: false
      jsonData:
        tracesToLogsV2:
          # Field with an internal link pointing to a logs data source in Grafana.
          # datasourceUid value must match the uid value of the logs data source.
          datasourceUid: 'loki'
          spanStartTimeShift: '1h'
          spanEndTimeShift: '-1h'
          tags: ['job', 'instance', 'pod', 'namespace']
          filterByTraceID: false
          filterBySpanID: false
          customQuery: true
          query: 'method="${__span.tags.method}"'
        tracesToMetrics:
          datasourceUid: 'prom'
          spanStartTimeShift: '1h'
          spanEndTimeShift: '-1h'
          tags: [{ key: 'service.name', value: 'service' }, { key: 'job' }]
          queries:
            - name: 'Sample query'
              query: 'sum(rate(traces_spanmetrics_latency_bucket{$$__tags}[5m]))'
        tracesToProfiles:
          datasourceUid: 'grafana-pyroscope-datasource'
          tags: ['job', 'instance', 'pod', 'namespace']
          profileTypeId: 'process_cpu:cpu:nanoseconds:cpu:nanoseconds'
          customQuery: true
          query: 'method="${__span.tags.method}"'
        serviceMap:
          datasourceUid: 'prometheus'
        nodeGraph:
          enabled: true
        search:
          hide: false
        lokiSearch:
          datasourceUid: 'loki'
        traceQuery:
          timeShiftEnabled: true
          spanStartTimeShift: '1h'
          spanEndTimeShift: '-1h'
        spanBar:
          type: 'Tag'
          tag: 'http.path'
  1. Open to Tempo datasource on Grafana Explorer, search for some traces (e.g. last 15 minutes).
    image

  2. Click on a trace, the time range on the calendar component will be decreased by one hour on "from" and "to", because the spanStartTimeShift is "1h" and it gets subtracted, and spanEndTimeShift is "-1h" so it adds -1h, essentially subtracting too (in my screenshot, my spanEndTimeShift is "1h" not "-1h", so it's indeed adding 1h to the end instead of subtracting).
    image

  3. Click another trace from the left panel, the time range should go down by another hour.
    image

  4. Keep clicking different traces and notice the calendar time being shifted every time.
    image

Expected behavior
The time shift should happen based on the original time range used for querying, shifting shouldn't be recursive.

Environment:

  • Infrastructure: Kubernetes
  • Deployment tool: helm

Additional Context
I can share some screenshots if needed.

@AlissonRS
Copy link
Author

On a side note, the issue might be caused by the fact when the UI applies the time shift on the right panel calendar (for the trace query by ID), it also updates the left panel calendar (for the trace list).

So the two calendars seem to be sharing the same state. If I have some free time, I can try running it locally and raising a PR.

@joe-elliott
Copy link
Member

Thank you for the detailed issue! This is a Grafana issue though. I will move it over there and tag it appropriately.

@joe-elliott joe-elliott transferred this issue from grafana/tempo May 10, 2024
@aocenas aocenas self-assigned this May 13, 2024
@aocenas aocenas added the needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/explore area/tracing datasource/Tempo needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants