Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update GraphQL span name to follow semantic conventions #966

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

karmingc
Copy link

@karmingc karmingc commented May 7, 2024

The semantic convention for GraphQL spans is specified here: https://opentelemetry.io/docs/specs/semconv/graphql/graphql-spans/. This will also resolve #560.

@arielvalentin
Copy link
Collaborator

Where the names always wrong?

I will have to take a look at the spec but are there any expectations around backward compatibility like there is with HTTP or Messaging semantics?

cc: @rmosolgo

Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on, @karmingc!

@kaylareopelle
Copy link
Contributor

Where the names always wrong?

I will have to take a look at the spec but are there any expectations around backward compatibility like there is with HTTP or Messaging semantics?

cc: @rmosolgo

@arielvalentin, all the GraphQL semantic conventions for spans are experimental. Breaking changes are allowed.

@kaylareopelle kaylareopelle self-requested a review May 10, 2024 17:06
attributes['graphql.document'] = query.query_string

tracer.in_span('graphql.execute_query', attributes: attributes, &block)
span_name = operation_name ? "#{operation_type} #{operation_name}" : operation_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make too much sense at the spec level. OpenTelemetry consistently discourages high cardinality span names, and this by definition is unbounded cardinality.

Edit to add context. GraphQL operation name is just a free form label supplied by the client caller. There's absolutely no constraints, if we don't put the raw path in an http server span name, I'm not at all convinced we should all operation name here.

Fwiw query, mutation, subscription seems reasonable on its own.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robertlaurin Did you open an issue in the semantic-conventions repo about this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operation_name = query.selected_operation_name

attributes['graphql.operation.name'] = operation_name if operation_name
attributes['graphql.operation.type'] = operation_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a MUST-level part of the spec requiring operation.type to be one of query, mutation or subscription. We weren't checking it previously. I'm not certain we need to validate it now.

Will the gem only send those operation types? What are your thoughts @karmingc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow semantic conventions for naming graphql spans
4 participants