GoogleCloudPlatform / opentelemetry-operations-java

Apache License 2.0
73 stars 38 forks source link

io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException: Unrecognized value for otel.metrics.exporter: google_cloud_monitoring #382

Closed MateuszGawel closed 3 weeks ago

MateuszGawel commented 1 month ago

I followed https://github.com/GoogleCloudPlatform/opentelemetry-operations-java/blob/6455156e9d97eb882f9cca020387ad3cdb525b2e/exporters/auto/README.md

and in GCP I still see:

io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException: Unrecognized value for otel.metrics.exporter: google_cloud_monitoring

when I manuall add:

ENTRYPOINT ["java", "-javaagent:opentelemetry-javaagent.jar", \
    "-Dotel.javaagent.extensions=opentelemetry-operations-java-auto.jar", \
    "-jar", "/main.jar"]
to my dockerfile it works fine, but why do we even need to exporter-auto?

Do I misunderstand?

depenencies:
            <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-metrics</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.cloud.opentelemetry</groupId>
            <artifactId>exporter-auto</artifactId>
            <version>0.33.0-alpha</version>
            <classifier>shaded</classifier>
        </dependency>
psx95 commented 1 month ago

Hi @MateuszGawel,

io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException: Unrecognized value for otel.metrics.exporter: google_cloud_monitoring

Would mean that the auto-exporter jar is not being loaded properly as an agent extension by the process.

I believe the issue here is that the auto-exporter shaded dependency is being downloaded in a different location and when you provide it using

-Dotel.javaagent.extensions=opentelemetry-operations-java-auto.jar

In this case, it's looking for a jar named opentelemetry-operations-java-auto in the current directory and probably not finding it.

I think you might have to copy this downloaded dependency to a specific location and then you can provide it as an argument to the Java command.

I have not used maven in a while, but the way you would do this in gradle is shown in autoinstrument example. Notice the copyAgent task that copies both the OpenTelemetry Java Agent and GCP Auto Exporter extension into a directory named otelagent.

Then the jib task includes this otelagent directory as an extraDirectory within the container image, making the contents available within the image.

About jib

jib is a gradle plugin (also available for Maven) that builds optimized docker images for your Java applications. You can try using it in your case and eliminate the need of a Dockerfile entirely.

Note: jib sets the default entrypoint as the Java command, but allows you to override it though in your case you may not require it.

psx95 commented 3 weeks ago

Marking this issue as fixed, assuming the information in the comment above has resolved the question.

Please feel free to re-open the issue if that is not the case.