Self-Observability is a redundant term, the self being instrumented is
always the self that observability is being provided for. Remove this
redundancy.
Continue to provide backwards compatibility for any users already using
`OTEL_GO_X_SELF_OBSERVABILITY` to enable the feature.
---------
Co-authored-by: Damien Mathieu <42@dmathieu.com>
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`.
* Add WithScopeAttributes TracerOption to trace API
* Add Attributes field to instrumentation Scope
* Use scope attributes for new Tracer
* Fix stdouttrace expected test output
* Allow unexported Set fields in sdk/trace test
* Export instrumentation scope attrs in OTLP
* Add changes to the changelog
* Fix imports with make lint
* Add unit tests for WithScopeAttributes
* Fix English in Scope documentation
* 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>