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

does not work with OpenTelemetry javaagent running at the same time #467

Open
brenol opened this issue Dec 22, 2023 · 0 comments
Open

does not work with OpenTelemetry javaagent running at the same time #467

brenol opened this issue Dec 22, 2023 · 0 comments

Comments

@brenol
Copy link

brenol commented Dec 22, 2023

Expected Behavior

It works with the javaagent at the same time

Actual Behaviour

JavaAgent throws a stacktrace when micronaut-tracing is trying to register itself, saying that GlobalOpenTelemetry.set calls are ignored:

[otel.javaagent 2023-12-22 10:32:49:465 -0300] [scheduled-executor-thread-1] WARN io.opentelemetry.api.GlobalOpenTelemetry - You are currently using the OpenTelemetry Instrumentation Java Agent; all GlobalOpenTelemetry.set calls are ignored - the agent provides the global OpenTelemetry object used by your application.
java.lang.Throwable
	at io.opentelemetry.api.GlobalOpenTelemetry.set(GlobalOpenTelemetry.java:101)
	at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.build(AutoConfiguredOpenTelemetrySdkBuilder.java:401)
	at io.micronaut.tracing.opentelemetry.DefaultOpenTelemetryFactory.defaultOpenTelemetry(DefaultOpenTelemetryFactory.java:112)
	at io.micronaut.tracing.opentelemetry.$DefaultOpenTelemetryFactory$DefaultOpenTelemetry0$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2307)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2277)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2289)
	at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3056)
	at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:81)
	at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2958)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2919)
	at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2730)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1693)
	at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:89)
	at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2165)
	at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForConstructorArgument(AbstractInitializableBeanDefinition.java:1328)
      ...

Some spans (like HTTP request spans) work correctly for some reason. Functions annotated with @NewSpan won't work at all.

Steps To Reproduce

Run a program with these args:
VM Options: -javaagent:/tmp/opentelemetry-javaagent.jar
Environment variable: OTEL_JAVAAGENT_DEBUG=true

Used dependencies:

<dependency>
	<groupId>io.micronaut.tracing</groupId>
	<artifactId>micronaut-tracing-opentelemetry</artifactId>
	<version>6.1.1</version>
</dependency>
<dependency>
	<groupId>io.micronaut.tracing</groupId>
	<artifactId>micronaut-tracing-opentelemetry-http</artifactId>
	<version>6.1.1</version>
</dependency>
<dependency>
	<groupId>io.opentelemetry</groupId>
	<artifactId>opentelemetry-extension-kotlin</artifactId>
</dependency>

Environment Information

OS: Ubuntu 20
JVM:

OpenJDK Runtime Environment Corretto-17.0.7.7.1 (build 17.0.7+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.7.7.1 (build 17.0.7+7-LTS, mixed mode, sharing)

Example Application

https://github.com/brenol/mn-tracing-issue-467/tree/main

Version

4.2.2

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

No branches or pull requests

1 participant