1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-16 02:47:20 +02:00
opentelemetry-go/sdk/log
Robert Pająk 6082e830c2
sdk/log: Remove slice allocation from SimpleProcessor.OnEmit (#5493)
The reason for this improvement (apart that, in general, it is good to
have better performance) is there may be good use case to use a
`SimpleProcessor` to emit logs efficiently to standard output. It could
be one of the most efficient solutions (from application performance
perspective) and thanks to such configuration the user would not lose
any logs if the application suddenly crashes. For instance, a useful
configuration could be a simple processor with an OTLP file exporter
(https://github.com/open-telemetry/opentelemetry-go/issues/5408).

I think we might consider changing the following portion of
`SimpleProcessor` documentation (but I would prefer to do it as separate
PR):

> // This Processor is not recommended for production use. The
synchronous
// nature of this Processor make it good for testing, debugging, or
// showing examples of other features, but it can be slow and have a
high
// computation resource usage overhead. [NewBatchProcessor] is
recommended
// for production use instead.

```
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                   449.4n ± 7%   156.2n ±  5%  -65.25% (p=0.000 n=10)
Processor/ModifyTimestampSimple-16    468.0n ± 6%   171.3n ± 15%  -63.40% (p=0.000 n=10)
Processor/ModifyAttributesSimple-16   515.8n ± 3%   233.2n ±  8%  -54.77% (p=0.000 n=10)
geomean                               476.9n        184.1n        -61.40%

                                    │   old.txt   │                 new.txt                 │
                                    │    B/op     │    B/op     vs base                     │
Processor/Simple-16                    417.0 ± 0%     0.0 ± 0%  -100.00% (p=0.000 n=10)
Processor/ModifyTimestampSimple-16     417.0 ± 0%     0.0 ± 0%  -100.00% (p=0.000 n=10)
Processor/ModifyAttributesSimple-16   465.00 ± 0%   48.00 ± 0%   -89.68% (p=0.000 n=10)
geomean                                432.4                    ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

                                    │  old.txt   │                 new.txt                 │
                                    │ allocs/op  │ allocs/op   vs base                     │
Processor/Simple-16                   1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
Processor/ModifyTimestampSimple-16    1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
Processor/ModifyAttributesSimple-16   2.000 ± 0%   1.000 ± 0%   -50.00% (p=0.000 n=10)
geomean                               1.260                    ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
```

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-06-11 07:28:56 -07:00
..
logtest Use reflect to construct a Record in logtest (#5275) 2024-05-06 09:03:14 -07:00
batch_test.go sdk/log: Fix TestBatchProcessor/ForceFlush/ErrorPartialFlush flaky test (#5416) 2024-05-30 07:40:19 -07:00
batch.go chore(deps): update dependency codespell to v2.3.0 (#5409) 2024-05-24 18:09:31 +02:00
bench_test.go sdk/log: Add processor benchmarks (#5448) 2024-06-03 07:14:52 +02:00
DESIGN.md chore(deps): update dependency codespell to v2.3.0 (#5409) 2024-05-24 18:09:31 +02:00
doc.go sdk/log: Scaffolding (#5068) 2024-03-13 17:47:07 +01:00
exporter_test.go Fix flaky test TestBufferExporter/Shutdown/ContextCancelled (#5261) 2024-04-25 17:46:39 +02:00
exporter.go chore(deps): update dependency codespell to v2.3.0 (#5409) 2024-05-24 18:09:31 +02:00
go.mod chore(deps): update module golang.org/x/sys to v0.21.0 (#5481) 2024-06-04 11:59:31 -07:00
go.sum chore(deps): update module golang.org/x/sys to v0.21.0 (#5481) 2024-06-04 11:59:31 -07:00
logger_bench_test.go sdk/log: Fix BenchmarkLoggerNewRecord to not drop attributes (#5407) 2024-05-24 08:07:56 +02:00
logger_norace_test.go Replace Record limit methods with DroppedAttributes (#5190) 2024-04-16 11:48:17 -07:00
logger_test.go Replace Record limit methods with DroppedAttributes (#5190) 2024-04-16 11:48:17 -07:00
logger.go sdk/log: ObservedTimestamp should be set (#5091) 2024-03-22 07:39:01 -07:00
processor.go Add the Enabled method to the Logger (#5071) 2024-03-15 08:15:44 -07:00
provider_test.go Implement the BatchingProcessor configuration (#5088) 2024-03-25 07:50:19 -07:00
provider.go chore(deps): update dependency codespell to v2.3.0 (#5409) 2024-05-24 18:09:31 +02:00
README.md Add READMEs to every package (#5103) 2024-03-26 20:13:54 +01:00
record_test.go sdk/log: Fix counting number of dropped attributes of log.Record (#5464) 2024-06-04 09:18:14 +02:00
record.go sdk/log: Fix counting number of dropped attributes of log.Record (#5464) 2024-06-04 09:18:14 +02:00
ring_test.go Add custom ring implementation to the BatchProcessor (#5237) 2024-04-24 12:07:15 +02:00
ring.go Add custom ring implementation to the BatchProcessor (#5237) 2024-04-24 12:07:15 +02:00
setting_test.go Implement the BatchingProcessor configuration (#5088) 2024-03-25 07:50:19 -07:00
setting.go Clamp batch size <= queue size (#5157) 2024-04-05 16:02:32 -07:00
simple_test.go Implement the SimpleProcessor (#5079) 2024-03-17 07:47:05 -07:00
simple.go sdk/log: Remove slice allocation from SimpleProcessor.OnEmit (#5493) 2024-06-11 07:28:56 -07:00

Log SDK

PkgGoDev