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

Allowed derived telemetry providers #3848

Merged
merged 10 commits into from
Dec 24, 2023
Merged

Allowed derived telemetry providers #3848

merged 10 commits into from
Dec 24, 2023

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented Dec 23, 2023

No description provided.

@Shane32 Shane32 self-assigned this Dec 23, 2023
builder.Services.Configure(configure);
builder.Services.TryRegister<IConfigureExecution, GraphQLTelemetryProvider>(ServiceLifetime.Singleton, RegistrationCompareMode.ServiceTypeAndImplementationType);
return builder;
}

/// <inheritdoc cref="UseTelemetry(IGraphQLBuilder, Action{GraphQLTelemetryOptions}?)"/>
public static IGraphQLBuilder UseTelemetry<TProvider>(this IGraphQLBuilder builder)
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you pass the GraphQLTelemetryOptions? And if TProvider : GraphQLTelemetryProvider, it may be useful to make TOptions : GraphQLTelemetryOptions, so the options can be extended to support additional configuration for the extended provider.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same issue as ErrorInfoProvider and other builder methods. The user will have to configure options with Configure() to configure the options class they are using.

Copy link
Contributor

@gao-artur gao-artur Dec 23, 2023

Choose a reason for hiding this comment

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

Why not provide an overload with options?

Copy link
Member Author

Choose a reason for hiding this comment

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

This scenario it might make sense to add TOptions : GraphQLTelemetryOptions since if someone wanted a fully custom telemetry provider they should use ConfigureExecution<TProvider>

Copy link
Member Author

Choose a reason for hiding this comment

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

Whereas IErrorInfoProvider does not require any options; just the default implementation allows for certain options. Users should be able to write their own implementation without necessarily using options.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, basically I'd just do all 4 together on request. But if you're requesting them then I'd just add all 4 now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, you are right. I recall now that I used this pattern when need to create options with dependencies

services.AddOptions<IConfiguration>()
    .Configure<GraphQLTelemetryOptions>((configuration, options) => { });

Copy link
Member Author

Choose a reason for hiding this comment

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

Another way to think of it is that people can just AddProvider<T> and they should be quite familiar with DI and the fact that if you have an options class, they need to AddSingleton to register it

Copy link
Member Author

@Shane32 Shane32 Dec 23, 2023

Choose a reason for hiding this comment

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

Not having these extra overloads should not be confusing for any user.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, basically I'd just do all 4 together on request. But if you're requesting them then I'd just add all 4 now.

Please add them. Because I just copied the UseTelemetry method and updated it to register the derived type, because I didn't find a simpler way to do that.

@Shane32 Shane32 added this to the 7.8 milestone Dec 23, 2023
@Shane32
Copy link
Member Author

Shane32 commented Dec 23, 2023

I still need to add tests for the builder overloads but i think this is everything

@codecov-commenter
Copy link

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (59393e9) 84.56% compared to head (814d024) 84.61%.

Files Patch % Lines
src/GraphQL/Extensions/GraphQLBuilderExtensions.cs 80.95% 2 Missing and 2 partials ⚠️
src/GraphQL/Telemetry/GraphQLTelemetryProvider.cs 81.81% 0 Missing and 2 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3848      +/-   ##
==========================================
+ Coverage   84.56%   84.61%   +0.05%     
==========================================
  Files         418      418              
  Lines       19271    19289      +18     
  Branches     3024     3028       +4     
==========================================
+ Hits        16296    16321      +25     
+ Misses       2266     2255      -11     
- Partials      709      713       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Shane32 Shane32 merged commit 110cd51 into master Dec 24, 2023
10 checks passed
@Shane32 Shane32 deleted the telemetry_derived branch December 24, 2023 06:58
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