Skip to content

Commit

Permalink
Add missing apply_to_spans section support (#2301)
Browse files Browse the repository at this point in the history
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 <a9@aneurysm9.com>
  • Loading branch information
tigrannajaryan and Aneurysm9 committed Oct 25, 2021
1 parent 8324034 commit 36b444a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion schema/v1.0/ast/spans.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ type SpanEvents struct {

// SpansChange corresponds to a section representing spans change.
type SpansChange struct {
RenameAttributes *RenameAttributes `yaml:"rename_attributes"`
RenameAttributes *AttributeMapForSpans `yaml:"rename_attributes"`
}

// AttributeMapForSpans corresponds to a section representing a translation of
// attributes for specific spans.
type AttributeMapForSpans struct {
ApplyToSpans []types.SpanName `yaml:"apply_to_spans"`
AttributeMap AttributeMap `yaml:"attribute_map"`
}

// SpanEventsChange corresponds to a section representing span events change.
Expand Down
3 changes: 2 additions & 1 deletion schema/v1.0/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ func TestParseSchemaFile(t *testing.T) {
Spans: ast.Spans{
Changes: []ast.SpansChange{
{
RenameAttributes: &ast.RenameAttributes{
RenameAttributes: &ast.AttributeMapForSpans{
AttributeMap: ast.AttributeMap{
"peer.service": "peer.service.name",
},
ApplyToSpans: []types.SpanName{"HTTP GET"},
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion schema/v1.0/testdata/valid-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ versions:
# the new attribute name starting from this version.
attribute_map:
peer.service: peer.service.name

apply_to_spans:
# apply only to spans named "HTTP GET"
- "HTTP GET"
span_events:
changes:
# Sequence of translations to apply to convert the schema from a prior version
Expand Down

0 comments on commit 36b444a

Please sign in to comment.