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

Support OpenTelemetry auto instrumentation #3631

Merged
merged 7 commits into from Jun 3, 2023

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented May 23, 2023

No description provided.

@@ -1193,7 +1193,7 @@ public static IGraphQLBuilder UseTelemetry(this IGraphQLBuilder builder, Action<
public static IGraphQLBuilder UseTelemetry(this IGraphQLBuilder builder, Action<GraphQLTelemetryOptions, IServiceProvider>? configure)
{
builder.Services.Configure(configure);
builder.ConfigureExecution<GraphQLTelemetryProvider>();
builder.Services.TryRegister<IConfigureExecution, GraphQLTelemetryProvider>(ServiceLifetime.Singleton, RegistrationCompareMode.ServiceTypeAndImplementationType);
Copy link
Member Author

Choose a reason for hiding this comment

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

Not necessary if #3628 is merged

@Shane32
Copy link
Member Author

Shane32 commented May 23, 2023

Before merging, this PR should link to the applicable documentation at https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation which indicates this is the correct pattern to support automatic instrumentation. So far I am unable to find any.

@RassK
Copy link

RassK commented May 25, 2023

Before merging, this PR should link to the applicable documentation at https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation which indicates this is the correct pattern to support automatic instrumentation. So far I am unable to find any.

Maybe this can be used for initial reference. Due you are the most responsive currently, this will be the first implementation. We probably would like to reconfirm it with 1-2 other library authors and after that proper documentation will be released. The first implementations would be probably linked as an actual references.
If that happens I could notify or open a fix PR to add the final link, if that is ok with you?

@Shane32
Copy link
Member Author

Shane32 commented May 25, 2023

@RassK Using the sample code provided in the issue you linked, I created a test, which does not pass because (a) the binding flag needs to be public, not non-public, and (b) the arguments were not passed to the method.

Can you provide a link to the reflection code that calls this EnableAutoInstrumentation method? Then we can be sure the implementation here matches the expected implementation within the OpenTelemetry library -- at least for the current version of OpenTelemetry,

@Shane32
Copy link
Member Author

Shane32 commented May 25, 2023

@sungam3r The changes here are minor and do not cause public API changes. The only behavioral change would be that if auto-telemetry were enabled, AND someone called UseTelemetry, now the telemetry GraphQL hook (IConfigureExecution instance) would be installed prior to any other hooks regardless of where UseTelemetry was located within AddGraphQL. That should be best anyway, but regardless does not affect execution of GraphQL requests.

I support merging this change.

@Shane32 Shane32 requested a review from sungam3r May 25, 2023 13:58
@Shane32
Copy link
Member Author

Shane32 commented May 25, 2023

Note: at the moment we are relying @RassK 's test build to know that the code works as intended with the OpenTelemetry SDK. Perhaps someone could add a sample project with a reference to OpenTelemetry and tests to verify it "end to end". But I do not intend to figure out if/how this is possible.

@RassK
Copy link

RassK commented May 25, 2023

@RassK Using the sample code provided in the issue you linked, I created a test, which does not pass because (a) the binding flag needs to be public, not non-public, and (b) the arguments were not passed to the method.

Can you provide a link to the reflection code that calls this EnableAutoInstrumentation method? Then we can be sure the implementation here matches the expected implementation within the OpenTelemetry library -- at least for the current version of OpenTelemetry,

Updated the issue in OpenTelemetry AutoInstrumentation about the correct usage.

The final implementation is here >
https://github.com/RassK/opentelemetry-dotnet-instrumentation/pull/954/files#diff-8b2aefd647deef50f042e7b6d65abf19f8acb24c29f26dce47937051380d06d0R23

We do have end to end tests, but at least rc package has to be available in the Nuget to test it.

@Shane32
Copy link
Member Author

Shane32 commented May 25, 2023

I updated the tests in this PR to align as closely as possible with RassK/opentelemetry-dotnet-instrumentation#954.

@codecov-commenter
Copy link

Codecov Report

Merging #3631 (a746db4) into master (2d03814) will decrease coverage by 0.03%.
The diff coverage is 52.17%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #3631      +/-   ##
==========================================
- Coverage   83.91%   83.88%   -0.03%     
==========================================
  Files         381      382       +1     
  Lines       16892    16914      +22     
  Branches     2718     2720       +2     
==========================================
+ Hits        14175    14189      +14     
- Misses       2070     2079       +9     
+ Partials      647      646       -1     
Impacted Files Coverage Δ
src/GraphQL/Telemetry/GraphQLTelemetryOptions.cs 100.00% <ø> (ø)
src/GraphQL/DI/GraphQLBuilderBase.cs 78.94% <31.25%> (-18.62%) ⬇️
src/GraphQL/Extensions/GraphQLBuilderExtensions.cs 93.75% <100.00%> (+0.25%) ⬆️
...phQL/Telemetry/OpenTelemetryAutoInstrumentation.cs 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@Shane32 Shane32 merged commit bbd3f5d into master Jun 3, 2023
7 of 8 checks passed
@Shane32 Shane32 deleted the support_auto_instrumentation branch June 3, 2023 13:35
@Shane32 Shane32 added this to the 7.5 milestone Jun 17, 2023
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.

None yet

3 participants