fix: use toJSONString for metric attribute hashing with JSON schema (#2087)#2118
fix: use toJSONString for metric attribute hashing with JSON schema (#2087)#2118doyong365 wants to merge 1 commit intohyperdxio:mainfrom
Conversation
|
|
@doyong365 is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
PR Review✅ No critical issues found. The implementation is correct and well-tested. A few minor observations:
|
89fb034 to
18c427d
Compare
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Summary
When the ClickHouse OTel exporter is configured with
json: true(BETA_CH_OTEL_JSON_SCHEMA_ENABLED), attribute columns (Attributes,ScopeAttributes,ResourceAttributes) are stored asJSONtype instead ofMap(String, String). The existing metric bucketing queries always usedcityHash64(mapConcat(...)), which fails with:This fix detects the column type at query time via
metadata.getColumns()and substitutesmapConcatwithtoJSONString-based hashing when JSON schema is active. The detection falls back to the original Map behaviour if the column lookup fails (e.g. table not yet created). Affected query paths: Gauge, Sum, and Histogram (count + quantile) metrics.Screenshots or video
N/A — backend query generation change only, no UI changes.
How to test locally
BETA_CH_OTEL_JSON_SCHEMA_ENABLED=truein your ClickHouse exporter config (json: true).otel_metrics_gauge,otel_metrics_sum, andotel_metrics_histogramtables.Function mapConcat requires at least one argument of type Maperror.References
{}): Bug: Metric ResourceAttributes and Attributes stored as {} when using JSON schema (ClickStack / BETA_CH_OTEL_JSON_SCHEMA_ENABLED) open-telemetry/opentelemetry-collector-contrib#47582