1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-26 21:05:00 +02:00
Commit Graph

914 Commits

Author SHA1 Message Date
David Ashpole
bc2fe88756
Release v1.31.0/v0.53.0/v0.7.0/v0.0.10 (#5883)
### Added

- Add `go.opentelemetry.io/otel/sdk/metric/exemplar` package which
includes `Exemplar`, `Filter`, `TraceBasedFilter`, `AlwaysOnFilter`,
`HistogramReservoir`, `FixedSizeReservoir`, `Reservoir`, `Value` and
`ValueType` types. These will be used for configuring the exemplar
reservoir for the metrics sdk. (#5747, #5862)
- Add `WithExportBufferSize` option to log batch processor.(#5877)

### Changed

- Enable exemplars by default in `go.opentelemetry.io/otel/sdk/metric`.
Exemplars can be disabled by setting
`OTEL_METRICS_EXEMPLAR_FILTER=always_off` (#5778)
- `Logger.Enabled` in `go.opentelemetry.io/otel/log` now accepts a newly
introduced `EnabledParameters` type instead of `Record`. (#5791)
- `FilterProcessor.Enabled` in
`go.opentelemetry.io/otel/sdk/log/internal/x` now accepts
`EnabledParameters` instead of `Record`. (#5791)
- The `Record` type in `go.opentelemetry.io/otel/log` is no longer
comparable. (#5847)
- Performance improvements for the trace SDK `SetAttributes` method in
`Span`. (#5864)
- Reduce memory allocations for the `Event` and `Link` lists in `Span`.
(#5858)
- Performance improvements for the trace SDK `AddEvent`, `AddLink`,
`RecordError` and `End` methods in `Span`. (#5874)

### Deprecated

- Deprecate all examples under `go.opentelemetry.io/otel/example` as
they are moved to [Contrib
repository](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples).
(#5854)

### Fixed

- The race condition for multiple `FixedSize` exemplar reservoirs
identified in #5814 is resolved. (#5819)
- Fix log records duplication in case of heterogeneous resource
attributes by correctly mapping each log record to it's resource and
scope. (#5803)
- Fix timer channel drain to avoid hanging on Go 1.23. (#5868)
- Fix delegation for global meter providers, and panic when calling
otel.SetMeterProvider. (#5827)
- Change the `reflect.TypeOf` to use a nil pointer to not allocate on
the heap unless necessary. (#5827)
2024-10-11 12:59:27 -04:00
Murphy Chen
a7d5c1aef7
Add an option to configure the exporter buffer of the BatchProcessor (#5877)
resolve: https://github.com/open-telemetry/opentelemetry-go/issues/5238

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-10 01:16:46 -07:00
Warnar Boekkooi
64416533d5
Performance improvements for the trace SDK in Span. (#5874)
Good day,
Thanks for review this PR!
This PR follows from
https://github.com/open-telemetry/opentelemetry-go/pull/5864 and avoid
multiple locks in `End`, `RecordError`, `AddEvent` and `AddLink`.

Benchstats result are:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
           │ event-3cbd9671.txt │        event-pr-e9744b48.txt        │
           │       sec/op       │                 │
SpanEnd-12          63.07n ± 1%   53.63n ± 1%  -14.97% (p=0.000 n=10)

           │ event-3cbd9671.txt │     event-pr-e9744b48.txt      │
           │        B/op        │    B/op     vs base            │
SpanEnd-12           0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

           │ event-3cbd9671.txt │     event-pr-e9744b48.txt      │
           │     allocs/op      │ allocs/op   vs base            │
SpanEnd-12           0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

```

---------

Co-authored-by: David Ashpole <dashpole@google.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-09 09:51:17 +02:00
Warnar Boekkooi
8fbaa97084
Reduce newEvictedQueueLink and newEvictedQueueEvent memory allocations (#5858)
Good day,

While doing some profile with pprof on one of our services I notices
that `sync.OnceFunc` was allocating a nice amount of objects. These
`sync.OnceFunc` calls where done by `newEvictedQueueEvent` and
`newEvictedQueueLink`.

So to avoid these extra allocation I created this PR which replaces the
`sync.OnceFunc` with `sync.Once` which is now part of the evictedQueue.
This resulted in the following benchstat result (commit
baad07e574):
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
                                              │ 1727937489-attr-old.txt │        evic-new1728018933.txt        │
                                              │         sec/op          │    sec/op     vs base                │
RecordingSpanSetAttributes/WithLimit/false-12              6.579µ ±  9%   5.875µ ±  8%  -10.71% (p=0.000 n=10)
RecordingSpanSetAttributes/WithLimit/true-12               14.27µ ± 10%   11.82µ ± 16%  -17.18% (p=0.009 n=10)
SpanEnd-12                                                 63.44n ±  0%   75.97n ±  2%  +19.75% (p=0.000 n=10)
TraceStart/with_a_simple_span-12                           728.0n ±  3%   412.7n ±  1%  -43.31% (p=0.000 n=10)
TraceStart/with_several_links-12                           881.5n ±  1%   553.2n ±  3%  -37.25% (p=0.000 n=10)
TraceStart/with_attributes-12                              916.5n ±  2%   598.4n ±  2%  -34.70% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_10-12                 151.9n ±  3%   144.1n ±  3%   -5.13% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_100-12                1.497µ ±  2%   1.435µ ±  2%   -4.14% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_100,_spans:_10-12                148.5n ±  2%   143.0n ±  2%   -3.67% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_100,_spans:_100-12               1.481µ ±  3%   1.442µ ±  4%   -2.67% (p=0.022 n=10)
SpanProcessorVerboseLogging-12                             9.376µ ±  1%   6.662µ ±  2%  -28.94% (p=0.000 n=10)
SpanLimits/AttributeValueLengthLimit-12                    7.221µ ±  4%   6.605µ ±  3%   -8.54% (p=0.002 n=10)
SpanLimits/AttributeCountLimit-12                          6.300µ ±  6%   6.091µ ±  6%   -3.30% (p=0.007 n=10)
SpanLimits/EventCountLimit-12                              5.921µ ±  4%   5.506µ ±  7%   -7.02% (p=0.011 n=10)
SpanLimits/LinkCountLimit-12                               6.073µ ±  6%   5.423µ ±  3%  -10.71% (p=0.000 n=10)
SpanLimits/AttributePerEventCountLimit-12                  6.455µ ±  3%   5.294µ ±  9%  -17.98% (p=0.000 n=10)
SpanLimits/AttributePerLinkCountLimit-12                   6.263µ ±  4%   5.850µ ±  7%   -6.59% (p=0.000 n=10)
SpanSetAttributesOverCapacity-12                           1.683µ ±  1%   1.391µ ±  0%  -17.35% (p=0.000 n=10)
StartEndSpan/AlwaysSample-12                               803.0n ±  4%   531.4n ±  5%  -33.82% (p=0.000 n=10)
StartEndSpan/NeverSample-12                                216.0n ±  2%   212.7n ±  2%        ~ (p=0.055 n=10)
SpanWithAttributes_4/AlwaysSample-12                      1216.5n ±  2%   877.6n ±  9%  -27.85% (p=0.000 n=10)
SpanWithAttributes_4/NeverSample-12                        370.4n ±  5%   374.5n ±  3%        ~ (p=0.197 n=10)
SpanWithAttributes_8/AlwaysSample-12                       1.494µ ±  4%   1.117µ ±  4%  -25.27% (p=0.000 n=10)
SpanWithAttributes_8/NeverSample-12                        477.1n ±  3%   475.1n ±  7%        ~ (p=0.739 n=10)
SpanWithAttributes_all/AlwaysSample-12                    1310.5n ±  5%   971.5n ±  6%  -25.87% (p=0.000 n=10)
SpanWithAttributes_all/NeverSample-12                      388.0n ±  5%   389.1n ±  6%        ~ (p=0.699 n=10)
SpanWithAttributes_all_2x/AlwaysSample-12                  1.664µ ±  2%   1.236µ ±  3%  -25.72% (p=0.000 n=10)
SpanWithAttributes_all_2x/NeverSample-12                   522.7n ±  7%   527.2n ±  9%        ~ (p=0.912 n=10)
SpanWithEvents_4/AlwaysSample-12                           1.411µ ±  4%   1.058µ ±  2%  -24.99% (p=0.000 n=10)
SpanWithEvents_4/NeverSample-12                            218.4n ±  3%   218.9n ±  2%        ~ (p=0.971 n=10)
SpanWithEvents_8/AlwaysSample-12                           1.997µ ±  5%   1.657µ ±  4%  -17.03% (p=0.000 n=10)
SpanWithEvents_8/NeverSample-12                            226.6n ±  3%   221.7n ±  2%   -2.14% (p=0.015 n=10)
SpanWithEvents_WithStackTrace/AlwaysSample-12             1016.5n ±  2%   712.5n ±  2%  -29.91% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/NeverSample-12               242.0n ±  3%   241.0n ±  1%        ~ (p=0.254 n=10)
SpanWithEvents_WithTimestamp/AlwaysSample-12              1019.5n ±  3%   713.2n ±  6%  -30.04% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/NeverSample-12                276.4n ±  3%   276.6n ±  2%        ~ (p=0.723 n=10)
TraceID_DotString-12                                       71.94n ±  3%   75.71n ±  3%   +5.23% (p=0.001 n=10)
SpanID_DotString-12                                        50.88n ±  3%   52.35n ±  1%   +2.88% (p=0.001 n=10)
geomean                                                    952.8n         822.2n        -13.71%

                                              │ 1727937489-attr-old.txt │         evic-new1728018933.txt         │
                                              │          B/op           │     B/op      vs base                  │
RecordingSpanSetAttributes/WithLimit/false-12            7.062Ki ± 0%     6.891Ki ± 0%   -2.43% (p=0.000 n=10)
RecordingSpanSetAttributes/WithLimit/true-12             7.564Ki ± 0%     7.393Ki ± 0%   -2.27% (p=0.000 n=10)
SpanEnd-12                                                 0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
TraceStart/with_a_simple_span-12                           704.0 ± 0%       528.0 ± 0%  -25.00% (p=0.000 n=10)
TraceStart/with_several_links-12                           880.0 ± 0%       704.0 ± 0%  -20.00% (p=0.000 n=10)
TraceStart/with_attributes-12                              960.0 ± 0%       784.0 ± 0%  -18.33% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_10-12                 0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_10,_spans:_100-12                0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_10-12                0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_100-12               0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorVerboseLogging-12                          10.938Ki ± 0%     9.219Ki ± 0%  -15.71% (p=0.000 n=10)
SpanLimits/AttributeValueLengthLimit-12                  10.76Ki ± 0%     10.59Ki ± 0%   -1.60% (p=0.000 n=10)
SpanLimits/AttributeCountLimit-12                       10.016Ki ± 0%     9.844Ki ± 0%   -1.72% (p=0.000 n=10)
SpanLimits/EventCountLimit-12                            9.594Ki ± 0%     9.422Ki ± 0%   -1.79% (p=0.000 n=10)
SpanLimits/LinkCountLimit-12                             9.203Ki ± 0%     9.031Ki ± 0%   -1.87% (p=0.000 n=10)
SpanLimits/AttributePerEventCountLimit-12                10.64Ki ± 0%     10.47Ki ± 0%   -1.62% (p=0.000 n=10)
SpanLimits/AttributePerLinkCountLimit-12                 10.64Ki ± 0%     10.47Ki ± 0%   -1.62% (p=0.000 n=10)
SpanSetAttributesOverCapacity-12                           768.0 ± 0%       592.0 ± 0%  -22.92% (p=0.000 n=10)
StartEndSpan/AlwaysSample-12                               704.0 ± 0%       528.0 ± 0%  -25.00% (p=0.000 n=10)
StartEndSpan/NeverSample-12                                144.0 ± 0%       144.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/AlwaysSample-12                     1.188Ki ± 0%     1.016Ki ± 0%  -14.47% (p=0.000 n=10)
SpanWithAttributes_4/NeverSample-12                        400.0 ± 0%       400.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/AlwaysSample-12                     1.688Ki ± 0%     1.516Ki ± 0%  -10.19% (p=0.000 n=10)
SpanWithAttributes_8/NeverSample-12                        656.0 ± 0%       656.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/AlwaysSample-12                   1.312Ki ± 0%     1.141Ki ± 0%  -13.10% (p=0.000 n=10)
SpanWithAttributes_all/NeverSample-12                      464.0 ± 0%       464.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/AlwaysSample-12                2.062Ki ± 0%     1.891Ki ± 0%   -8.33% (p=0.000 n=10)
SpanWithAttributes_all_2x/NeverSample-12                   848.0 ± 0%       848.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_4/AlwaysSample-12                         1.188Ki ± 0%     1.016Ki ± 0%  -14.47% (p=0.000 n=10)
SpanWithEvents_4/NeverSample-12                            144.0 ± 0%       144.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_8/AlwaysSample-12                         1.812Ki ± 0%     1.641Ki ± 0%   -9.48% (p=0.000 n=10)
SpanWithEvents_8/NeverSample-12                            144.0 ± 0%       144.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/AlwaysSample-12              800.0 ± 0%       624.0 ± 0%  -22.00% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/NeverSample-12               160.0 ± 0%       160.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/AlwaysSample-12               824.0 ± 0%       648.0 ± 0%  -21.36% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/NeverSample-12                184.0 ± 0%       184.0 ± 0%        ~ (p=1.000 n=10) ¹
TraceID_DotString-12                                       64.00 ± 0%       64.00 ± 0%        ~ (p=1.000 n=10) ¹
SpanID_DotString-12                                        32.00 ± 0%       32.00 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                                               ²                  -7.15%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                              │ 1727937489-attr-old.txt │        evic-new1728018933.txt        │
                                              │        allocs/op        │ allocs/op   vs base                  │
RecordingSpanSetAttributes/WithLimit/false-12             15.000 ± 0%     3.000 ± 0%  -80.00% (p=0.000 n=10)
RecordingSpanSetAttributes/WithLimit/true-12              20.000 ± 0%     8.000 ± 0%  -60.00% (p=0.000 n=10)
SpanEnd-12                                                 0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
TraceStart/with_a_simple_span-12                          14.000 ± 0%     2.000 ± 0%  -85.71% (p=0.000 n=10)
TraceStart/with_several_links-12                          15.000 ± 0%     3.000 ± 0%  -80.00% (p=0.000 n=10)
TraceStart/with_attributes-12                             16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_10-12                 0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_10,_spans:_100-12                0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_10-12                0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_100-12               0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanProcessorVerboseLogging-12                            155.00 ± 0%     35.00 ± 0%  -77.42% (p=0.000 n=10)
SpanLimits/AttributeValueLengthLimit-12                    54.00 ± 0%     42.00 ± 0%  -22.22% (p=0.000 n=10)
SpanLimits/AttributeCountLimit-12                          50.00 ± 0%     38.00 ± 0%  -24.00% (p=0.000 n=10)
SpanLimits/EventCountLimit-12                              47.00 ± 0%     35.00 ± 0%  -25.53% (p=0.000 n=10)
SpanLimits/LinkCountLimit-12                               47.00 ± 0%     35.00 ± 0%  -25.53% (p=0.000 n=10)
SpanLimits/AttributePerEventCountLimit-12                  50.00 ± 0%     38.00 ± 0%  -24.00% (p=0.000 n=10)
SpanLimits/AttributePerLinkCountLimit-12                   50.00 ± 0%     38.00 ± 0%  -24.00% (p=0.000 n=10)
SpanSetAttributesOverCapacity-12                          15.000 ± 0%     3.000 ± 0%  -80.00% (p=0.000 n=10)
StartEndSpan/AlwaysSample-12                              14.000 ± 0%     2.000 ± 0%  -85.71% (p=0.000 n=10)
StartEndSpan/NeverSample-12                                2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/AlwaysSample-12                      16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_4/NeverSample-12                        3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/AlwaysSample-12                      16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_8/NeverSample-12                        3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/AlwaysSample-12                    16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_all/NeverSample-12                      3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/AlwaysSample-12                 16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_all_2x/NeverSample-12                   3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_4/AlwaysSample-12                          17.000 ± 0%     5.000 ± 0%  -70.59% (p=0.000 n=10)
SpanWithEvents_4/NeverSample-12                            2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_8/AlwaysSample-12                          18.000 ± 0%     6.000 ± 0%  -66.67% (p=0.000 n=10)
SpanWithEvents_8/NeverSample-12                            2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/AlwaysSample-12             16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/NeverSample-12               3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/AlwaysSample-12              17.000 ± 0%     5.000 ± 0%  -70.59% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/NeverSample-12                4.000 ± 0%     4.000 ± 0%        ~ (p=1.000 n=10) ¹
TraceID_DotString-12                                       2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanID_DotString-12                                        2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                                               ²               -47.73%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-10-08 09:43:14 +02:00
Warnar Boekkooi
3cbd967152
Performance improvements for recordingSpan SetAttributes and addOverCapAttrs (#5864)
Good day,

While working on
https://github.com/open-telemetry/opentelemetry-go/pull/5858 I found
some other possible improvements.

This PR:
- Adds an early return to `SetAttributes` when no attributes are
provided.
- Only increases `s.attributes` to guarantee that there is enough space
for elements to be added.
- Fixes and issue where `truncateAttr` was not used when a attribute was
being updated in `addOverCapAttrs`.

Thanks for reviewing and please let me know if any changes are needed.

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-07 09:30:29 +02:00
Jesse Bank
1333b2f73a
Fix delegation for global MeterProviders (#5828)
Fixes #5827
Fixes #5852

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: David Ashpole <dashpole@google.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-04 10:19:41 +02:00
Danny Shemesh
19877b1654
Fix timer channel drain to avoid hanging in Go 1.23 (#5869)
- Fix timer channel drain to avoid hanging in go1.23 w/ asynctimerchan=0
(https://github.com/open-telemetry/opentelemetry-go/issues/5868)

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-04 09:48:57 +02:00
David Ashpole
be328ac923
Rename SampledFilter to TraceBasedFilter (#5862)
The specification calls this filter "TraceBased":
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#tracebased

I don't have a huge preference between the two, but lean towards
TraceBasedFilter to match the specification, and to match our
environment variable configuration (and probably the future file
configuration).

This PR must be merged or closed prior to the v1.31 release, since we
can't change it after the release.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-10-02 12:54:01 -04:00
Robert Pająk
d7e7da66a9
Deprecate examples and redirect to contrib (#5854)
Towards #5801
2024-10-01 12:59:11 +02:00
David Ashpole
481f4983f7
Move exemplar types to non-internal package (#5747)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/5249

This makes all existing types designed to implement the public Exemplar
API public by moving most of `internal/exemplar` to `exemplar`. The only
types that are not being made public are `exemplar.Drop`, and
`exemplar.FilteredReservoir`. Those types are moved to
`internal/aggregate`, and are renamed to `DropReservoir` and
`FilteredExemplarReservoir`.

The following types are made public:

* `exemplar.Exemplar`
* `exemplar.Filter`
* `exemplar.SampledFilter`
* `exemplar.AlwaysOnFilter`
* `exemplar.HistogramReservoir`
* `exemplar.FixedSizeReservoir`
* `exemplar.Reservoir`
* `exemplar.Value`
* `exemplar.ValueType`
2024-09-26 13:25:05 -07:00
Robert Pająk
f710cecfc5
log: Make Record not comparable (#5847)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5696
2024-09-26 08:32:36 +02:00
pree-dew
534ce5ab09
Fix duplicate logs across resources (#5803)
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>
2024-09-17 13:12:49 +02:00
Tyler Yahn
42fd8fe325
Move global random number generator to randRes field (#5819)
Instead of using a global random number generator for all `randRes`,
have each value use its own. This removes the need for locking and
managing concurrent safe access to the global. Also, the field, given
the `Reservoir` type is not concurrent safe and the metric pipeline
guards this, does not need a `sync.Mutex` to guard it.

Supersedes https://github.com/open-telemetry/opentelemetry-go/pull/5815 
Fix #5814

### Performance Analysis

This change has approximately equivalent performance as the existing
code based on existing benchmarks.

```terminal
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                           │   old.txt   │              new.txt               │
                           │   sec/op    │   sec/op     vs base               │
Exemplars/Int64Counter/8-8   14.00µ ± 3%   13.44µ ± 4%  -3.98% (p=0.001 n=10)

                           │   old.txt    │             new.txt              │
                           │     B/op     │     B/op      vs base            │
Exemplars/Int64Counter/8-8   3.791Ki ± 0%   3.791Ki ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                           │  old.txt   │            new.txt             │
                           │ allocs/op  │ allocs/op   vs base            │
Exemplars/Int64Counter/8-8   84.00 ± 0%   84.00 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal
```
2024-09-16 07:31:15 -07:00
Robert Pająk
23f7b41e0a
log: Introduce EnabledParameters (#5791)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5769

Related spec PR:
https://github.com/open-telemetry/opentelemetry-specification/pull/4203

Remark: A follow-up in contrib is required and afterwards here to fix
the `example/dice`.

Benchstat results for `sdk/log` (`log` has no benchmarks related to
Enabled):

```
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                │
BatchProcessorOnEmit-16              398.8n ± 10%   395.6n ± 12%        ~ (p=0.971 n=10)
Processor/Simple-16                  882.2n ±  8%   869.8n ±  9%        ~ (p=0.811 n=10)
Processor/Batch-16                   1.478µ ±  3%   1.485µ ±  5%        ~ (p=0.646 n=10)
Processor/SetTimestampSimple-16      847.8n ±  1%   844.6n ±  3%        ~ (p=0.247 n=10)
Processor/SetTimestampBatch-16       1.480µ ±  3%   1.473µ ±  4%        ~ (p=0.700 n=10)
Processor/AddAttributesSimple-16     930.0n ±  1%   933.8n ±  1%        ~ (p=0.172 n=10)
Processor/AddAttributesBatch-16      1.624µ ±  2%   1.639µ ±  2%        ~ (p=0.839 n=10)
Processor/SetAttributesSimple-16     903.4n ±  1%   895.1n ±  1%        ~ (p=0.190 n=10)
Processor/SetAttributesBatch-16      1.554µ ±  4%   1.529µ ±  3%        ~ (p=0.159 n=10)
LoggerNewRecord/5_attributes-16      346.0n ±  2%   343.3n ±  2%        ~ (p=0.448 n=10)
LoggerNewRecord/10_attributes-16     1.608µ ±  6%   1.503µ ±  2%   -6.53% (p=0.007 n=10)
LoggerEnabled-16                    34.305n ±  8%   6.706n ±  1%  -80.45% (p=0.000 n=10)
LoggerProviderLogger-16              636.9n ± 10%   605.8n ±  3%        ~ (p=0.105 n=10)
WalkAttributes/1_attributes-16       5.363n ±  3%   4.540n ± 14%  -15.34% (p=0.002 n=10)
WalkAttributes/10_attributes-16      5.436n ±  7%   4.461n ±  2%  -17.95% (p=0.000 n=10)
WalkAttributes/100_attributes-16     5.126n ±  9%   4.465n ±  1%  -12.90% (p=0.000 n=10)
WalkAttributes/1000_attributes-16    5.316n ±  9%   4.502n ±  5%  -15.32% (p=0.002 n=10)
SetAddAttributes/SetAttributes-16    220.5n ± 18%   192.6n ± 11%  -12.67% (p=0.007 n=10)
SetAddAttributes/AddAttributes-16    165.3n ± 21%   127.3n ± 22%  -22.96% (p=0.011 n=10)
SimpleProcessorOnEmit-16             2.159n ±  9%   2.167n ±  9%        ~ (p=0.739 n=10)
geomean                              178.3n         154.5n        -13.31%

                        │    old.txt    │             new.txt             │
                        │      B/s      │      B/s       vs base          │
BatchProcessorOnEmit-16   76.52Mi ± 11%   77.14Mi ± 14%  ~ (p=0.971 n=10)

                                  │    old.txt     │                new.txt                │
                                  │      B/op      │     B/op      vs base                 │
BatchProcessorOnEmit-16               0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/Simple-16                   417.0 ± 0%       417.0 ± 0%       ~ (p=1.000 n=10) ¹
Processor/Batch-16                  1.093Ki ± 1%     1.088Ki ± 1%       ~ (p=0.254 n=10)
Processor/SetTimestampSimple-16       417.0 ± 0%       417.0 ± 0%       ~ (p=1.000 n=10) ¹
Processor/SetTimestampBatch-16      1.095Ki ± 1%     1.084Ki ± 2%       ~ (p=0.361 n=10)
Processor/AddAttributesSimple-16      417.0 ± 0%       417.0 ± 0%       ~ (p=1.000 n=10) ¹
Processor/AddAttributesBatch-16     1.085Ki ± 1%     1.086Ki ± 1%       ~ (p=1.000 n=10)
Processor/SetAttributesSimple-16      465.0 ± 0%       465.0 ± 0%       ~ (p=1.000 n=10) ¹
Processor/SetAttributesBatch-16     1.129Ki ± 1%     1.125Ki ± 1%       ~ (p=0.084 n=10)
LoggerNewRecord/5_attributes-16       0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
LoggerNewRecord/10_attributes-16      610.0 ± 0%       610.0 ± 0%       ~ (p=1.000 n=10) ¹
LoggerEnabled-16                      0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
LoggerProviderLogger-16               359.0 ± 6%       346.0 ± 3%       ~ (p=0.117 n=10)
WalkAttributes/1_attributes-16        0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
WalkAttributes/10_attributes-16       0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
WalkAttributes/100_attributes-16      0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
WalkAttributes/1000_attributes-16     0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
SetAddAttributes/SetAttributes-16     48.00 ± 0%       48.00 ± 0%       ~ (p=1.000 n=10) ¹
SetAddAttributes/AddAttributes-16     0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
SimpleProcessorOnEmit-16              0.000 ± 0%       0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                          ²                 -0.27%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                  │   old.txt    │               new.txt               │
                                  │  allocs/op   │ allocs/op   vs base                 │
BatchProcessorOnEmit-16             0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/Simple-16                 1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/Batch-16                  1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/SetTimestampSimple-16     1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/SetTimestampBatch-16      1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/AddAttributesSimple-16    1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/AddAttributesBatch-16     1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/SetAttributesSimple-16    2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=10) ¹
Processor/SetAttributesBatch-16     2.000 ± 0%     2.000 ± 0%       ~ (p=1.000 n=10) ¹
LoggerNewRecord/5_attributes-16     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
LoggerNewRecord/10_attributes-16    4.000 ± 0%     4.000 ± 0%       ~ (p=1.000 n=10) ¹
LoggerEnabled-16                    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
LoggerProviderLogger-16             1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
WalkAttributes/1_attributes-16      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
WalkAttributes/10_attributes-16     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
WalkAttributes/100_attributes-16    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
WalkAttributes/1000_attributes-16   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
SetAddAttributes/SetAttributes-16   1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
SetAddAttributes/AddAttributes-16   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
SimpleProcessorOnEmit-16            0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                        ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```
2024-09-13 06:35:01 +02:00
David Ashpole
6e2f72f698
Enable exemplars by default (#5778)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/5249.

Addresses
https://github.com/open-telemetry/opentelemetry-go/issues/5249#issuecomment-2088725450

This removes handling of the `OTEL_GO_X_EXEMPLAR` environment variable.

Instead of changing the default for the existing environment variable to
enable it by default, i'm just removing it entirely. Users can still
disable the feature by setting the filter to always_off. Since we will
continue to support that configuration, it seems better to direct users
there, rather than give them a temporary equivalent.
2024-09-11 15:07:14 -04:00
Sam Xie
ed4fc75758
Release v1.30.0/v0.52.0/v0.6.0/v0.0.9 (#5797)
### Added

- Support `OTEL_EXPORTER_OTLP_LOGS_INSECURE` and
`OTEL_EXPORTER_OTLP_INSECURE` environments in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. (#5739)
- The `WithResource` option for `NewMeterProvider` now merges the
provided resources with the ones from environment variables. (#5773)
- The `WithResource` option for `NewLoggerProvider` now merges the
provided resources with the ones from environment variables. (#5773)
- Add UTF-8 support to `go.opentelemetry.io/otel/exporters/prometheus`.
(#5755)
### Fixed

- Fix memory leak in the global `MeterProvider` when identical
instruments are repeatedly created. (#5754)
- Fix panic instruments creation when setting meter provider. (#5758)
- Fix panic on instruments creation when setting meter provider. (#5758)
- Fix an issue where `SetMeterProvider` in `go.opentelemetry.io/otel`
might miss the delegation for instruments and registries. (#5780)

### Removed

- Drop support for [Go 1.21](https://go.dev/doc/go1.21). (#5736, #5740,
#5800)
2024-09-10 14:10:56 -07:00
Tyler Yahn
cdd2dbb474
Drop support for Go 1.21 in dice example (#5800)
Resolves #5359
2024-09-10 11:04:33 -07:00
David Ashpole
71b341f0a0
Add utf8 support to the prometheus exporter (#5755)
### Changes

Disable sanitization when the UTF-8 support is enabled in the Prometheus
library.

### Usage

To enable UTF-8 support for the Prometheus exporter after this change,
set the following in your application:

```golang
import "github.com/prometheus/common/model"

func init() {
    model.NameValidationScheme = model.UTF8Validation
}
```

See `exporters/prometheus/testdata/counter_utf8.txt` for an example of
the text exposition format including names/labels with dots.
2024-09-09 11:08:14 -04:00
Nathan Baulch
506a9baf5e
Fix typos (#5763) 2024-09-09 08:53:15 +02:00
Sam Xie
b37e8a9860
SetMeterProvider might miss the delegation for instruments and registries (#5780)
Closes #5757

This PR fixes an issue where `SetMeterProvider` might miss the
delegation for instruments and registries. This bug brings a concurrent
issue that could possibly make instruments and registries unable to
operate correctly, such as recording, after using the `SetMeterProvider`
method. The data put on these instruments and registries might be lost.
2024-09-06 16:42:55 -07:00
Bastian Krol
9e1b015159
fix(metric, log): merge explicit resource with environment variables (#5773)
fixes #5764

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-09-06 19:19:44 +02:00
Anton Manakin
8dca9cc0fa
Support OTEL_EXPORTER_OTLP_LOGS_INSECURE and OTEL_EXPORTER_OTLP_INSECURE environments in grpc exporter (#5739)
Closes https://github.com/open-telemetry/opentelemetry-go/issues/5719

In this commit I add OTEL_EXPORTER_OTLP_LOGS_INSECURE and
OTEL_EXPORTER_OTLP_INSECURE env options to `otlploggrpc.Exporter`.

Now insecure option is fetched from env endpoint value
(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT/OTEL_EXPORTER_OTLP_ENDPOINT).
According to
[spec](https://opentelemetry.io/docs/specs/otel/protocol/exporter/):
> Insecure: Whether to enable client transport security for the
exporter’s gRPC connection. This option only applies to OTLP/gRPC when
an endpoint is provided without the http or https scheme - OTLP/HTTP
always uses the scheme provided for the endpoint.

So with current behavior we have several problems:
- If default endpoint is used, we can't use insecure connection (with
setting OTEL_EXPORTER_OTLP_INSECURE).
- If endpoint provided with option without scheme (e.g. `WithEndpoint`)
we can't use insecure connection with env settings.
- If endpoint provided with env variable without scheme (e.g.
`//env.endpoint:8080/`) we can't use insecure connection.

This commit fixes this.

The same problem with `otlploghttp.Exporter`, and probably it should be
fixed there too.
I'm open to suggestions on how to fix the current behavior in a more
elegant way.

---------

Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-09-06 15:48:45 +02:00
Sam Xie
932a4d8a5f
Fix panic instruments creation when setting meter provider (#5758)
Related #5757. This is a quick fix.
2024-09-01 11:02:31 -07:00
David Ashpole
e47618fc36
Fix duplicate instrumentation memory leak (#5754)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5753

The added test fails on main, but passes after the fix.

---------

Co-authored-by: Sam Xie <sam@samxie.me>
2024-08-29 10:30:20 -07:00
Sam Xie
172cfb7208
Replace go 1.21 with go 1.22 in go mod (#5740)
Related #5736
2024-08-26 18:50:33 -07:00
Tyler Yahn
023025f17d
Drop support for Go 1.21 (#5736)
Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2024-08-25 07:22:05 -07:00
Tyler Yahn
6b1d94f21c
Release v1.29.0/v0.51.0/v0.5.0 (#5732)
This release is the last to support [Go 1.21]. The next release will
require at least [Go 1.22].

### Added

- Add MacOS ARM64 platform to the compatibility testing suite. (#5577)
- Add `InstrumentationScope` field to `SpanStub` in
`go.opentelemetry.io/otel/sdk/trace/tracetest`, as a replacement for the
deprecated `InstrumentationLibrary`. (#5627)
- Make the initial release of
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. This new
module contains an OTLP exporter that transmits log telemetry using
gRPC. This module is unstable and breaking changes may be introduced.
See our [versioning policy](VERSIONING.md) for more information about
these stability guarantees. (#5629)
- Add `Walk` function to `TraceState` in
`go.opentelemetry.io/otel/trace` to iterate all the key-value pairs.
(#5651)
- Bridge the trace state in
`go.opentelemetry.io/otel/bridge/opencensus`. (#5651)
- Zero value of `SimpleProcessor` in `go.opentelemetry.io/otel/sdk/log`
no longer panics. (#5665)
- The `FilterProcessor` interface type is added in
`go.opentelemetry.io/otel/sdk/log/internal/x`. This is an optional and
experimental interface that log `Processor`s can implement to instruct
the `Logger` if a `Record` will be processed or not. It replaces the
existing `Enabled` method that is removed from the `Processor` interface
itself. It does not fall within the scope of the OpenTelemetry Go
versioning and stability [policy](./VERSIONING.md) and it may be changed
in backwards incompatible ways or removed in feature releases. (#5692)
- Support [Go 1.23]. (#5720)

### Changed

- `NewMemberRaw`, `NewKeyProperty` and `NewKeyValuePropertyRaw` in
`go.opentelemetry.io/otel/baggage` allow UTF-8 string in key. (#5132)
- `Processor.OnEmit` in `go.opentelemetry.io/otel/sdk/log` now accepts a
pointer to `Record` instead of a value so that the record modifications
done in a processor are propagated to subsequent registered processors.
(#5636)
- `SimpleProcessor.Enabled` in `go.opentelemetry.io/otel/sdk/log` now
returns `false` if the exporter is `nil`. (#5665)
- Update the concurrency requirements of `Exporter` in
`go.opentelemetry.io/otel/sdk/log`. (#5666)
- `SimpleProcessor` in `go.opentelemetry.io/otel/sdk/log` synchronizes
`OnEmit` calls. (#5666)
- The `Processor` interface in `go.opentelemetry.io/otel/sdk/log` no
longer includes the `Enabled` method. See the `FilterProcessor`
interface type added in `go.opentelemetry.io/otel/sdk/log/internal/x` to
continue providing this functionality. (#5692)
- The `SimpleProcessor` type in `go.opentelemetry.io/otel/sdk/log` is no
longer comparable. (#5693)
- The `BatchProcessor` type in `go.opentelemetry.io/otel/sdk/log` is no
longer comparable. (#5693)

### Fixed

- Correct comments for the priority of the `WithEndpoint` and
`WithEndpointURL` options and their corresponding environment variables
in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#5584)
- Pass the underlying error rather than a generic retry-able failure in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` and
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#5541)
- Correct the `Tracer`, `Meter`, and `Logger` names used in
`go.opentelemetry.io/otel/example/dice`. (#5612)
- Correct the `Tracer` names used in
`go.opentelemetry.io/otel/example/namedtracer`. (#5612)
- Correct the `Tracer` name used in
`go.opentelemetry.io/otel/example/opencensus`. (#5612)
- Correct the `Tracer` and `Meter` names used in
`go.opentelemetry.io/otel/example/otel-collector`. (#5612)
- Correct the `Tracer` names used in
`go.opentelemetry.io/otel/example/passthrough`. (#5612)
- Correct the `Meter` name used in
`go.opentelemetry.io/otel/example/prometheus`. (#5612)
- Correct the `Tracer` names used in
`go.opentelemetry.io/otel/example/zipkin`. (#5612)
- Correct comments for the priority of the `WithEndpoint` and
`WithEndpointURL` options and their corresponding environment variables
in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`
and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#5641)
- Correct comments for the priority of the `WithEndpoint` and
`WithEndpointURL` options and their corresponding environment variables
in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`.
(#5650)
- Stop percent encoding header environment variables in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`,
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`
(#5705)
- Remove invalid environment variable header keys in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`,
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`
(#5705)

### Removed

- The `Enabled` method of the `SimpleProcessor` in
`go.opentelemetry.io/otel/sdk/log` is removed. (#5692)
- The `Enabled` method of the `BatchProcessor` in
`go.opentelemetry.io/otel/sdk/log` is removed. (#5692)

[Go 1.23]: https://go.dev/doc/go1.23
[Go 1.22]: https://go.dev/doc/go1.22
[Go 1.21]: https://go.dev/doc/go1.21
2024-08-23 13:13:40 -07:00
Tyler Yahn
002c0a4c03
Move log.Processor.Enabled to independent FilterProcessor interfaced type (#5692)
Closes #5425 

Our current log `Processor` interface contains more functionality than
the [OTel
spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#logrecordprocessor-operations).
The additional functionality allows processors to report back to the API
if a Record should be constructed and emitted or not, which is quite
helpful[^1][^2][^3][^4][^5].

This removes the `Enabled` method from the `Processor` type. It adds
this functionality a new optional and experimental `FilterProcessor`
interface type. The logger and provider are updated to check for this
optional interface to be implemented with the configured processors and
uses them to back the `Logger.Enabled` method, preserving existing
functionality.

By making this change:

- The `Processor` interface is now compliant with the OTel spec and does
not contain any additional unspecified behavior.
- All `Processor` implementations are no longer required to implement an
`Enabled` method. The default, when they do not implement this method,
is to assume they are enabled.

### Benchmark

```terminal
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/log
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                │   old.txt    │              new7.txt               │
                │    sec/op    │   sec/op     vs base                │
LoggerEnabled-8   133.30n ± 3%   32.36n ± 3%  -75.72% (p=0.000 n=10)

                │  old.txt   │            new7.txt            │
                │    B/op    │    B/op     vs base            │
LoggerEnabled-8   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                │  old.txt   │            new7.txt            │
                │ allocs/op  │ allocs/op   vs base            │
LoggerEnabled-8   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal
```

This is a significant performance improvement due to the `Record` no
longer being converted from the API version to the SDK version.

[^1]: https://pkg.go.dev/go.opentelemetry.io/contrib/processors/minsev
[^2]:
https://pkg.go.dev/go.opentelemetry.io/otel/sdk/log#BatchProcessor.Enabled
[^3]:
https://pkg.go.dev/go.opentelemetry.io/otel/sdk/log#SimpleProcessor.Enabled
[^4]:
af75717ac4/bridges/otelslog/handler.go (L206-L211)
[^5]:
d0309ddd8c/bridges/otelzap/core.go (L142-L146)

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Sam Xie <sam@samxie.me>
2024-08-22 09:12:23 -07:00
jianwu
fe6c67e7e9
OpenCensus bridge to support TraceState (#5651)
# Summary 
This is to fix issue: #5642 
The original logic skips copying TraceState when convert Spans between
OTel and OC.

This PR also updated the OTel TraceState to expose the Keys function for
the propagation purpose.

---------

Co-authored-by: Sam Xie <sam@samxie.me>
2024-08-21 17:33:56 +02:00
Zhihan Li
83ae9bd0e3
Bugfix: OTLP exporters should not percent decode the key when parsing HEADERS env vars (#5705)
Bugfix #5623

As stated in the issue, we need to avoid parsing the key and instead
implement a validation check for it. I've added some unit tests to
verify this fix.

However, I noticed a comment at the top of this file:
```
// Code created by gotmpl. DO NOT MODIFY.
// source: internal/shared/otlp/envconfig/envconfig.go.tmpl
```
It seems that `internal/shared/otlp/envconfig/envconfig.go.tmpl` is the
source template for this file. Since this template matches
`exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig/envconfig.go`,
I updated the template to maintain consistency. I’m not entirely sure if
this approach is correct, so please confirm if this is the right course
of action.

---------

Co-authored-by: Fools <54661071+Charlie-lizhihan@users.noreply.github.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-08-21 07:53:24 -07:00
Damien Mathieu
083d03e605
Add support for go 1.23 (#5720)
Go 1.23 was released a few days ago.
https://go.dev/blog/go1.23

This also upgrades golangci-lint (and fixes new issues), since it
appears 1.59 doesn't work nicely with Go 1.23.

---------

Co-authored-by: Sam Xie <sam@samxie.me>
2024-08-21 09:37:56 +02:00
Sam Xie
d61bbf18f5
baggage: Accept non-ASCII keys (#5132)
resolves #4946

I also add additional test cases to cover more lines.

benchmark results:

```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/baggage
                                 │   old.txt   │               new.txt               │
                                 │   sec/op    │   sec/op     vs base                │
New-10                             402.3n ± 1%   422.4n ± 6%   +4.98% (p=0.000 n=10)
NewMemberRaw-10                    10.82n ± 0%   13.90n ± 1%  +28.51% (p=0.000 n=10)
Parse-10                           803.8n ± 1%   795.0n ± 1%   -1.09% (p=0.011 n=10)
String-10                          682.6n ± 0%   610.0n ± 2%  -10.63% (p=0.000 n=10)
ValueEscape/nothing_to_escape-10   4.856n ± 0%   4.849n ± 0%        ~ (p=0.279 n=10)
ValueEscape/requires_escaping-10   22.47n ± 1%   22.36n ± 1%        ~ (p=0.342 n=10)
ValueEscape/long_value-10          513.3n ± 1%   510.1n ± 0%   -0.62% (p=0.006 n=10)
MemberString-10                    430.8n ± 2%   471.3n ± 2%   +9.41% (p=0.000 n=10)
geomean                            124.5n        128.5n        +3.22%

                                 │   old.txt    │               new.txt                │
                                 │     B/op     │    B/op     vs base                  │
New-10                             704.0 ± 0%     704.0 ± 0%        ~ (p=1.000 n=10) ¹
NewMemberRaw-10                    0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
Parse-10                           888.0 ± 0%     888.0 ± 0%        ~ (p=1.000 n=10) ¹
String-10                          936.0 ± 0%     840.0 ± 0%  -10.26% (p=0.000 n=10)
ValueEscape/nothing_to_escape-10   0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
ValueEscape/requires_escaping-10   16.00 ± 0%     16.00 ± 0%        ~ (p=1.000 n=10) ¹
ValueEscape/long_value-10          576.0 ± 0%     576.0 ± 0%        ~ (p=1.000 n=10) ¹
MemberString-10                    656.0 ± 0%     656.0 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                       ²                -1.34%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                 │    old.txt    │               new.txt                │
                                 │   allocs/op   │ allocs/op   vs base                  │
New-10                              8.000 ± 0%     8.000 ± 0%        ~ (p=1.000 n=10) ¹
NewMemberRaw-10                     0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
Parse-10                            9.000 ± 0%     9.000 ± 0%        ~ (p=1.000 n=10) ¹
String-10                          10.000 ± 0%     8.000 ± 0%  -20.00% (p=0.000 n=10)
ValueEscape/nothing_to_escape-10    0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
ValueEscape/requires_escaping-10    1.000 ± 0%     1.000 ± 0%        ~ (p=1.000 n=10) ¹
ValueEscape/long_value-10           2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
MemberString-10                     4.000 ± 0%     4.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                        ²                -2.75%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

FYI, the old implementation of `NewMemberRaw` didn't verify the value,
so the benchmark result of `NewMemberRaw` is not an apple-to-apple
comparison of `utf8.ValidString` and `validateKey`.

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-08-15 16:50:34 -07:00
Tyler Yahn
c4ebcaa08d
Ensure exported struct in sdk/log are not comparable (#5693)
Ensure the `Record` and `Provider` continue to be non-comparable.

Restrict `BatchProcessor` and `SimpleProcessor` to be non-comparable.

There is no obvious reason an end-user will need to compare these types,
and we want to keep the possibility of changing the internals without
changing this behavior.

if comparability is required by end-users in the future we can add
`Equal(other T)` methods in the future.
2024-08-09 07:31:42 -07:00
Robert Pająk
69e235829e
sdk/log: SimpleProcessor synchronizes OnEmit calls (#5666)
From
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#export:

> `Export` will never be called concurrently for the same exporter
instance.

From our SDK perspective this change will make
https://pkg.go.dev/go.opentelemetry.io/otel/exporters/stdout/stdoutlog
concurrent-safe when used with the simple processor. Before the change,
there can be multiple goroutines calling `Write` in parallel (via
`json.Encoder.Encode`).

### Remarks

[Maybe we should simply state that "whole" exporter implementation does
not need to be
concurrent-safe?](https://github.com/open-telemetry/opentelemetry-specification/pull/4173#discussion_r1699958752)
However:
1. we would need to make complex changes in `BatchExporter` to
synchronize the `Export`, `Shutdown`, `ForceFlush` calls
2. we would need to update all exporters (remove synchronization) and
simple exporter (add locks to `Shutdown`, `ForceFlush`)
3. I am 100% not sure if this would be compliant with the specification
- I think it would be complaint because we would simply give stronger
safety-measures


We should probably discuss it separately, but I wanted to highlight my
though process.
Even if we decide that simple and batch processors to synchronize all
calls then I would prefer to address it in a separate PR.

Related spec clarification PR:
-
https://github.com/open-telemetry/opentelemetry-specification/pull/4173
2024-08-09 08:40:39 +02:00
Robert Pająk
f079b03364
sdk/log: SimpleProcessor to not panic for zero value (#5665) 2024-08-04 12:35:58 +02:00
Sam Xie
9e5b316e3c
Correct the comment for the priority of options and environments on otlploghttp (#5650)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/5379
2024-08-01 13:33:16 -07:00
Robert Pająk
8e8ad092cc
sdk/log: Processor.OnEmit accetps a Record pointer (#5636)
## What

Change `Processor.OnEmit` methods to accept a record pointer.

## Why

Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5219

This would be specification compliant according to discussions around
https://github.com/open-telemetry/opentelemetry-specification/pull/4067

This is inline of how processors Go span processors works and how log
processors work in other languages.

If the performance (an additional heap allocation during log processing)
would occur to be a significant problem for some users, we have at few
possible solutions:

1. Utilize PGO which may also lead to decreasing heap allocations
(sources:
https://landontclipp.github.io/blog/2023/08/25/profile-guided-optimizations-in-go/#devirtualization,
https://andrewwphillips.github.io/blog/pgo.html). Currently it does not
but I expect it may change in future.
2. Improve the Go compilers escape analysis (related to previous point)
3. introduce new "chaining processor" which can be also desirable in
other languages

## Benchstat

`old` is from `main`.
`new` is from current branch.

`new-pgo` is from current branch with PGO optimization. I first run
benchmarks to generate a CPU profile using `go test -run=^$ -bench=.
-count=10 -cpuprofile default.pgo` and then I rerun the tests with PGO.
Currently, the number of heap allocations is the same.

```
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                │              new-pgo.txt              │
                                  │    sec/op     │    sec/op     vs base                 │    sec/op     vs base                 │
BatchProcessorOnEmit-16              402.7n ± 18%   382.0n ±  7%         ~ (p=0.247 n=10)   376.7n ± 14%         ~ (p=0.210 n=10)
Processor/Simple-16                  350.9n ±  9%   782.5n ±  6%  +123.00% (p=0.000 n=10)   755.1n ±  5%  +115.19% (p=0.000 n=10)
Processor/Batch-16                   1.333µ ± 15%   1.497µ ± 11%   +12.27% (p=0.000 n=10)   1.528µ ±  8%   +14.63% (p=0.000 n=10)
Processor/SetTimestampSimple-16      329.5n ± 15%   711.6n ±  4%  +115.93% (p=0.000 n=10)   721.9n ±  5%  +119.04% (p=0.000 n=10)
Processor/SetTimestampBatch-16       1.163µ ±  2%   1.524µ ±  3%   +31.03% (p=0.000 n=10)   1.461µ ±  5%   +25.57% (p=0.000 n=10)
Processor/AddAttributesSimple-16     408.7n ±  3%   810.1n ±  4%   +98.21% (p=0.000 n=10)   830.1n ±  4%  +103.11% (p=0.000 n=10)
Processor/AddAttributesBatch-16      1.270µ ±  2%   1.623µ ±  4%   +27.71% (p=0.000 n=10)   1.597µ ±  7%   +25.66% (p=0.000 n=10)
Processor/SetAttributesSimple-16     436.2n ± 10%   796.1n ±  3%   +82.50% (p=0.000 n=10)   817.6n ±  4%   +87.43% (p=0.000 n=10)
Processor/SetAttributesBatch-16      1.202µ ±  2%   1.552µ ±  2%   +29.06% (p=0.000 n=10)   1.659µ ± 11%   +37.96% (p=0.000 n=10)
LoggerNewRecord/5_attributes-16      366.6n ±  3%   363.7n ±  7%         ~ (p=0.952 n=10)   426.2n ±  7%   +16.27% (p=0.000 n=10)
LoggerNewRecord/10_attributes-16     1.711µ ±  2%   1.909µ ± 18%   +11.57% (p=0.000 n=10)   2.077µ ± 10%   +21.39% (p=0.000 n=10)
LoggerProviderLogger-16              650.1n ±  4%   690.1n ±  8%    +6.15% (p=0.019 n=10)   737.6n ± 13%   +13.47% (p=0.004 n=10)
WalkAttributes/1_attributes-16       5.264n ± 12%   5.510n ±  8%         ~ (p=0.812 n=10)   5.865n ±  5%   +11.41% (p=0.011 n=10)
WalkAttributes/10_attributes-16      5.440n ±  8%   5.881n ±  7%    +8.12% (p=0.004 n=10)   6.104n ±  7%   +12.21% (p=0.005 n=10)
WalkAttributes/100_attributes-16     5.403n ±  9%   5.894n ±  9%    +9.10% (p=0.029 n=10)   5.783n ±  6%         ~ (p=0.052 n=10)
WalkAttributes/1000_attributes-16    5.196n ±  4%   5.860n ±  8%   +12.79% (p=0.000 n=10)   5.981n ± 13%   +15.13% (p=0.002 n=10)
SetAddAttributes/SetAttributes-16    181.2n ± 14%   208.1n ± 12%   +14.85% (p=0.005 n=10)   209.9n ± 11%   +15.87% (p=0.007 n=10)
SetAddAttributes/AddAttributes-16    156.7n ± 14%   161.1n ± 16%         ~ (p=0.190 n=10)   165.5n ± 15%         ~ (p=0.315 n=10)
SimpleProcessorOnEmit-16            11.775n ± 10%   9.027n ± 17%   -23.33% (p=0.000 n=10)   9.389n ± 18%   -20.26% (p=0.002 n=10)
geomean                              169.1n         209.6n         +23.98%                  215.5n         +27.48%

                        │     old.txt     │               new.txt                │              new-pgo.txt              │
                        │       B/s       │     B/s       vs base                │      B/s       vs base                │
BatchProcessorOnEmit-16   1004.39Mi ± 15%   79.88Mi ± 7%  -92.05% (p=0.000 n=10)   81.06Mi ± 12%  -91.93% (p=0.000 n=10)

                                  │   old.txt    │                new.txt                 │               new-pgo.txt               │
                                  │     B/op     │    B/op      vs base                   │     B/op      vs base                   │
BatchProcessorOnEmit-16             0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
Processor/Simple-16                   0.0 ± 0%      417.0 ± 0%         ? (p=0.000 n=10)      417.0 ±  0%         ? (p=0.000 n=10)
Processor/Batch-16                  621.5 ± 2%     1057.5 ± 1%   +70.15% (p=0.000 n=10)     1064.5 ±  1%   +71.28% (p=0.000 n=10)
Processor/SetTimestampSimple-16       0.0 ± 0%      417.0 ± 0%         ? (p=0.000 n=10)      418.0 ±  0%         ? (p=0.000 n=10)
Processor/SetTimestampBatch-16      626.5 ± 3%     1049.5 ± 1%   +67.52% (p=0.000 n=10)     1057.5 ±  2%   +68.79% (p=0.000 n=10)
Processor/AddAttributesSimple-16      0.0 ± 0%      417.0 ± 0%         ? (p=0.000 n=10)      417.0 ±  0%         ? (p=0.000 n=10)
Processor/AddAttributesBatch-16     616.5 ± 3%     1053.0 ± 2%   +70.80% (p=0.000 n=10)     1048.5 ±  2%   +70.07% (p=0.000 n=10)
Processor/SetAttributesSimple-16    48.00 ± 0%     466.00 ± 0%  +870.83% (p=0.000 n=10)     466.00 ±  0%  +870.83% (p=0.000 n=10)
Processor/SetAttributesBatch-16     648.0 ± 3%     1089.5 ± 1%   +68.13% (p=0.000 n=10)     1087.5 ±  4%   +67.82% (p=0.000 n=10)
LoggerNewRecord/5_attributes-16     0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
LoggerNewRecord/10_attributes-16    610.0 ± 0%      610.0 ± 0%         ~ (p=1.000 n=10) ¹    610.0 ±  0%         ~ (p=1.000 n=10) ¹
LoggerProviderLogger-16             354.5 ± 6%      368.0 ± 7%         ~ (p=0.288 n=10)      391.0 ± 29%         ~ (p=0.239 n=10)
WalkAttributes/1_attributes-16      0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
WalkAttributes/10_attributes-16     0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
WalkAttributes/100_attributes-16    0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
WalkAttributes/1000_attributes-16   0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
SetAddAttributes/SetAttributes-16   48.00 ± 0%      48.00 ± 0%         ~ (p=1.000 n=10) ¹    48.00 ±  0%         ~ (p=1.000 n=10) ¹
SetAddAttributes/AddAttributes-16   0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
SimpleProcessorOnEmit-16            0.000 ± 0%      0.000 ± 0%         ~ (p=1.000 n=10) ¹    0.000 ±  0%         ~ (p=1.000 n=10) ¹
geomean                                        ²                ?                       ²                 ?                       ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                  │   old.txt    │                new.txt                │              new-pgo.txt              │
                                  │  allocs/op   │ allocs/op   vs base                   │ allocs/op   vs base                   │
BatchProcessorOnEmit-16             0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
Processor/Simple-16                 0.000 ± 0%     1.000 ± 0%         ? (p=0.000 n=10)     1.000 ± 0%         ? (p=0.000 n=10)
Processor/Batch-16                  0.000 ± 0%     1.000 ± 0%         ? (p=0.000 n=10)     1.000 ± 0%         ? (p=0.000 n=10)
Processor/SetTimestampSimple-16     0.000 ± 0%     1.000 ± 0%         ? (p=0.000 n=10)     1.000 ± 0%         ? (p=0.000 n=10)
Processor/SetTimestampBatch-16      0.000 ± 0%     1.000 ± 0%         ? (p=0.000 n=10)     1.000 ± 0%         ? (p=0.000 n=10)
Processor/AddAttributesSimple-16    0.000 ± 0%     1.000 ± 0%         ? (p=0.000 n=10)     1.000 ± 0%         ? (p=0.000 n=10)
Processor/AddAttributesBatch-16     0.000 ± 0%     1.000 ± 0%         ? (p=0.000 n=10)     1.000 ± 0%         ? (p=0.000 n=10)
Processor/SetAttributesSimple-16    1.000 ± 0%     2.000 ± 0%  +100.00% (p=0.000 n=10)     2.000 ± 0%  +100.00% (p=0.000 n=10)
Processor/SetAttributesBatch-16     1.000 ± 0%     2.000 ± 0%  +100.00% (p=0.000 n=10)     2.000 ± 0%  +100.00% (p=0.000 n=10)
LoggerNewRecord/5_attributes-16     0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
LoggerNewRecord/10_attributes-16    4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹   4.000 ± 0%         ~ (p=1.000 n=10) ¹
LoggerProviderLogger-16             1.000 ± 0%     1.000 ± 0%         ~ (p=1.000 n=10) ¹   1.000 ± 0%         ~ (p=1.000 n=10) ¹
WalkAttributes/1_attributes-16      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
WalkAttributes/10_attributes-16     0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
WalkAttributes/100_attributes-16    0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
WalkAttributes/1000_attributes-16   0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
SetAddAttributes/SetAttributes-16   1.000 ± 0%     1.000 ± 0%         ~ (p=1.000 n=10) ¹   1.000 ± 0%         ~ (p=1.000 n=10) ¹
SetAddAttributes/AddAttributes-16   0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
SimpleProcessorOnEmit-16            0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹   0.000 ± 0%         ~ (p=1.000 n=10) ¹
geomean                                        ²               ?                       ²               ?                       ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```
2024-08-01 10:13:43 +02:00
Sam Xie
48f6a11b75
Correct the comment for the priority of options and environments on otlpmetric (#5641)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/5379
2024-07-24 18:42:37 -07:00
Damien Mathieu
3e17ef99d6
Allow relying on InstrumentationScope in SpanStub and fix remaining deprecation issues (#5627)
Rather than the deprecated InstrumentationLibrary

This is a replacement for
https://github.com/open-telemetry/opentelemetry-go/pull/3104, as after
this, there is no usage of `instrumentation.Library` within the SDK
anymore.

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Sam Xie <sam@samxie.me>
2024-07-24 09:33:07 +02:00
Sam Xie
52d4ce66e5
Include otlploggrpc module into the experimental-logs (#5629)
Resolve #5056
2024-07-18 10:41:34 -07:00
pree-dew
23abb5a3d8
Parse errormsgs in retryable status codes (#5541)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5536

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-07-18 09:49:44 +02:00
Tyler Yahn
f5b4e99025
Update example instrumentation names (#5612)
Part of #5412 

- Use the recommended package name for the instrumentation exemplified
in the repository.
- Use the recommended detection of a `TracerProvider` from passed
context.
2024-07-12 11:53:18 -07:00
Robert Pająk
82184aa44b
[chore] Add missing changelog entry for #5577 (#5586)
Per
https://github.com/open-telemetry/opentelemetry-go-contrib/pull/5868#issuecomment-2213239602

Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Damien Mathieu <damien.mathieu@elastic.co>
2024-07-09 09:36:59 +02:00
Sam Xie
aab5af16af
Correct the comment for the priority of options and environments on otlptracehttp (#5584)
part of https://github.com/open-telemetry/opentelemetry-go/issues/5379
2024-07-08 18:14:06 -07:00
Sam Xie
30ca54a7dc
Protect released changelog in CI (#5560)
resolve #1682

This PR adds a new action in CI to protect released sections in the
changelog from being changed. It compares the released sections in the
changelog from the base branch to the current PR. It fails if a change
happens.

Apply "Unlock Released Changelog" to bypass this check when doing a new
release.

Action result if we changed the unreleased section:
d640deb435
Action result if we changed the released section:
d672de7a54

---

Meaning of `awk '/^\<!-- Released section --\>/ {flag=1} /^\<!--
Released section ended --\>/ {flag=0} flag'`
- `/^\<!-- Released section --\>/ {flag=1}`
  - Matches lines starting with `<!-- Released section -->`.
  - Sets the flag variable to 1 (starting the printing of lines).
- `/^\<!-- Released section ended --\>/ {flag=0}`
  - Matches lines starting with `<!-- Released section ended -->`.
  - Sets the flag variable to 0.
  - So it is ok to change external reference links, like
    ```md 
    [Go 1.22]: https://go.dev/doc/go1.22
    [Go 1.21]: https://go.dev/doc/go1.21
    ```
- `flag` lines are printed only when the flag is 1.

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-07-08 11:31:31 -07:00
Santi Leira
7e0af515e2
baggage: Fix invalid percent-encoded octet sequences (#5528)
# Goal

Replace the percent encoded octet sequence with the replacement code
point (U+FFFD) when it doesn't match the UTF-8 encoding schema.

Issue: https://github.com/open-telemetry/opentelemetry-go/issues/5519

Current behavior: 

```
package main

import (
	"fmt"
	"log"
	"unicode/utf8"

	"go.opentelemetry.io/otel/baggage"
)

func main() {
	kv := "k=aa%ffcc"

	b, err := baggage.Parse(kv)
	if err != nil {
		log.Fatal(err)
	}
	val := b.Members()[0].Value()

	fmt.Println(len(val)) # 5
	fmt.Println(utf8.ValidString(val)) # false
}
```

Expected behavior:
```
package main

import (
	"fmt"
	"log"
	"unicode/utf8"

	"go.opentelemetry.io/otel/baggage"
)

func main() {
	kv := "k=aa%ffcc"

	b, err := baggage.Parse(kv)
	if err != nil {
		log.Fatal(err)
	}
	val := b.Members()[0].Value()

	fmt.Println(len(val)) # 7
	fmt.Println(utf8.ValidString(val)) # true
}
```

## Benchmark

- `go test -bench=BenchmarkParse -count 20 > old.txt`
```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/baggage
BenchmarkParse-10    	 1548118	       774.3 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1547653	       786.0 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1544949	       770.5 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1558972	       770.2 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1554973	       774.7 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1550200	       779.6 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1545100	       774.3 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1549634	       777.5 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1552530	       769.6 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1536499	       855.0 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1552244	       770.4 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1560225	       767.4 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1562738	       772.3 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1556679	       838.9 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1562500	       777.1 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1530901	       836.5 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1000000	      1372 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1534678	       780.3 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1366180	       822.4 ns/op	     864 B/op	       8 allocs/op
BenchmarkParse-10    	 1539852	       796.8 ns/op	     864 B/op	       8 allocs/op
PASS
ok  	go.opentelemetry.io/otel/baggage	40.839s

```

- `go test -bench=BenchmarkParse -count 20 > new.txt`
```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/baggage
BenchmarkParse-10    	 1355893	       886.6 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1349192	       883.1 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1363053	       880.4 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1372404	       875.7 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1359979	       880.7 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1360497	       874.7 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1375520	       870.2 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1375268	       882.8 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1361998	       964.8 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1373461	       961.5 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1378065	       872.6 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1377290	       879.0 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1362094	       885.6 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1352175	       915.9 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1364914	       887.9 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1355782	       890.5 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1361848	      1245 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1163396	       878.8 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1370886	       916.6 ns/op	     888 B/op	       9 allocs/op
BenchmarkParse-10    	 1340149	      1175 ns/op	     888 B/op	       9 allocs/op
PASS
ok  	go.opentelemetry.io/otel/baggage	44.347s
```

- `benchstat old.txt new.txt`
```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/baggage
         │   old.txt   │               new.txt               │
         │   sec/op    │   sec/op     vs base                │
Parse-10   777.3n ± 3%   884.4n ± 4%  +13.77% (p=0.000 n=20)

         │  old.txt   │              new.txt              │
         │    B/op    │    B/op     vs base               │
Parse-10   864.0 ± 0%   888.0 ± 0%  +2.78% (p=0.000 n=20)

         │  old.txt   │              new.txt               │
         │ allocs/op  │ allocs/op   vs base                │
Parse-10   8.000 ± 0%   9.000 ± 0%  +12.50% (p=0.000 n=20)
```

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-07-08 15:01:04 +02:00
Tyler Yahn
81216fb002
Releases v1.28.0/v0.50.0/v0.4.0 (#5569)
### Added

- The `IsEmpty` method is added to the `Instrument` type in
`go.opentelemetry.io/otel/sdk/metric`.
This method is used to check if an `Instrument` instance is a
zero-value. (#5431)
- Store and provide the emitted `context.Context` in `ScopeRecords` of
`go.opentelemetry.io/otel/sdk/log/logtest`. (#5468)
- The `go.opentelemetry.io/otel/semconv/v1.26.0` package.
The package contains semantic conventions from the `v1.26.0` version of
the OpenTelemetry Semantic Conventions. (#5476)
- The `AssertRecordEqual` method to
`go.opentelemetry.io/otel/log/logtest` to allow comparison of two log
records in tests. (#5499)
- The `WithHeaders` option to
`go.opentelemetry.io/otel/exporters/zipkin` to allow configuring custom
http headers while exporting spans. (#5530)

### Changed

- `Tracer.Start` in `go.opentelemetry.io/otel/trace/noop` no longer
allocates a span for empty span context. (#5457)
- Upgrade `go.opentelemetry.io/otel/semconv/v1.25.0` to
`go.opentelemetry.io/otel/semconv/v1.26.0` in
`go.opentelemetry.io/otel/example/otel-collector`. (#5490)
- Upgrade `go.opentelemetry.io/otel/semconv/v1.25.0` to
`go.opentelemetry.io/otel/semconv/v1.26.0` in
`go.opentelemetry.io/otel/example/zipkin`. (#5490)
- Upgrade `go.opentelemetry.io/otel/semconv/v1.25.0` to
`go.opentelemetry.io/otel/semconv/v1.26.0` in
`go.opentelemetry.io/otel/exporters/zipkin`. (#5490)
- The exporter no longer exports the deprecated "otel.library.name" or
"otel.library.version" attributes.
- Upgrade `go.opentelemetry.io/otel/semconv/v1.25.0` to
`go.opentelemetry.io/otel/semconv/v1.26.0` in
`go.opentelemetry.io/otel/sdk/resource`. (#5490)
- Upgrade `go.opentelemetry.io/otel/semconv/v1.25.0` to
`go.opentelemetry.io/otel/semconv/v1.26.0` in
`go.opentelemetry.io/otel/sdk/trace`. (#5490)
- `SimpleProcessor.OnEmit` in `go.opentelemetry.io/otel/sdk/log` no
longer allocates a slice which makes it possible to have a
zero-allocation log processing using `SimpleProcessor`. (#5493)
- Use non-generic functions in the `Start` method of
`"go.opentelemetry.io/otel/sdk/trace".Trace` to reduce memory
allocation. (#5497)
- `service.instance.id` is populated for a `Resource` created with
`"go.opentelemetry.io/otel/sdk/resource".Default` with a default value
when `OTEL_GO_X_RESOURCE` is set. (#5520)
- Improve performance of metric instruments in
`go.opentelemetry.io/otel/sdk/metric` by removing unnecessary calls to
`time.Now`. (#5545)

### Fixed

- Log a warning to the OpenTelemetry internal logger when a `Record` in
`go.opentelemetry.io/otel/sdk/log` drops an attribute due to a limit
being reached. (#5376)
- Identify the `Tracer` returned from the global `TracerProvider` in
`go.opentelemetry.io/otel/global` with its schema URL. (#5426)
- Identify the `Meter` returned from the global `MeterProvider` in
`go.opentelemetry.io/otel/global` with its schema URL. (#5426)
- Log a warning to the OpenTelemetry internal logger when a `Span` in
`go.opentelemetry.io/otel/sdk/trace` drops an attribute, event, or link
due to a limit being reached. (#5434)
- Document instrument name requirements in
`go.opentelemetry.io/otel/metric`. (#5435)
- Prevent random number generation data-race for experimental rand
exemplars in `go.opentelemetry.io/otel/sdk/metric`. (#5456)
- Fix counting number of dropped attributes of `Record` in
`go.opentelemetry.io/otel/sdk/log`. (#5464)
- Fix panic in baggage creation when a member contains `0x80` char in
key or value. (#5494)
- Correct comments for the priority of the `WithEndpoint` and
`WithEndpointURL` options and their corresponding environment variables
in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`.
(#5508)
- Retry trace and span ID generation if it generated an invalid one in
`go.opentelemetry.io/otel/sdk/trace`. (#5514)
- Fix stale timestamps reported by the last-value aggregation. (#5517)
- Indicate the `Exporter` in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` must be
created by the `New` method. (#5521)
- Improved performance in all `{Bool,Int64,Float64,String}SliceValue`
functions of `go.opentelemetry.io/attributes` by reducing the number of
allocations. (#5549)
2024-07-02 13:29:45 -07:00
David Ashpole
0485de287e
Move time.Now call into exemplar reservoir to improve performance (#5545)
Part of addressing
https://github.com/open-telemetry/opentelemetry-go/issues/5542.

### Motivation

This removes the `time.Now()` call from filtered-out Exemplars by only
invoking `time.Now()` after the filtering decision is made. This
improvement is especially noticeable for measurements without any
attributes.

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: AMD EPYC 7B12
                                                                 │   old.txt    │                new.txt                │
                                                                 │    sec/op    │   sec/op     vs base                  │
SyncMeasure/NoView/Int64Counter/Attributes/0-24                    158.20n ± 4%   99.83n ± 1%  -36.90% (p=0.000 n=10)
SyncMeasure/NoView/Int64Counter/Attributes/1-24                     333.3n ± 4%   274.8n ± 1%  -17.55% (p=0.000 n=10)
SyncMeasure/NoView/Int64Counter/Attributes/10-24                    1.640µ ± 1%   1.600µ ± 1%   -2.41% (p=0.000 n=10)
SyncMeasure/NoView/Float64Counter/Attributes/0-24                   159.0n ± 3%   101.3n ± 0%  -36.27% (p=0.000 n=10)
SyncMeasure/NoView/Float64Counter/Attributes/1-24                   340.0n ± 2%   272.0n ± 1%  -20.00% (p=0.000 n=10)
SyncMeasure/NoView/Float64Counter/Attributes/10-24                  1.661µ ± 1%   1.597µ ± 0%   -3.85% (p=0.000 n=10)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/0-24               159.8n ± 1%   103.1n ± 0%  -35.50% (p=0.000 n=10)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/1-24               339.5n ± 1%   273.1n ± 0%  -19.57% (p=0.000 n=10)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/10-24              1.656µ ± 0%   1.589µ ± 0%   -4.05% (p=0.000 n=10)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/0-24             159.3n ± 2%   100.8n ± 0%  -36.74% (p=0.000 n=10)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/1-24             337.9n ± 2%   271.8n ± 1%  -19.55% (p=0.000 n=10)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/10-24            1.657µ ± 0%   1.593µ ± 1%   -3.83% (p=0.000 n=10)
SyncMeasure/NoView/Int64Histogram/Attributes/0-24                  144.65n ± 4%   89.38n ± 0%  -38.21% (p=0.000 n=10)
SyncMeasure/NoView/Int64Histogram/Attributes/1-24                   235.7n ± 2%   183.5n ± 0%  -22.15% (p=0.000 n=10)
SyncMeasure/NoView/Int64Histogram/Attributes/10-24                  900.8n ± 1%   836.8n ± 0%   -7.10% (p=0.000 n=10)
SyncMeasure/NoView/Float64Histogram/Attributes/0-24                145.60n ± 5%   93.48n ± 1%  -35.80% (p=0.000 n=10)
SyncMeasure/NoView/Float64Histogram/Attributes/1-24                 240.9n ± 1%   183.0n ± 0%  -24.06% (p=0.000 n=10)
SyncMeasure/NoView/Float64Histogram/Attributes/10-24                905.6n ± 1%   826.3n ± 0%   -8.76% (p=0.000 n=10)
SyncMeasure/DropView/Int64Counter/Attributes/0-24                   20.33n ± 0%   20.35n ± 0%        ~ (p=0.302 n=10)
SyncMeasure/DropView/Int64Counter/Attributes/1-24                   26.46n ± 0%   26.45n ± 1%        ~ (p=0.868 n=10)
SyncMeasure/DropView/Int64Counter/Attributes/10-24                  26.50n ± 0%   26.47n ± 0%        ~ (p=0.208 n=10)
SyncMeasure/DropView/Float64Counter/Attributes/0-24                 20.34n ± 1%   20.27n ± 0%   -0.34% (p=0.009 n=10)
SyncMeasure/DropView/Float64Counter/Attributes/1-24                 26.55n ± 0%   26.60n ± 1%        ~ (p=0.109 n=10)
SyncMeasure/DropView/Float64Counter/Attributes/10-24                26.59n ± 1%   26.57n ± 1%        ~ (p=0.926 n=10)
SyncMeasure/DropView/Int64UpDownCounter/Attributes/0-24             20.38n ± 1%   20.38n ± 0%        ~ (p=0.725 n=10)
SyncMeasure/DropView/Int64UpDownCounter/Attributes/1-24             26.39n ± 0%   26.44n ± 0%        ~ (p=0.238 n=10)
SyncMeasure/DropView/Int64UpDownCounter/Attributes/10-24            26.52n ± 0%   26.42n ± 0%   -0.36% (p=0.049 n=10)
SyncMeasure/DropView/Float64UpDownCounter/Attributes/0-24           20.30n ± 0%   20.25n ± 0%        ~ (p=0.196 n=10)
SyncMeasure/DropView/Float64UpDownCounter/Attributes/1-24           26.57n ± 0%   26.54n ± 1%        ~ (p=0.540 n=10)
SyncMeasure/DropView/Float64UpDownCounter/Attributes/10-24          26.57n ± 0%   26.51n ± 1%        ~ (p=0.643 n=10)
SyncMeasure/DropView/Int64Histogram/Attributes/0-24                 20.37n ± 0%   20.36n ± 1%        ~ (p=1.000 n=10)
SyncMeasure/DropView/Int64Histogram/Attributes/1-24                 26.41n ± 0%   26.50n ± 0%   +0.32% (p=0.007 n=10)
SyncMeasure/DropView/Int64Histogram/Attributes/10-24                26.44n ± 0%   26.55n ± 1%   +0.42% (p=0.012 n=10)
SyncMeasure/DropView/Float64Histogram/Attributes/0-24               20.30n ± 0%   20.45n ± 0%   +0.74% (p=0.000 n=10)
SyncMeasure/DropView/Float64Histogram/Attributes/1-24               26.52n ± 0%   26.48n ± 0%        ~ (p=0.127 n=10)
SyncMeasure/DropView/Float64Histogram/Attributes/10-24              26.55n ± 0%   26.48n ± 0%   -0.26% (p=0.002 n=10)
SyncMeasure/AttrFilterView/Int64Counter/Attributes/0-24             170.5n ± 2%   110.8n ± 0%  -35.03% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Int64Counter/Attributes/1-24             402.5n ± 1%   331.5n ± 1%  -17.64% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Int64Counter/Attributes/10-24            1.363µ ± 1%   1.281µ ± 1%   -6.02% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Float64Counter/Attributes/0-24           170.6n ± 1%   111.5n ± 1%  -34.64% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Float64Counter/Attributes/1-24           397.1n ± 1%   335.9n ± 0%  -15.41% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Float64Counter/Attributes/10-24          1.371µ ± 1%   1.279µ ± 1%   -6.71% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Int64UpDownCounter/Attributes/0-24       170.1n ± 1%   112.2n ± 0%  -34.09% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Int64UpDownCounter/Attributes/1-24       397.5n ± 1%   330.2n ± 0%  -16.93% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Int64UpDownCounter/Attributes/10-24      1.371µ ± 1%   1.289µ ± 1%   -5.95% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Float64UpDownCounter/Attributes/0-24     171.4n ± 2%   112.9n ± 0%  -34.13% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Float64UpDownCounter/Attributes/1-24     397.0n ± 3%   336.4n ± 0%  -15.24% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Float64UpDownCounter/Attributes/10-24    1.383µ ± 1%   1.305µ ± 1%   -5.61% (p=0.000 n=10)
SyncMeasure/AttrFilterView/Int64Histogram/Attributes/0-24          157.30n ± 2%   98.58n ± 1%  -37.33% (p=0.000 n=6+10)
```

### Changes

* Introduce `exemplar.Filter`, which is a filter function based on the
context. It will not be user-facing, so we can always add other
parameters later if needed.
* Introduce `exemplar.FilteredReservoir`, which is similar to a
reservoir, except it does not receive a timestamp. It gets the current
time after the filter decision has been made. It uses generics to avoid
the call to exemplar.NewValue(), since it is internal-only.
* The `exemplar.Reservoir` is left as-is, so that it can be made public
when exemplars are stable. It still includes a timestamp argument.
* Unit tests are updated to expect a much lower number of calls to
time.Now
* `exemplar.Drop` is now an `exemplar.FilteredReservoir` instead of a
`Reservoir`, since we don't need a Reservoir to store things in if the
measurement is always dropped.

Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-07-01 09:36:11 -07:00
Fabrice Vaillant
f3a2d96022
Reduces allocation in attributes (#5549)
Remove one allocation in all SliceValue function (going from 3 to 2).

Here is benchstat results

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/internal/attribute
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
                    │   old.txt    │               new.txt                │
                    │    sec/op    │    sec/op     vs base                │
BoolSliceValue-8      128.4n ± 22%   103.8n ± 25%  -19.12% (p=0.007 n=10)
Int64SliceValue-8     167.9n ±  7%   130.8n ±  5%  -22.13% (p=0.000 n=10)
Float64SliceValue-8   133.8n ± 14%   122.6n ±  4%   -8.33% (p=0.000 n=10)
StringSliceValue-8    166.4n ±  9%   158.5n ± 10%   -4.75% (p=0.037 n=10)
geomean               148.0n         127.5n        -13.88%

                    │   old.txt   │              new.txt               │
                    │    B/op     │    B/op     vs base                │
BoolSliceValue-8      32.000 ± 0%   8.000 ± 0%  -75.00% (p=0.000 n=10)
Int64SliceValue-8      88.00 ± 0%   64.00 ± 0%  -27.27% (p=0.000 n=10)
Float64SliceValue-8    88.00 ± 0%   64.00 ± 0%  -27.27% (p=0.000 n=10)
StringSliceValue-8     152.0 ± 0%   128.0 ± 0%  -15.79% (p=0.000 n=10)
geomean                78.34        45.25       -42.23%

                    │  old.txt   │              new.txt               │
                    │ allocs/op  │ allocs/op   vs base                │
BoolSliceValue-8      3.000 ± 0%   2.000 ± 0%  -33.33% (p=0.000 n=10)
Int64SliceValue-8     3.000 ± 0%   2.000 ± 0%  -33.33% (p=0.000 n=10)
Float64SliceValue-8   3.000 ± 0%   2.000 ± 0%  -33.33% (p=0.000 n=10)
StringSliceValue-8    3.000 ± 0%   2.000 ± 0%  -33.33% (p=0.000 n=10)
geomean               3.000        2.000       -33.33%
```
2024-06-27 10:27:48 -07:00
Sam Xie
418f19d341
Indicate the otlploghttp exporter must be created by the New method (#5521)
The empty Exporter would cause panics.
2024-06-27 11:41:05 +02:00