Skip to content

Handle kafka METRIC_REPORTER_CLASSES_CONFIG being set to a List#9155

Merged
laurit merged 2 commits into
open-telemetry:mainfrom
laurit:kafka-list
Aug 9, 2023
Merged

Handle kafka METRIC_REPORTER_CLASSES_CONFIG being set to a List#9155
laurit merged 2 commits into
open-telemetry:mainfrom
laurit:kafka-list

Conversation

@laurit

@laurit laurit commented Aug 8, 2023

Copy link
Copy Markdown
Contributor

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 August 8, 2023 08:12

@mateuszrzeszutek mateuszrzeszutek left a comment

Copy link
Copy Markdown
Member

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

laurit commented Aug 8, 2023

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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