add exporter configurations to springboot autoconfigure#729
Conversation
| * Configuration for OpenTelemetry Tracer | ||
| * | ||
| * <p>Configures LoggingExporter and sets default tracer name | ||
| * <p>Sets default tracer name and sampler probability |
There was a problem hiding this comment.
Let's go ahead and remove this, and instead add javadoc to at least the getters.
There was a problem hiding this comment.
Sorry. I forgot to clean up the java docs before creating this review. I'll fix this up now
|
|
||
| compileOnly deps.opentelemetryJaeger | ||
| compileOnly deps.opentelemetryOtlp | ||
| implementation group: 'io.grpc', name: 'grpc-api', version: '1.24.0' |
There was a problem hiding this comment.
Aren't these included transitively from the above deps? Even if not, these should be compileOnly as well, not implementation
There was a problem hiding this comment.
When I set the grpc-api dependency to compileOnly I get this exception: org.springframework.beans.factory.UnsatisfiedDependencyException. I'm not sure why this dependency isn't provided transitively by the opentelemetry-java jaeger-exporter. A similar pattern could be seen in the auto-exporter-jaeger and auto-exporter-zipkin modules. I'm not sure if this was intended or if it's a bug
There was a problem hiding this comment.
@trask @anuraaga Should I open an issue to add the io.grpc.grpc-api and io.grpc.grpc-netty-shaded dependencies to the opentelemetry Otlp and Jaeger exporters.
Would it make sense to keep these exporters self contained?
If so, we could also add the io.zipkin.reporter2.zipkin-sender-okhttp3 dependency to the the zipkin exporter.
There was a problem hiding this comment.
Sorry for the late reply.
I think it could make sense to have those transitive dependencies on the exporters in the SDK so could be nice to file an issue.
In the meantime, we can include dependencies here if needed. Can you post the stacktrace for the UnsatisfiedDependencyException? We have e.g., ConditionalOnMissingBean etc because we want to make sure we only instrument what a user brought into their app, so we need to avoid implementation here in favor of compileOnly, etc - api or implementation will bring the dependency into the user's app regardless of their config. If you're seeing it in a test, you may need to use testRuntimeOnly or similar.
There was a problem hiding this comment.
Hmmm after I rebased from master this error went away. It looks like the opentelemetry-exporters-jaeger-0.7.0-SNAPSHOT has the grpc dependencies. I'll change these dependencies to compileOnly
There was a problem hiding this comment.
For reference this is the runtime error I get when I use opentelemetry-exporters-jaeger:0.6.0 and I set io.grpc.grpc-netty-shaded:1.24.0 to compileOnly I get the following error:
Caused by: io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp, grpc-netty, or grpc-netty-shaded artifact
at io.grpc.ManagedChannelProvider.provider(ManagedChannelProvider.java:60) ~[grpc-api-1.28.0.jar:1.28.0]
at io.grpc.ManagedChannelBuilder.forTarget(ManagedChannelBuilder.java:76) ~[grpc-api-1.28.0.jar:1.28.0]
at io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterAutoConfiguration.otelJaegerSpanExporter(JaegerSpanExporterAutoConfiguration.java:52) ~[opentelemetry-spring-boot-autoconfigure-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
at io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterAutoConfiguration$$EnhancerBySpringCGLIB$$652d2c30.CGLIB$otelJaegerSpanExporter$0(<generated>) ~[opentelemetry-spring-boot-autoconfigure-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
at io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterAutoConfiguration$$EnhancerBySpringCGLIB$$652d2c30$$FastClassBySpringCGLIB$$3ee7321d.invoke(<generated>) ~[opentelemetry-spring-boot-autoconfigure-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterAutoConfiguration$$EnhancerBySpringCGLIB$$652d2c30.otelJaegerSpanExporter(<generated>) ~[opentelemetry-spring-boot-autoconfigure-0.6.0-SNAPSHOT.jar:0.6.0-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
... 62 common frames omitted
There was a problem hiding this comment.
hey @mabdinur, can you try adding:
compileOnly group: 'io.grpc', name: 'grpc-api', version: '1.24.0'
to your spring-boot-autoconfigure.gradle?
I think that will fix the current build issue.
For reference this is the runtime error I get when I use opentelemetry-exporters-jaeger:0.6.0 and I set io.grpc.grpc-netty-shaded:1.24.0 to compileOnly
Where are you using io.grpc.grpc-netty-shaded:1.24.0? Is part of an app you are testing? In that case I don't think you want compileOnly. We just want compileOnly for our own transitive dependencies here, so that we don't affect an application's choice of gRPC version.
There was a problem hiding this comment.
I need io.grpc.grpc-netty-shaded:1.24.0 to run the otlp exporter (version 0.6.0) and the jaeger exporter (0.6.0). This dependency wasn't supplied by the exporter package. I don't need to include it in the autoconfigure project. Instead I'll include it in a opentelemetry-spring-starter https://github.com/mabdinur/opentelemetry-java-instrumentation/pull/6/files
| api deps.opentelemetryApi | ||
| api "io.opentelemetry:opentelemetry-exporters-logging:0.5.0" |
There was a problem hiding this comment.
Moving these apis to an opentelemetry-spring-starter. A draft of this can be see here: mabdinur#6
| return; | ||
| } | ||
| private void addSpanProcessors(List<SpanExporter> spanExporters) { | ||
|
|
There was a problem hiding this comment.
[Suggestion] Drop the extra newline here.
| private void setSampler(TracerProperties tracerProperties) { | ||
| TraceConfig.getDefault() | ||
| .toBuilder() | ||
| .setSampler(Samplers.probability(tracerProperties.getSamplerProbability())) |
There was a problem hiding this comment.
[Question] Is that always guaranteed to be a valid value?
There was a problem hiding this comment.
Yes, I added validators to the TracerProperties class that bounds the decimal value between 0 and 1
| * Configuration for OpenTelemetry Tracer | ||
| * | ||
| * <p>Configures LoggingExporter and sets default tracer name | ||
| * <p>Get Tracer Name {@link getName()} |
There was a problem hiding this comment.
Here and elsewhere: You don't need usually need to provide a list of the methods of the class in its documentation. IS there a special convention for beans?
|
|
||
| public void setLoggingExporterEnabled(boolean loggingExporterEnabled) { | ||
| this.loggingExporterEnabled = loggingExporterEnabled; | ||
| public void setSamplerProbability(double samplerProbability) { |
There was a problem hiding this comment.
Is it worth documenting that 0.0 / 1.0 have special values?
| @ConfigurationProperties(prefix = "opentelemetry.trace.exporter.jaeger") | ||
| public final class JaegerSpanExporterProperties { | ||
|
|
||
| private boolean enabled = true; |
There was a problem hiding this comment.
[Note] I'm not sure about the convention, but I'd consider making the defaults part of the class documentation.
I'd also add a link to where that 14250 is coming from.
| private String serviceName = "otel-spring-boot-jaeger-exporter"; | ||
| private String host = "localhost"; | ||
| private int port = 14250; | ||
| private Duration deadline = Duration.ofMillis(1000L); |
trask
left a comment
There was a problem hiding this comment.
good stuff 👍
a couple comments on configuration properties, check out what's coming around common configuration env vars in open-telemetry/opentelemetry-specification#666, good to align the spring configuration with that where possible
f8f59d2 to
97ff9ae
Compare
…/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/jaeger/JaegerSpanExporterProperties.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpGrpcSpanExporterProperties.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/otlp/OtlpGrpcSpanExporterProperties.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/jaeger/JaegerSpanExporterProperties.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/zipkin/ZipkinSpanExporterProperties.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/zipkin/ZipkinSpanExporterProperties.java Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…st/port property javadocs
0e761ec to
6535eda
Compare
| compileOnly "io.opentelemetry:opentelemetry-exporters-logging:0.5.0" | ||
| compileOnly deps.opentelemetryJaeger | ||
| compileOnly deps.opentelemetryOtlp | ||
| compileOnly group: 'io.grpc', name: 'grpc-api', version: '1.24.0' |
There was a problem hiding this comment.
It sounds like the transitive dependency problem got fixed. Doesn't it work to remove these extra compileOnly completely?
Add Spring Boot auto configurations and configuration properties for OTLPGrpcSpanExporter, LoggingSpanExporter, JaegerSpanExporter, and ZipkinSpanExporter.
My next pull request will add spring boot starters for these exporters. Here's a preview: https://github.com/mabdinur/opentelemetry-java-instrumentation/pull/6/files :)