-
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
[PoC] Change Processor.OnEmit to accept a record pointer #5469
base: main
Are you sure you want to change the base?
Conversation
goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/sdk/log cpu: Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ Processor/Simple-16 536.0n ± 10% 751.2n ± 9% +40.14% (p=0.000 n=10) Processor/Batch-16 1.068µ ± 3% 1.296µ ± 5% +21.35% (p=0.000 n=10) Processor/ModifyTimestampSimple-16 557.8n ± 5% 827.2n ± 8% +48.31% (p=0.000 n=10) Processor/ModifyTimestampBatch-16 1.028µ ± 2% 1.318µ ± 6% +28.22% (p=0.000 n=10) Processor/ModifyAttributesSimple-16 615.2n ± 2% 887.1n ± 3% +44.19% (p=0.000 n=10) Processor/ModifyAttributesBatch-16 1.054µ ± 3% 1.406µ ± 6% +33.33% (p=0.000 n=10) geomean 772.7n 1.048µ +35.60% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ Processor/Simple-16 416.0 ± 0% 834.0 ± 0% +100.48% (p=0.000 n=10) Processor/Batch-16 620.5 ± 2% 1049.5 ± 1% +69.14% (p=0.000 n=10) Processor/ModifyTimestampSimple-16 417.0 ± 0% 834.0 ± 0% +100.00% (p=0.000 n=10) Processor/ModifyTimestampBatch-16 617.5 ± 2% 1047.5 ± 1% +69.64% (p=0.000 n=10) Processor/ModifyAttributesSimple-16 465.0 ± 0% 882.0 ± 0% +89.68% (p=0.000 n=10) Processor/ModifyAttributesBatch-16 642.0 ± 2% 1085.0 ± 1% +69.00% (p=0.000 n=10) geomean 520.3 949.3 +82.44% │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ Processor/Simple-16 1.000 ± 0% 2.000 ± 0% +100.00% (p=0.000 n=10) Processor/Batch-16 0.000 ± 0% 1.000 ± 0% ? (p=0.000 n=10) Processor/ModifyTimestampSimple-16 1.000 ± 0% 2.000 ± 0% +100.00% (p=0.000 n=10) Processor/ModifyTimestampBatch-16 0.000 ± 0% 1.000 ± 0% ? (p=0.000 n=10) Processor/ModifyAttributesSimple-16 2.000 ± 0% 3.000 ± 0% +50.00% (p=0.000 n=10) Processor/ModifyAttributesBatch-16 1.000 ± 0% 2.000 ± 0% +100.00% (p=0.000 n=10) geomean ¹ 1.698 ? ¹ summaries must be >0 to compute geomean
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5469 +/- ##
=====================================
Coverage 84.6% 84.6%
=====================================
Files 267 267
Lines 17825 17825
=====================================
+ Hits 15084 15086 +2
+ Misses 2428 2426 -2
Partials 313 313
|
…pentelemetry-go into log-processor-pointer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Record
type is not concurrent safe. This new pattern almost guarantees concurrent access to the same record. This seems like a design issue that needs to be addressed before this can be accepted.
Could you please elaborate on it? I added a following comment for
Maybe I could change it to:
? EDIT: I have updated the comment to:
Notice that the specification does not require log records to be concurrent safe.
The log records in other languages are not concurrent safe. |
Commenting something like this is not going to be a solution. There are going to be many user use cases that will violate this and having a comment is not an adequate design choice. The point of passing a reference is use the side-effects of modifying the passed record. Additional to users use-case, we by default provide a batch processor. What happens when an processor modifies a record it was passed to a batch processor? |
That is a very good use case. I think the solution could be adding a |
If we want to go with this design, then yeah that sounds correct. This will come with the issue that the |
We could also create a Clone of the record in batch span processor so that the further processors will not modify the record. I will create one PR which does that and a separate which adds a mutex to the log record. |
Like I was saying, that is our implementation. We do not control all the possible user implementations. We should provide a design that works easily and intuitively for those as well. |
I just want to notice that this is a problem that we already have as we have the following comments:
I think that only making the log record concurrent safe will get rid of this problem. I am afraid of the performance consequences of adding a sync.Mutex to each log record, but maybe these are misplaced fears. |
FWIW, adding the mutex has small overhead. It is just its use that will have computational performance impact. |
Fixes #5219
Related to open-telemetry/opentelemetry-specification#4065
Alternative proposal: #5470
Changes
Processor.OnEmit
to:Pros:
Cons:
slog
Processor benchmark results: