1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-27 22:49:15 +02:00
Commit Graph

23 Commits

Author SHA1 Message Date
Tyler Yahn
88d3fedf1a Optimize the return type of ExportSpans (#7405)
Do not allocate a return function from `ExportSpans` to the heap. Use
the added `ExportOp` type instead.

### Benchmarks

#### `stdouttrace`

```terminal
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/stdout/stdouttrace
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                      │ main.bmark.results │ stdouttrace-optimize-end.bmark.results │
                                      │       sec/op       │     sec/op       vs base               │
ExporterExportSpans/Observability-8            23.37µ ± 2%       22.79µ ± 3%  -2.50% (p=0.025 n=10)
ExporterExportSpans/NoObservability-8          23.07µ ± 7%       22.29µ ± 1%  -3.38% (p=0.000 n=10)
geomean                                        23.22µ            22.54µ       -2.94%

                                      │ main.bmark.results │ stdouttrace-optimize-end.bmark.results │
                                      │        B/op        │      B/op        vs base               │
ExporterExportSpans/Observability-8           4.253Ki ± 0%      4.190Ki ± 0%  -1.47% (p=0.000 n=10)
ExporterExportSpans/NoObservability-8         3.975Ki ± 0%      3.975Ki ± 0%       ~ (p=0.474 n=10)
geomean                                       4.111Ki           4.081Ki       -0.74%

                                      │ main.bmark.results │ stdouttrace-optimize-end.bmark.results │
                                      │     allocs/op      │   allocs/op    vs base                 │
ExporterExportSpans/Observability-8             67.00 ± 0%      66.00 ± 0%  -1.49% (p=0.000 n=10)
ExporterExportSpans/NoObservability-8           64.00 ± 0%      64.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                         65.48           64.99       -0.75%
¹ all samples are equal
```

#### `stdouttrace/internal/observ`

```terminal

goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/stdout/stdouttrace/internal/observ
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                          │ main.bmark.results │ stdouttrace-optimize-end.bmark.results │
                                          │       sec/op       │     sec/op      vs base                │
InstrumentationExportSpans/NoError-8               197.9n ± 7%      153.3n ± 5%  -22.51% (p=0.000 n=10)
InstrumentationExportSpans/PartialError-8          754.4n ± 6%      663.2n ± 6%  -12.08% (p=0.001 n=10)
InstrumentationExportSpans/FullError-8             772.8n ± 4%      669.2n ± 4%  -13.39% (p=0.000 n=10)
geomean                                            486.8n           408.3n       -16.13%

                                          │ main.bmark.results │ stdouttrace-optimize-end.bmark.results  │
                                          │        B/op        │    B/op     vs base                     │
InstrumentationExportSpans/NoError-8                64.00 ± 0%    0.00 ± 0%  -100.00% (p=0.000 n=10)
InstrumentationExportSpans/PartialError-8           280.0 ± 0%   216.0 ± 0%   -22.86% (p=0.000 n=10)
InstrumentationExportSpans/FullError-8              280.0 ± 0%   216.0 ± 0%   -22.86% (p=0.000 n=10)
geomean                                             171.2                    ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

                                          │ main.bmark.results │ stdouttrace-optimize-end.bmark.results  │
                                          │     allocs/op      │ allocs/op   vs base                     │
InstrumentationExportSpans/NoError-8                1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
InstrumentationExportSpans/PartialError-8           3.000 ± 0%   2.000 ± 0%   -33.33% (p=0.000 n=10)
InstrumentationExportSpans/FullError-8              3.000 ± 0%   2.000 ± 0%   -33.33% (p=0.000 n=10)
geomean                                             2.080                    ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
```
2025-09-25 09:07:15 -07:00
Tyler Yahn
9b6585ae54 Encapsulate stdouttrace.Exporter instrumentation in internal package (#7307)
[Follow
guidelines](a5dcd68ebb/CONTRIBUTING.md (encapsulation))
and move instrumentation into its own type.
2025-09-09 12:11:08 -07:00
Tyler Yahn
5358fd737d Upgrade semconv dependencies to v1.37.0 (#7260)
Resolve https://github.com/open-telemetry/opentelemetry-go/issues/7255
2025-08-28 11:29:52 +02:00
Tyler Yahn
41f03302cd Amortize measurement option allocations (#7215)
This is not a performance critical exporter, but it is acting as the
foundation for all other self-observability work. We want to ensure
performance is considered for all this other work.

- Do not allocate the add and record measurement option slices.
- Do not allocate the `metric.attrOpt` to head when on default path
(i.e. `WithAttributeSet` or `WithAttributes`)

There are three additional allocations in the self-observability. It
appears these are added in the error scenario where we need to
dynamically build the attributes that are being recorded.

### Benchmarks

```terminal
$ benchstat main-49be00144.txt amortize-opts-stdouttrace.txt
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/stdout/stdouttrace
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                        │ main-49be00144.txt │   amortize-opts-stdouttrace.txt    │
                                        │       sec/op       │   sec/op     vs base               │
ExporterExportSpans/SelfObservability-8          26.89µ ± 3%   27.40µ ± 3%       ~ (p=0.143 n=10)
ExporterExportSpans/NoObservability-8            25.99µ ± 3%   27.22µ ± 2%  +4.76% (p=0.004 n=10)

                                        │ main-49be00144.txt │    amortize-opts-stdouttrace.txt     │
                                        │        B/op        │     B/op      vs base                │
ExporterExportSpans/SelfObservability-8         5.459Ki ± 0%   4.081Ki ± 0%  -25.24% (p=0.000 n=10)
ExporterExportSpans/NoObservability-8           3.873Ki ± 0%   3.873Ki ± 0%        ~ (p=1.000 n=10)

                                        │ main-49be00144.txt │    amortize-opts-stdouttrace.txt     │
                                        │     allocs/op      │ allocs/op   vs base                  │
ExporterExportSpans/SelfObservability-8           80.00 ± 0%   67.00 ± 0%  -16.25% (p=0.000 n=10)
ExporterExportSpans/NoObservability-8             65.00 ± 0%   65.00 ± 0%        ~ (p=1.000 n=10) ¹
¹ all samples are equal
```

## Follow-up

- Investigate if the `semconv` helper packages can be updated to accept
some of this complexity (e.g. add a `AddSet` method that accepts an
`attribute.Set` instead of just `...attribute.KeyValue`).

## Alternatives

A cleaner version is found in
https://github.com/open-telemetry/opentelemetry-go/pull/7226. That
relies on an external [`bind`](https://github.com/MrAlias/bind) package
and the clean up mentioned above.
2025-08-26 09:10:29 -07:00
Tyler Yahn
44a0d621ee Pool attribute slices in stdouttrace self-observability (#7201)
### Benchmarks

```terminal
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/stdout/stdouttrace
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                      │  main.txt   │   stdouttrace-pool-obs-attrs.txt   │
                      │   sec/op    │   sec/op     vs base               │
ExporterExportSpans-8   30.55µ ± 2%   31.76µ ± 3%  +3.96% (p=0.000 n=10)

                      │   main.txt   │   stdouttrace-pool-obs-attrs.txt    │
                      │     B/op     │     B/op      vs base               │
ExporterExportSpans-8   6.538Ki ± 0%   6.353Ki ± 0%  -2.84% (p=0.000 n=10)

                      │  main.txt  │  stdouttrace-pool-obs-attrs.txt   │
                      │ allocs/op  │ allocs/op   vs base               │
ExporterExportSpans-8   135.0 ± 0%   134.0 ± 0%  -0.74% (p=0.000 n=10)
```
2025-08-18 10:27:17 -07:00
Tyler Yahn
907d93b8e1 Handle partial export counts in stdouttrace observability (#7199)
Do not fail all exported metric counts if only some of them failed.
2025-08-18 09:37:33 -07:00
Tyler Yahn
e799586d10 Restructure component ID counting in stdouttrace (#7196)
Use a resettable counter so tests can have deterministic component IDs
that do not depend on previous state.
2025-08-17 09:05:09 -07:00
Tyler Yahn
cdd18ab3a1 Fix component name for stdouttrace (#7195)
The STDOUT exporter not a standardized type. Use the [semantic
convention recommendation of a "language-defined name of the
type"](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/otel.md#otel-component-type).
2025-08-17 08:46:13 -07:00
Tyler Yahn
ee6d57b7cf Flatten stdouttrace Exporter.initSelfObservability into Exporter.New (#7197)
- Do not use [side-effect
programming](https://en.wikipedia.org/wiki/Side_effect_(computer_science))
to setup an exporter. Make the setup explicit, unique, and local.
- Report instrument creation errors back to the user instead of passing
them to `otel.Handle`.
2025-08-17 08:37:42 -07:00
Tyler Yahn
2ab7d4dc14 Use the context passed to ExportSpans for measurements in stdouttrace (#7198)
Without this the measurements are receiving broken context.
2025-08-17 08:26:57 -07:00
Flc゛
0a834865f6 feat(stdouttrace): add experimental self-observability metrics (#7133)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7008
2025-08-11 16:05:02 +02:00
Matthieu MOREL
d464abf1f3 chore: enable unused-parameter rule from revive (#7122)
#### Description

Enable and fixes
[unused-parameter](https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-parameter)
rule from revive

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-08-04 12:48:04 -07:00
Mikhail Mazurskiy
5e1c62a2d5 Modernize (#7089)
Use
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
to update code to new style.

---------

Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-07-29 10:19:11 +02:00
Damien Mathieu
f6a5aa2c3f Add unparam linter (#5531)
This adds the [unparam](https://github.com/mvdan/unparam) linter.

Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-06-21 16:02:07 -07:00
Prasad Shirodkar
fd6d4db8c3 Remove context check on stdout exporters (#5189) 2024-04-25 17:11:45 +02:00
Robert Pająk
7dea232a46 [chore] Simplify the license header (#4987) 2024-02-29 07:05:28 +01:00
Alex Boten
8778c38832 docs: minor update to docstring (#4833)
Signed-off-by: Alex Boten <aboten@lightstep.com>
2024-01-19 15:18:16 +01:00
Charlie Le
1b55281859 docs(typos): Run codespell to fix typos (#3980)
* docs(typos): Run codespell to fix typos

There were a lot of typos through the repository, so I ran
[codespell][], a tool for automatically fixing typos, to fix them.

```console
make codespell
```

There's already a tool called [misspell][] that's supposed to take care
of this, but misspell hasn't been updated for 6 years, and it doesn't
seem to be catching any of the typos that codespell can.

[codespell]: https://github.com/codespell-project/codespell
[misspell]: https://github.com/client9/misspell

* Revert and ignore spelling for Consequentially

* Add GH workflow for codespell

* Revert GH Workflow and Makefile for codespell

Per @pellared, since there's no instructions for setting up codespell,
it was suggested that the changes for setting up a workflow and section
in Makefile include instructions for setting up codespell as well.

* Revert spelling on consequently

---------

Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2023-04-11 17:28:13 -07:00
Aaron Clawson
f24f52aa06 Debug Logging for sdk/trace (#2500)
* Debug Logging for sdk/trace

* Fixes spelling, adds marshaling to attribute sets

Co-authored-by: Aaron Clawson <MadVikingGod@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
2022-01-10 19:58:01 -05:00
Liz Fong-Jones
66fccc0be0 fix: lock accesses to encoder in json stdout exporter to prevent crash (#2265)
* lock accesses to encoder

fixes #2264

* move locking outside loop to avoid deadlock

* Update CHANGELOG.md
2021-09-30 15:58:26 -04:00
Lucas Käldström
c912b179fd Print JSON objects to stdout without a wrapping array (#2196)
* Encode JSON objects to stdout one by one; not wrapped in lists

* Add changelog entry
2021-08-25 08:48:48 -07:00
Lucas Käldström
add511c105 Make WithoutTimestamps work (#2195)
* Make WithoutTimestamps work

* Add changes to changelog

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2021-08-23 14:29:51 -07:00
Anthony Mirabella
c30cd1d0fd Split stdout exporter into stdouttrace and stdoutmetric (#2005)
* Split stdout exporter into stdouttrace and stdoutmetric

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Remove unused options from stdouttrace and stdoutmetric exporters

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Update stdout exporter references in website docs

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Update docs to include correct import paths, properly describe exporter scope

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Remove pointless options to disable signals from what are now single-signal exporters

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
2021-06-16 11:32:42 -04:00