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.
- 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`.
* 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>
* 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>