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

Handle kafka METRIC_REPORTER_CLASSES_CONFIG being set to a List #9155

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Aug 8, 2023

Resolves #9143
For METRIC_REPORTER_CLASSES_CONFIG valid values seem to be a comma separated string with class names, list of classes and list of class names. Instead of checking with regex whether our metrics reporter has been added we'll now check whether instrumentation name has been added to config and is so skip enhancing. Duplicate enhancement happens because we do it in the constructors of producer/consumer and due to constructor chaining it may be called multiple times.

@laurit laurit requested a review from a team as a code owner August 8, 2023 08:12
Copy link
Member

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

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

Is it possible for METRIC_REPORTER_CLASSES_CONFIG to be a single Class<?>?

@laurit
Copy link
Contributor Author

laurit commented Aug 8, 2023

Is it possible for METRIC_REPORTER_CLASSES_CONFIG to be a single Class<?>?

not possible, also using a set instead of a list failed.

Comment on lines +75 to +76
|| config.get(OpenTelemetryMetricsReporter.CONFIG_KEY_OPENTELEMETRY_INSTRUMENTATION_NAME)
!= null) {
Copy link
Member

Choose a reason for hiding this comment

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

can you add a comment, I couldn't figure out what this check is for, thx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is for ensuring that we don't try to modify the same configuration twice, added a comment

Comment on lines -88 to -90
if (METRIC_REPORTER_PRESENT_PATTERN.matcher(className1).find()) {
return class1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure of the original intent, but it sure looked like the pattern was here to attempt to prevent duplicates. Removing this now allows duplicates, which could possibly allow for duplicated telemetry (unless there's some other hidden guardrails in place).

In any case, this is a change in behavior. Looks like there wasn't test coverage anyway, so .........

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a test for this. Duplicates are now handled with config.get(OpenTelemetryMetricsReporter.CONFIG_KEY_OPENTELEMETRY_INSTRUMENTATION_NAME) != null check at the start of the method as outlined in the pr description

@laurit laurit merged commit 54d0e07 into open-telemetry:main Aug 9, 2023
45 checks passed
@laurit laurit deleted the kafka-list branch August 9, 2023 11:49
breedx-splk pushed a commit to breedx-splk/opentelemetry-java-instrumentation that referenced this pull request Aug 15, 2023
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.

Breaks Kafka configuration when METRIC_REPORTER_CLASSES_CONFIG is a List
4 participants