-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use OTel recommended names for attributes (#79)
* Use OTel recommended names for attributes OpenTelemetry documents some conventional names to use for some pieces of GraphQL server data. This change renames one attribute and adds two more in line with OTel's recommendation, and also changes the name given to the span that is started. - Attribute "graphql.operation.name" was added - Attribute "graphql.operation.type" was added - BREAKING: "graphql.request.query" was renamed to "graphql.document". - Span name was changed to `graphql.operation.type` + `graphql.operation.name` if those fields are present, else "GraphQL Operation" See: <https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/instrumentation/graphql/> * Get operation name and type from blueprint * Update changelog * Document the trace_request_name and trace_request_type options * Stringify the otel semantic convention attributes Turns out tests break when we use atoms. Ideally we should look into replacing all attributes with atoms instead, but for the sake of simplicity this commit opts for using strings instead. * Change behavior of the span_name config option * Deprecate setting span_name --------- Co-authored-by: mae.kasza <26093674+MaeIsBad@users.noreply.github.com>
- Loading branch information
Showing
11 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule OpentelemetryAbsintheTest.SpanName do | ||
use OpentelemetryAbsintheTest.Case | ||
|
||
alias OpentelemetryAbsintheTest.Support.GraphQL.Queries | ||
alias OpentelemetryAbsintheTest.Support.Query | ||
|
||
describe "span name" do | ||
test "defaults to GraphQL Operation" do | ||
OpentelemetryAbsinthe.Instrumentation.setup() | ||
assert "GraphQL Operation" = Query.query_for_span_name(Queries.invalid_query()) | ||
end | ||
|
||
test "is the operation type for an unnamed operation" do | ||
OpentelemetryAbsinthe.Instrumentation.setup() | ||
assert "query" = Query.query_for_span_name(Queries.query()) | ||
assert "mutation" = Query.query_for_span_name(Queries.mutation(), variables: %{"isbn" => "A1"}) | ||
end | ||
|
||
test "is the operation type and name for named operations" do | ||
OpentelemetryAbsinthe.Instrumentation.setup() | ||
assert "query OperationTwo" = Query.query_for_span_name(Queries.batch_queries(), operation_name: "OperationTwo") | ||
end | ||
|
||
test "can be overriden with the configuration" do | ||
span_name = "graphql? I hardly know er" | ||
OpentelemetryAbsinthe.Instrumentation.setup(span_name: span_name) | ||
assert ^span_name = Query.query_for_span_name(Queries.batch_queries(), operation_name: "OperationTwo") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters