Skip to content

Commit 5c2a83f

Browse files
shbiengAneurysm9
andauthored
Add missing apply_to_spans section support (#2301)
This bug was uncovered during spec review here: open-telemetry/opentelemetry-specification#2008 (comment) apply_to_spans section was missing although it is implied to be present in the description of how span changes section is supposed to work. This fixes the omission by adding apply_to_spans section. This is not a new feature, just fixing a bug in file format description and in the corresponding implementation. Co-authored-by: Anthony Mirabella <[email protected]>
1 parent b49255d commit 5c2a83f

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

schema/v1.0/ast/spans.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ type SpanEvents struct {
3030

3131
// SpansChange corresponds to a section representing spans change.
3232
type SpansChange struct {
33-
RenameAttributes *RenameAttributes `yaml:"rename_attributes"`
33+
RenameAttributes *AttributeMapForSpans `yaml:"rename_attributes"`
34+
}
35+
36+
// AttributeMapForSpans corresponds to a section representing a translation of
37+
// attributes for specific spans.
38+
type AttributeMapForSpans struct {
39+
ApplyToSpans []types.SpanName `yaml:"apply_to_spans"`
40+
AttributeMap AttributeMap `yaml:"attribute_map"`
3441
}
3542

3643
// SpanEventsChange corresponds to a section representing span events change.

schema/v1.0/parser_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ func TestParseSchemaFile(t *testing.T) {
7575
Spans: ast.Spans{
7676
Changes: []ast.SpansChange{
7777
{
78-
RenameAttributes: &ast.RenameAttributes{
78+
RenameAttributes: &ast.AttributeMapForSpans{
7979
AttributeMap: ast.AttributeMap{
8080
"peer.service": "peer.service.name",
8181
},
82+
ApplyToSpans: []types.SpanName{"HTTP GET"},
8283
},
8384
},
8485
},

schema/v1.0/testdata/valid-example.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ versions:
6565
# the new attribute name starting from this version.
6666
attribute_map:
6767
peer.service: peer.service.name
68-
68+
apply_to_spans:
69+
# apply only to spans named "HTTP GET"
70+
- "HTTP GET"
6971
span_events:
7072
changes:
7173
# Sequence of translations to apply to convert the schema from a prior version

0 commit comments

Comments
 (0)