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 automatic MongoDB instrumentation to the OTel starter #11211

Merged
merged 17 commits into from
May 16, 2024

Conversation

zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Apr 23, 2024

Fixes #11210

@zeitlinger zeitlinger self-assigned this Apr 23, 2024
@zeitlinger zeitlinger requested a review from a team April 23, 2024 15:04
@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label Apr 23, 2024
@zeitlinger zeitlinger mentioned this pull request Apr 23, 2024
4 tasks
@zeitlinger
Copy link
Member Author

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

@jeanbisutti
Copy link
Member

@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
Copy link
Member

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

@zeitlinger zeitlinger force-pushed the spring-mongo branch 2 times, most recently from 1cf8c56 to 5070000 Compare April 30, 2024 13:13
@zeitlinger zeitlinger marked this pull request as ready for review April 30, 2024 13:59
Copy link
Member

@jeanbisutti jeanbisutti left a comment

Choose a reason for hiding this comment

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

Maybe rename the PR to something more specific, like "Add automatic MongoDB instrumentation to the OTel starter"?

@zeitlinger zeitlinger changed the title support mongo client Add automatic MongoDB instrumentation to the OTel starter May 2, 2024
@zeitlinger zeitlinger marked this pull request as draft May 3, 2024 09:06
@zeitlinger zeitlinger added this to the v2.4.0 milestone May 14, 2024
@zeitlinger zeitlinger marked this pull request as ready for review May 16, 2024 04:52
MongoTelemetry.builder(openTelemetry)
.setStatementSanitizationEnabled(
config.getBoolean(
"otel.instrumentation.mongo.statement-sanitizer.enabled", true))
Copy link
Contributor

Choose a reason for hiding this comment

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

agent uses the value of common sanitizer property as the default

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in #11350

Comment on lines +63 to +68
@EventListener(ApplicationReadyEvent.class)
public void loadData() {
jdbcTemplate
.getObject()
.execute("create table test_table (id bigint not null, primary key (id))");
}
Copy link
Contributor

@laurit laurit May 16, 2024

Choose a reason for hiding this comment

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

how is this related to mongo?

Copy link
Member Author

Choose a reason for hiding this comment

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

moved from another class so that the mongo test is not affected

@laurit laurit merged commit 6b66434 into open-telemetry:main May 16, 2024
53 checks passed
@zeitlinger zeitlinger deleted the spring-mongo branch May 16, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test native This label can be applied to PRs to trigger them to run native tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spring starter: support mongo client
3 participants