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

DI support for configuring EventCounters #833

Open
1 task
dpk83 opened this issue Dec 15, 2022 · 1 comment · May be fixed by #2078
Open
1 task

DI support for configuring EventCounters #833

dpk83 opened this issue Dec 15, 2022 · 1 comment · May be fixed by #2078
Labels
comp:instrumentation.eventcounters Things related to OpenTelemetry.Instrumentation.EventCounters

Comments

@dpk83
Copy link

dpk83 commented Dec 15, 2022

Issue with OpenTelemetry.Instrumentation.EventCounters

Is this a feature request or a bug?

  • [x ] Feature Request
  • Bug

What is the expected behavior?

  • Event counters instrumentation can be enabled when using DI based APIs i.e. services.AddOpenTelemetryMetrics(...) and support providing options via IConfigurationSection

What do you expect to see?

  • AddEventCountersInstrumentation work with IDeferredMeterProviderBuilder
  • Another overload
public static MeterProviderBuilder AddEventCountersInstrumentation(this MeterProviderBuilder builder, IConfigurationSection)  

What is the actual behavior?

Today it only works for non DI mode. Options can't be provided directly via configuration

Additional Context

Add any other context about the feature request here.

@dpk83 dpk83 added the comp:instrumentation.eventcounters Things related to OpenTelemetry.Instrumentation.EventCounters label Dec 15, 2022
@CodeBlanch
Copy link
Member

Just FYI 1.4.0 SDK is introducing an updated pattern which allows better integration than what IDeferredMeterProviderBuilder can provide. I would recommend using OpenTelemetry.Exporter.Prometheus.AspNetCore as a guide for this effort.

Instead of...

public static MeterProviderBuilder AddEventCountersInstrumentation(this MeterProviderBuilder builder, IConfigurationSection)  

...add...

public static MeterProviderBuilder AddEventCountersInstrumentation(
   this MeterProviderBuilder builder,
   string name,
   Action<EventCountersInstrumentationOptions> configure)

The way the pattern is implemented, if users want to bind to IConfiguration they can do something like this...

services.Configure<EventCountersInstrumentationOptions>(config.GetSection("otel:eventcounters"));
services.Configure<EventCountersInstrumentationOptions>("NamedExporter", config.GetSection("otel:eventcounters"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.eventcounters Things related to OpenTelemetry.Instrumentation.EventCounters
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants