-
Notifications
You must be signed in to change notification settings - Fork 791
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 GraphQL DataFetcher Instrumentation #10998
Add GraphQL DataFetcher Instrumentation #10998
Conversation
3bf6c8e
to
1db723b
Compare
e0a705b
to
e8e263b
Compare
...src/main/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphQLInstrumenterFactory.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphQLInstrumenterFactory.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/graphql/v20_0/OpenTelemetryInstrumentation.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/graphql/v20_0/OpenTelemetryInstrumentation.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/graphql/v20_0/OpenTelemetryInstrumentation.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/graphql/v20_0/OpenTelemetryInstrumentation.java
Show resolved
Hide resolved
...n/java/io/opentelemetry/instrumentation/graphql/v20_0/OpenTelemetryInstrumentationState.java
Outdated
Show resolved
Hide resolved
...brary/src/test/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphQLTelemetryTest.java
Outdated
Show resolved
Hide resolved
...ry/src/main/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphQLTelemetryBuilder.java
Outdated
Show resolved
Hide resolved
...ry/src/main/java/io/opentelemetry/instrumentation/graphql/v20_0/GraphQLTelemetryBuilder.java
Outdated
Show resolved
Hide resolved
e8e263b
to
5c496d2
Compare
Node<?> node = operationDefinition; | ||
if (sanitizeQuery) { | ||
node = sanitize(node); | ||
} | ||
state.setQuery(AstPrinter.printAst(node)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still yet to verify this but suspect this block is the source of performance regressions in our GraphQL endpoint in our production environment. I'm unable to turn this off as this needs to be sanitised.
We are seeing regressions of around 10-100+ milliseconds added to our GraphQL operations when the OpenTelemetry GraphQL instrumentation is turned on. I suspect traversing the AST is causing the regression with larger GraphQL documents resulting in larger regressions.
I think this block needs to be surrounded with a check on span.isRecording()
to at least not impact performance if the span is not sampled.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we could find a way to off load this onto another thread to do this async as to not block the execution of the GraphQL operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can then please do verify. If we can reproduce this then we can figure out a better strategy to handle it. If the query is really large then perhaps we can only handle the start of the query and truncate most of it.
What else do you think I need to do in order to get this over the line? Are there any other concerns that need to be addressed? |
293d9ed
to
1431f52
Compare
@hannahchan I have create a PR hannahchan#1 for your PR that should get it closer to acceptable |
b45ff21
to
a52e219
Compare
Ah I missed this. I'll take a look and incorporate the changes as soon as I can. Thanks. |
ce57745
to
6e80358
Compare
6e80358
to
f6f44bf
Compare
I've merged the above PR into my branch via the command line and updated the unit tests to make sure the data fetcher spans and structure is what we expect it to be under various conditions. I think this is ready to be merged unless there are other things that need to be addressed. |
This PR refactors the GraphQL 20.0 instrumentation to introduce the ability to create spans for DataFetchers.
At a high-level;
GraphQLInstrumeterFactory
GraphQLTelemetryBuilder
,GraphQLTelemetry
with the new options;createSpansForDataFetchers
andcreateSpanForTrivialDataFetchers
OpenTelemetryInstrumentation
with logic to create the actual spans for DataFetchersOpenTelemetryInstrumentationState
to correctly track the OpenTelemetry Context for DataFetchersI was unable to make these changes compatible with previous versions of
graphql-java
.