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

@robertlaurin robertlaurin May 10, 2024

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@karmingc, I apologize for how long the cycles on this PR have been. I brought this concern to the Semantic Conventions repo.

Issue: open-telemetry/semantic-conventions#1361
PR: open-telemetry/semantic-conventions#1389

If you have any feedback on the proposed span name, let's discuss it in the PR. (cc @robertlaurin @arielvalentin)

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?

Copy link
Contributor

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale Marks an issue/PR stale label Jun 14, 2024
@arielvalentin arielvalentin added keep Ensures stale-bot keeps this issue/PR open and removed stale Marks an issue/PR stale labels Jun 14, 2024
@kaylareopelle
Copy link
Contributor

Hi @karmingc! Whew, this has been a journey! I appreciate your patience.

We brought these questions to the semantic conventions repo. After some discussion, the decision was to change the span name to be graphql.operation.type by default, and to allow instrumentation authors to add a configuration option to append graphql.operation.name to the span name if a user opts in.

With this in mind, are you interested in updating this PR to fit with the new semantic convention?
open-telemetry/semantic-conventions#1389

@karmingc
Copy link
Author

Hi @karmingc! Whew, this has been a journey! I appreciate your patience.

We brought these questions to the semantic conventions repo. After some discussion, the decision was to change the span name to be graphql.operation.type by default, and to allow instrumentation authors to add a configuration option to append graphql.operation.name to the span name if a user opts in.

With this in mind, are you interested in updating this PR to fit with the new semantic convention? open-telemetry/semantic-conventions#1389

Hi, I haven't had the chance to comment/reply for a while given that I am no longer involved on Ruby-related applications at work. However, I'm still open to fixing these! I'll try to update in the upcoming weeks if possible.

If somebody needs this to be prioritized, feel free to pick it up as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Ensures stale-bot keeps this issue/PR open
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow semantic conventions for naming graphql spans
4 participants