-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
OTLP log export duplicates logs across all present resources #5782
Comments
@vito Please put a set of log records that can reproduce this bug, thanks! |
We can refer to this
|
@pellared @Frapschen @vito Can I pick this issue if it's okay with you all? |
Able to reproduce
Here: service3 is also showing record for service4 and vice versa. Will start work on this now. |
I have a question regarding the steps to reproduce from the issue description
Is there a possibility to configure the OTel Go Logs SDK that such call is possible? The logs providers is associated with a single instance of a resource. @pree-dew], can you share the code snippet that reproduces the issue? |
@pellared I reproduced it by implementing a small function that might be just taking care of exporting logs
Let me know if I am missing something here. |
@pree-dew, users are expected to emit logs using this API: https://pkg.go.dev/go.opentelemetry.io/otel/log (or a bridge using it). The SDK is not designed to create https://pkg.go.dev/go.opentelemetry.io/otel/sdk/log#Record themselves. The record is created by the Logger returned by https://pkg.go.dev/go.opentelemetry.io/otel/sdk/log#LoggerProvider.Logger. EDIT: I created #5823 |
@pellared My assumptions might be incorrect in that case but I assumed that there might be libraries or tools that just want to export otel compatible logs when the actual logs are received in different format from the base library, might be using it in this way. If that is not the case, then let me know how can I help in documenting this behaviour as it will help others. |
@pellared , @vito has added a reference in the issue where they are using |
Side note: your snippets misses
Sure. You can help fixing #5823. |
@pellared Issue and PR is going to be closed now? |
@pellared I know this is a rare case, but it seems valid to have two providers with a different resource and a shared processor. processor := log.NewBatchProcessor(logExporter)
loggerProvider1 := log.NewLoggerProvider(
log.WithResource(res1),
log.WithProcessor(processor),
)
loggerProvider2 := log.NewLoggerProvider(
log.WithResource(res2),
log.WithProcessor(processor),
) With this, users can push different sets of resources to the same exporter. If so, I think it is still a bug. |
I agree. Reopening |
1. Create scope map with resource key to map the correct log record. 2. Add test case with different resource and scope combination Fixes #5782 ### Benchmarks ``` goos: darwin goarch: arm64 pkg: go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/transform │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ ResourceLogs-8 3.266µ ± 3% 1.100µ ± 5% -66.33% (p=0.000 n=10) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ ResourceLogs-8 8.297Ki ± 0% 2.430Ki ± 0% -70.72% (p=0.000 n=10) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ ResourceLogs-8 178.00 ± 0% 52.00 ± 0% -70.79% (p=0.000 n=10) ``` --------- Co-authored-by: Sam Xie <sam@samxie.me>
Description
When I call
Export
with a[]log.Record
batch that includes records from multiple different resources, it includes all logs for every resource, resulting in duplicates and incorrect data.Seems to be a simple error in code - this line just passes the full set of records along to
ScopeLogs
:opentelemetry-go/exporters/otlp/otlplog/otlploggrpc/internal/transform/log.go
Line 65 in 1b8f785
I suppose it should either send only the subset for the current resource, or check against the resource
Equivalent()
as it populates the per-scope batches.Environment
(I'm aware this is out of date but afaict the issue exists on
master:
)Steps To Reproduce
Export
with a[]log.Record
with a heterogeneous set of resources.Sorry this is verbal, I can try to put a code example together but figured the linked code would make it seem obvious!
Expected behavior
I would expect the OTLP payload to divide the records across the resources. Instead, all records are sent for all resources.
So
[A1, A2, B3, B4]
ends up as[A: [1, 2, 3, 4], B: [1, 2, 3, 4]}
when instead it should be{A: [1, 2], B: [3, 4]}
.The text was updated successfully, but these errors were encountered: