Skip to content

Commit

Permalink
[AIDM-459] Remap OTel GraphQL resource to use query data
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed Dec 4, 2024
1 parent e6017fd commit d4547df
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/trace/api/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,12 @@ func resourceFromTags(meta map[string]string) string {
return m + " " + svc
}
return m
// Enrich GraphQL query resource names
} else if typ := meta[semconv117.AttributeGraphqlOperationType]; typ != "" {
if name := meta[semconv117.AttributeGraphqlOperationName]; name != "" {
return typ + " " + name
}
return typ
}
return ""
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/trace/api/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,18 @@ func TestOTLPHelpers(t *testing.T) {
meta: map[string]string{semconv.AttributeRPCMethod: "M"},
out: "M",
},
{
meta: map[string]string{"graphql.operation.name": "myQuery"},
out: "",
},
{
meta: map[string]string{"graphql.operation.type": "query"},
out: "query",
},
{
meta: map[string]string{"graphql.operation.type": "query", "graphql.operation.name": "myQuery"},
out: "query myQuery",
},
} {
assert.Equal(t, tt.out, resourceFromTags(tt.meta))
}
Expand Down
11 changes: 11 additions & 0 deletions releasenotes/notes/otel-graphql-resource-e31ae2262b52a873.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
enhancements:
- |
For OpenTelemetry GraphQL request spans, the span resource name is now the GraphQL operation type and name.

0 comments on commit d4547df

Please sign in to comment.