-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add Sentry tracing #4775
Add Sentry tracing #4775
Conversation
Hi, thanks for working this up! I'll take a look soon. |
Thanks @rmosolgo :) @sl0thentr0py, one of the engineers from Sentry is also interested in it too. |
Thanks again for your work on this! I took a look and:
Sorry about the trouble with testing. In fact, graphql-ruby/lib/graphql/tracing/platform_tracing.rb Lines 75 to 91 in 0f32887
(I added that option after implementing the under-the-hood migration, just in case people ran into trouble. But I never documented it, and I never heard any reports of issues with the new modules. It's time to deprecate (and eventually remove) those old ones!) |
late to the party but the sentry data / span looks good to me from our side! thank you for adding this :) |
alright so we like to make things as zero-configurable as possible, so what I'm going to do on our side now is
let me know if you see a problem with that! I think this is generally useful for all our users. |
👍 Certainly fine with me. It should work to add it to all classes by adding to # add tracing to all GraphQL schemas in the app:
GraphQL::Schema.trace_with(GraphQL::Tracing::SentryTrace) The only problem is ... there's no way to remove it after it's added there. (Under the hood, Another approach might be to add it on the # Monkey-patch this to include tracing on all child schemas, unless it's been disabled:
class GraphQL::Schema
def self.included(child_class)
if Sentry.trace_graphql_by_default? # somehow implement your opt-out configuration
child_class.trace_with(GraphQL::Tracing::SentryTrace)
end
end
end Let me know if I can help with anything while you're looking for a solution! |
yep something like that, thanks for the samples! We will just have a top-level switch to turn off the whole patch and then people can of course add it manually to the ones they prefer. We just prefer to make it easier for the 99% use case to work with minimal configuration. |
Closes #3655
Adds support for sending traces to Sentry. The data names follow the OpenTelemetry Semantic Conventions, which is how Sentry say data should be sent.
Points for consideration
I've aliased
execute_multiplex
/analyze_multiplex
tographql.execute_multiplex
/graphql.analyze_multiplex
operations, rather thangraphql.execute
/graphql.analyze
which is what other tracers do. This is because the initial entry point for queries seems to beexecute_multiplex
, followed by anexecute_query
call later. If there is just one operation in theexecute_multiplex
span, we'd end up with two spans with identical names in the same transaction, which could be confusing. The description could be postponed until theexecute_query
is called, but I felt it was useful to have an overall description set at the top of the span.When an operation name is not set, I've not used
anonymous
as the identifier which is what the base class does, but followed the OpenTelemetry spec which states that the name should be omitted.If the operation name and type are both missing, this defaults to
GraphQL Operation
, which is what has been suggested by the OpenTelemetry convention.No attempt is made to sanitize the GraphQL document for any sensitive data.
I've not snake-cased the data names, although Sentry suggests this is preferred.
Questions ❓
In testing I've found that the tests for
GraphQL::Tracing::SentryTracing
(the legacy tracing) useGraphQL::Tracing::SentryTrace
unless I removerequire 'graphql/tracing/sentry_trace'
formgraphql/tracing.rb
. Is there a better way to ensure that theSentryTracing
spec actually testsSentryTracing
?