-
Notifications
You must be signed in to change notification settings - Fork 772
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
[OtlpExporter] Registration extension configuration delegate fix #4058
Conversation
…ions instance when named options are not used.
@@ -113,8 +127,7 @@ public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder bui | |||
|
|||
builder.ConfigureServices(services => | |||
{ | |||
services.RegisterOptionsFactory(configuration | |||
=> new OtlpExporterOptions(configuration, defaultBatchOptions: null)); | |||
OtlpTraceExporterHelperExtensions.RegisterOtlpExporterOptionsFactory(services); |
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.
nit: Kinda weird to have this method in OtlpTraceExporterHelperExtensions
. I don't feel strongly this needs to change right now.
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 moved the internal helper extension onto OtlpExporterOptions
that seemed like a slightly better spot for it? 🤣
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4058 +/- ##
==========================================
- Coverage 85.50% 85.49% -0.01%
==========================================
Files 289 289
Lines 11229 11259 +30
==========================================
+ Hits 9601 9626 +25
- Misses 1628 1633 +5
|
Hard to say, it is very nuanced. I'll provide a bit more detail here on the change. When named options are not used... We retrieve the options instance using Options API. Example here. Users registering Options API "things" (IConfigureOptions, IPostConfigureOptions, IValidateOptions, etc.) those will all fire in the correct order at that time. Then the delegate passed to Is this how we would like it to work? No 🤣 Sharing an options class between the 3 signals was probably a mistake. I made a branch to introduce new classes but it was very large and obsoleted a lot of stuff. We felt like this smaller change will work well for most users and is safer for a break fix right before a stable release. But there is another effort to breakup the OtlpExporter project into separate projects for http and grpc. Chatting with @alanwest we hope to fix this up at that time.
Given the above, do you still feel there is an issue? If yes can you share a small repro so I can dig into it? Also if users do run into any issues, do you feel like it is easy enough to switch to named options?
That screenshot is from the logs code right? Don't judge us by the logs code yet! 🤣 The OTel logs spec is up in the air right now so my hands are more or less tied. There is no "DI" support (IServiceCollection/IServiceProvider) at all yet in logs so I can't use Options API. But I will fix that "soon" (as possible). That's what the main-logs branch is all about. |
It is exactly how I'd assume it would work though, given there is a single settings class.
I can see that. Even if the underlying options are the same, if the usage paths are different, different models should indeed be created: one for each. Having said that, as a consumer of this library, it would certainly be really nice if there was an optional, unified path, where you could configure things such as the exporter, in a single place and didn't have to replicate it 3 times. I understand you want to remain flexible and allow distinct configurations for each metric type, but from my experience, that's hardly put to use, as the simplest flow is just to configure resources, exporters, and even instrumentations, all across with the same settings. I'm not saying there shouldn't be an option to customize for each metric type, though I do think a simpler, unified configuration mode should also be available for those who don't need the per-pipeline configurations. For instance, I wish there was a higher level Adding additional extension methods that did this internally could be an easy way to approach that. I liked the change that allows centralization of the resource builder configuration, for example (even though the logging part is still separate).
That makes sense to me if only because of the differences in dependencies (gRPC carries a lot of additional stuff with it I'm pretty sure). I assume you'll have to change the design a bit and change the simple enum-based selection, to a method-based selection to support that kind of separation, right? Perhaps have a "transport" option that you have to call inside The only bad thing about this is that "http" would become "the default", and "grpc" would be seen as an extension (which is not the case today with gRPC being the default mode).
Gotcha, thanks for clarifying.
If you are only manually instantiating the settings in the Logs path and that's supposed to be a temporary approach, then I don't see a huge problem right now, no. As for using named options..... that feels a bit weird here. Hopefully you'd be able to move forward with the separate options classes instead. Options were never supposed to be a "bag of generic settings that can be reused across many different services", but a very specific model for a specific purpose. The fact that multiple options models could have similar or even identical properties, should not change that (this is the type of "duplication of code" that is totally ok and intended). I see the use of named options in this case as a workaround to that original poor design. Another thing to keep in mind is that named options is probably considered an advanced mechanism that a ton of folks are unaware of. The added complexity could damage the usability of this library IMHO and should be avoided as much as possible. |
Fixes #4043
[Check out #4043 for a really good writeup of the issue.]
Changes
AddOtlpExporter
extensions when named options are NOT used.