Skip to content

Commit

Permalink
[spanmetrics] Sanitize name in mapped dimensions (#3171)
Browse files Browse the repository at this point in the history
* Sanitize name in mapped dimensions

* chlog
  • Loading branch information
mapno committed Nov 23, 2023
1 parent aed8183 commit a0a0ce2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [ENHANCEMENT] Improve TraceQL performance in complex queries. [#3113](https://github.com/grafana/tempo/pull/3113) (@joe-elliott)
* [BUGFIX] Fix compactor ignore configured S3 headers [#3149](https://github.com/grafana/tempo/pull/3154) (@Batkilin)
* [BUGFIX] Prevent building parquet iterators that would loop forever. [#3159](https://github.com/grafana/tempo/pull/3159) (@mapno)
* [BUGFIX] Sanitize name in mapped dimensions in span-metrics processor [#3171](https://github.com/grafana/tempo/pull/3171) (@mapno)

## v2.3.0 / 2023-10-30

Expand Down
2 changes: 1 addition & 1 deletion modules/generator/processor/spanmetrics/spanmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func New(cfg Config, registry registry.Registry, spanDiscardCounter prometheus.C
}

for _, m := range cfg.DimensionMappings {
labels = append(labels, m.Name)
labels = append(labels, sanitizeLabelNameWithCollisions(m.Name))
}

p := &Processor{
Expand Down
6 changes: 3 additions & 3 deletions modules/generator/processor/spanmetrics/spanmetrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ func TestSpanMetricsDimensionMapping(t *testing.T) {
cfg.IntrinsicDimensions.StatusMessage = true
cfg.DimensionMappings = []sharedconfig.DimensionMappings{
{
Name: "foobar",
Name: "foo.bar",
SourceLabel: []string{"foo", "bar"},
Join: "/",
},
Expand Down Expand Up @@ -933,7 +933,7 @@ func TestSpanMetricsDimensionMapping(t *testing.T) {
"span_name": "test",
"status_code": "STATUS_CODE_OK",
"status_message": "OK",
"foobar": "foo-value/bar-value",
"foo_bar": "foo-value/bar-value",
})

assert.Equal(t, 10.0, testRegistry.Query("traces_spanmetrics_calls_total", lbls))
Expand Down Expand Up @@ -1011,7 +1011,7 @@ func TestSpanMetricsDimensionMappingMissingLabels(t *testing.T) {
"status_message": "OK",
"first_only": "first-value",
"world_only": "world-value",
"first/last": "first-value->last-value",
"first_last": "first-value->last-value",
})

assert.Equal(t, 10.0, testRegistry.Query("traces_spanmetrics_calls_total", lbls))
Expand Down

0 comments on commit a0a0ce2

Please sign in to comment.