Skip to content

Conversation

@marctrem
Copy link

@marctrem marctrem commented Nov 30, 2025

Summary

Fixes Query Builder UI returning empty results for ExponentialHistogram metrics. The MetricAggregation.Type field was never being populated from metadata, causing exponential histogram queries to route to the wrong table (samples instead of exp_hist).


Changes

  • Bug fix: Add FetchTypeMulti method to MetadataStore interface to fetch metric types
  • Bug fix: Implement type fetching from metrics metadata table in telemetrymetadata
  • Bug fix: Populate Type field in querier alongside existing Temporality enrichment
  • Bug fix: Update mock store for testing

Required: Add Relevant Labels

  • backend
  • bug

Reviewers

  • backend

How to Test

  1. Ingest ExponentialHistogram metrics (e.g., via OTEL collector with enable_exp_hist: true)
  2. Open Query Builder in SigNoz UI
  3. Select an ExponentialHistogram metric from the dropdown
  4. Choose an aggregation (P50, P95, P99)
  5. Run query - should now return data (previously returned empty results)
  6. Verify regular histogram/gauge/sum metrics still work correctly

🔍 Related Issues

N/A


Screenshots / Screen Recording (if applicable / mandatory for UI related changes)

Would previously return empty results for ExponentialHistogram.
image


Checklist

  • Dev Review
  • Test cases added (Unit/ Integration / E2E)
  • Manually tested the changes

Notes for Reviewers

Root Cause

  1. MetricAggregation.Type has json:"-" tag in builder_elements.go:25, so it cannot be deserialized from frontend JSON requests
  2. The querier (pkg/querier/querier.go) enriches Temporality from metadata but never fetches or populates Type
  3. The routing logic in sub_query.go:98 that checks if mq.AggregateAttribute.Type == v3.AttributeKeyType(v3.MetricTypeExponentialHistogram) never triggers
  4. Queries go to the regular samples table instead of exp_hist, returning no data

Solution

Follow the same pattern already used for Temporality enrichment - fetch Type from metadata and populate it before query execution.


Note

Fetches metric Type for all referenced metrics and injects it into builder aggregations; adds FetchTypeMulti to metadata store with ClickHouse implementation and test mock support.

  • Querier (pkg/querier/querier.go):
    • Fetches metric Type for all referenced metrics via metadataStore.FetchTypeMulti.
    • Populates missing MetricAggregation.Type from fetched metadata alongside existing temporality enrichment.
  • Telemetry Metadata (pkg/telemetrymetadata/metadata.go):
    • Adds FetchTypeMulti and underlying fetchMetricsType querying metrics_fields (uses argMax(type, last_reported_unix_milli)).
    • Maps string types to metrictypes.Type (e.g., gauge, sum, histogram, exponentialhistogram).
  • Types/Interfaces (pkg/types/telemetrytypes/store.go):
    • Extends MetadataStore with FetchTypeMulti.
  • Tests/Mocks (pkg/types/telemetrytypes/telemetrytypestest/metadata_store.go):
    • Adds TypeMap, FetchTypeMulti, and SetType to mock store.

Written by Cursor Bugbot for commit abbd6a5. This will update automatically on new commits. Configure here.

The MetricAggregation.Type field was never being populated from metadata,
causing exponential histogram queries to route to the wrong table (samples
instead of exp_hist).

This fix:
- Adds FetchTypeMulti method to MetadataStore interface
- Implements type fetching from metrics metadata table
- Populates Type field in querier alongside existing Temporality enrichment
- Updates mock for testing

Fixes queries for ExponentialHistogram metrics in Query Builder UI.
@CLAassistant
Copy link

CLAassistant commented Nov 30, 2025

CLA assistant check
All committers have signed the CLA.

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.

2 participants