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 exporter configurations to springboot autoconfigure #729

Merged

Conversation

mabdinur
Copy link
Contributor

@mabdinur mabdinur commented Jul 19, 2020

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 :)

@mabdinur mabdinur marked this pull request as ready for review July 20, 2020 04:13
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
* Configuration for OpenTelemetry Tracer
*
* <p>Configures LoggingExporter and sets default tracer name
* <p>Sets default tracer name and sampler probability
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go ahead and remove this, and instead add javadoc to at least the getters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these included transitively from the above deps? Even if not, these should be compileOnly as well, not implementation

Copy link
Contributor Author

@mabdinur mabdinur Jul 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Contributor

@anuraaga anuraaga Jul 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

@mabdinur mabdinur Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines 34 to 35
api deps.opentelemetryApi
api "io.opentelemetry:opentelemetry-exporters-logging:0.5.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving these apis to an opentelemetry-spring-starter. A draft of this can be see here: mabdinur#6

Copy link

@udekel udekel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments attached.

return;
}
private void addSpanProcessors(List<SpanExporter> spanExporters) {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] Drop the extra newline here.

private void setSampler(TracerProperties tracerProperties) {
TraceConfig.getDefault()
.toBuilder()
.setSampler(Samplers.probability(tracerProperties.getSamplerProbability()))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] Is that always guaranteed to be a valid value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added validators to the TracerProperties class that bounds the decimal value between 0 and 1

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
* Configuration for OpenTelemetry Tracer
*
* <p>Configures LoggingExporter and sets default tracer name
* <p>Get Tracer Name {@link getName()}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just use ofSeconds(1)

@trask
Copy link
Member

trask commented Jul 22, 2020

hey @mabdinur, can you merge master into your branch to fix the finatra CI failure (see #747)?

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mabdinur mabdinur force-pushed the add_exports_to_springboot_autoconfigure branch from f8f59d2 to 97ff9ae Compare July 23, 2020 00:38
@mabdinur mabdinur requested a review from trask July 23, 2020 05:08
Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one thing below.

@mabdinur mabdinur requested a review from trask July 23, 2020 19:25
Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

mabdinur and others added 12 commits July 24, 2020 21:32
…/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>
mabdinur and others added 7 commits July 24, 2020 21:32
…/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>
@mabdinur mabdinur force-pushed the add_exports_to_springboot_autoconfigure branch from 0e761ec to 6535eda Compare July 24, 2020 21:33
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like the transitive dependency problem got fixed. Doesn't it work to remove these extra compileOnly completely?

@mabdinur mabdinur requested a review from anuraaga July 27, 2020 00:01
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@anuraaga anuraaga merged commit 72c36b4 into open-telemetry:master Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants