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

Add SPI for customizing metric export #3437

Closed
jack-berg opened this issue Aug 3, 2021 · 2 comments
Closed

Add SPI for customizing metric export #3437

jack-berg opened this issue Aug 3, 2021 · 2 comments
Labels
Feature Request Suggest an idea for this project

Comments

@jack-berg
Copy link
Member

Is your feature request related to a problem? Please describe.
There is no way to configure custom metric exporters.

SdkMeterProviderConfigurer provides a hook to register views and set the resource via configure(SdkMeterProviderBuilder meterProviderBuilder). However, this is insufficient for customizing metric exporter configuration since both push (IntervalMetricReader) and pull (PrometheusCollector) based exporters require access to a built SdkMeterProvider. If you were to call SdkMeterProviderBuilder#build() in configure(SdkMeterProviderBuilder), you'd have access to a different instance the one that gets registered globally.

Describe the solution you'd like
I'd like to extend SdkMeterProviderConfigurer with an additional callback method which would be invoked after the SdkMeterProvider has been built and registered globally. This would provide a place to customize metric exporters and IntervalMetricReader in ways not exposed by autoconfigure env vars / system properties.

  /** Callback which is invoked after the {@link SdkMeterProvider} has been built and registered globally. */
  default void callback(SdkMeterProvider sdkMeterProvider) {}

Describe alternatives you've considered
Also considered adding ConfigurableMetricExporterProvider akin to ConfigureableSpanExporterProvider, but doesn't solve the problem because metric exporters also need an IntervalMetricReader (or in prometheus' case a server to expose the data). Unclear how that would be exposed via SPI and tie in neatly with ConfigurableMetricExporterProvider.

Additional context
I'm trying to use SPI hooks to customize OtlpGrpcMetricExporter to set my own MangedChannel which is configured with retry logic in accordance with the spec but can't. I opened Issue #3271 to separately address adding retry logic to the OTLP exporters.

@jack-berg jack-berg added the Feature Request Suggest an idea for this project label Aug 3, 2021
@jkwatson
Copy link
Contributor

jkwatson commented Aug 3, 2021

Yes, we had been holding off on this until the metrics SDK got more stable.

@jack-berg
Copy link
Member Author

This is solved with the addition of ConfigurableMetricExporterProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Suggest an idea for this project
Projects
None yet
Development

No branches or pull requests

2 participants