opentelemetry-java-instrumentation icon indicating copy to clipboard operation
opentelemetry-java-instrumentation copied to clipboard

Add automatic MongoDB instrumentation to the OTel starter

Open zeitlinger opened this issue 1 year ago • 3 comments

Based on https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/11256

View actual diff: https://github.com/zeitlinger/opentelemetry-java-instrumentation/compare/spring-testing-project...zeitlinger:opentelemetry-java-instrumentation:spring-mongo

Fixes https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/11210

zeitlinger avatar Apr 23 '24 15:04 zeitlinger

@jeanbisutti this test only fails in spring native mode with the following error:

Caused by: java.lang.ClassNotFoundException: org.springframework.data.mongodb.core.aggregation.AggregationOperation

Can you help?

zeitlinger avatar Apr 24 '24 06:04 zeitlinger

@jeanbisutti this test only fails in spring native mode with the following error:

Caused by: java.lang.ClassNotFoundException: org.springframework.data.mongodb.core.aggregation.AggregationOperation

Can you help?

@zeitlinger It seems related to the Spring code, not the OTel Starter code (to check).

In this case, the following code in the RuntimeHints class solves the issue:

    hints
        .reflection()
        .registerType(
            TypeReference.of("org.springframework.data.mongodb.core.aggregation.AggregationOperation"),
            hint -> {
              hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_DECLARED_METHODS);
            });

jeanbisutti avatar Apr 25 '24 16:04 jeanbisutti

@zeitlinger I confirm that the GraalVM native issue is related to the Spring code, not the OpenTelemetry code. I have pushed a fix on your branch.

jeanbisutti avatar Apr 26 '24 10:04 jeanbisutti