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 OTLP exporter #toBuilder() methods to ease autoconfigure customization #5642

Closed
jack-berg opened this issue Jul 20, 2023 · 0 comments · Fixed by #5680
Closed

Add OTLP exporter #toBuilder() methods to ease autoconfigure customization #5642

jack-berg opened this issue Jul 20, 2023 · 0 comments · Fixed by #5680
Labels
Feature Request Suggest an idea for this project

Comments

@jack-berg
Copy link
Member

AutoConfigurationCustomizer supports the ability to customize exporters using methods like addSpanExporterCustomizer.

Maybe you want to use environment variables to configure the OTLP exporters, but add further customization for parameters which aren't configurable (like retry, or custom default metric aggregation). So you'd expect to do something like:

    customizer.addSpanExporterCustomizer(
        (exporter, config) -> {
          if (exporter instanceof OtlpGrpcSpanExporter) {
            return OtlpGrpcSpanExporter.builder()
                .setEndpoint("http://foo.com")
                .setRetryPolicy(RetryPolicy.builder().setMaxAttempts(2).build())
                .build());
          }
          return exporter;
        });

The problem is that you can't access / extend the OTLP exporter parameters which were configured via environment variables, so you're essentially forced into doing all programatic configuration.

I propose we add OtlpGrpcSpanExporter toBuilder() methods to to each of the OTLP exporters. This would allow users to extend the environment variable based config like:

    customizer.addSpanExporterCustomizer(
        (exporter, config) -> {
          if (exporter instanceof OtlpGrpcSpanExporter) {
            exporter.shutdown().join(10, TimeUnit.SECONDS);
            return exporter.toBuilder()
                .setRetryPolicy(RetryPolicy.builder().setMaxAttempts(2).build())
                .build();
          }
          return exporter;
        });

Notice that the user will have to be careful to close the previous exporter before creating a new one, else they'll have unclosed resources like thread pools floating around.

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

Successfully merging a pull request may close this issue.

1 participant