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

Deduplicate metrics created by loadAndRun #134

Open
danieljbingham opened this issue Dec 12, 2024 · 1 comment · May be fixed by #135
Open

Deduplicate metrics created by loadAndRun #134

danieljbingham opened this issue Dec 12, 2024 · 1 comment · May be fixed by #135
Labels
enhancement New feature or request

Comments

@danieljbingham
Copy link

danieljbingham commented Dec 12, 2024

Is your feature request related to a problem? Please describe.
We've been noticing logs similar to the below, logging constantly for different kafka metrics, reporting multiple values for the same attributes:

[otel.javaagent 2024-11-20 10:01:38:390 +0000] [prometheus-http-1-1] WARN io.opentelemetry.sdk.metrics.internal.state.AsynchronousMetricStorage - Instrument kafka.consumer.connection_close_rate has recorded multiple values for the same attributes: {client-id="recently-watched-ingest"}

This duplication is caused by loadAndRun creating 2 KafkaConsumers with identical client-ids. We validated this by updating the clientId for one of the consumers, and the warning logs disappeared.

Describe the solution you'd like
We should be able to specify different consumerSettings or clientIds per KafkaConsumer to avoid these clashes.

Describe alternatives you've considered

  • We could disable our own logs for this, but this would just hide the problem
  • Only one consumer could be used, but two are required for re-assigning offsets after the initial load

Additional context
loadAndRun method

@danieljbingham danieljbingham added the enhancement New feature or request label Dec 12, 2024
@bcarter97
Copy link
Member

bcarter97 commented Dec 12, 2024

I think because the preloadConsumer is still alive in scope of the postLoad function it is never closed.

for {
given Logger[F] <- Stream.eval(LoggerFactory[F].create)
preloadConsumer <- KafkaConsumer.stream(consumerSettings)
logOffsets <- Stream.eval(logOffsetsForTopics(topics, LoadAll, preloadConsumer)).flatMap(Stream.fromOption(_))
_ <- Stream.eval(info"log offsets: ${logOffsets.show}")
record <- load(logOffsets, preloadConsumer).onFinalizeCase(onLoad) ++ postLoad(logOffsets)
} yield record

Because it's needed to get the logOffsets we have two options as I can see it:

  1. Create a 3rd consumer to get the LogOffsets and destroy this one properly
  2. Destroy the preloadConsumer before calling postLoad

@bcarter97 bcarter97 linked a pull request Dec 12, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants