mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-16 21:17:34 -06:00
[chore] update otel libraries (#3740)
* chore: update otel dependencies * refactor: combine tracing & metrics in observability package * chore: update example tracing compose file
This commit is contained in:
parent
baed591a1d
commit
dd094e4012
217 changed files with 6873 additions and 2734 deletions
19
vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/README.md
generated
vendored
19
vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/README.md
generated
vendored
|
|
@ -10,6 +10,7 @@ See the [Compatibility and Stability](#compatibility-and-stability) section for
|
|||
|
||||
- [Cardinality Limit](#cardinality-limit)
|
||||
- [Exemplars](#exemplars)
|
||||
- [Instrument Enabled](#instrument-enabled)
|
||||
|
||||
### Cardinality Limit
|
||||
|
||||
|
|
@ -102,6 +103,24 @@ Revert to the default exemplar filter (`"trace_based"`)
|
|||
unset OTEL_METRICS_EXEMPLAR_FILTER
|
||||
```
|
||||
|
||||
### Instrument Enabled
|
||||
|
||||
To help users avoid performing computationally expensive operations when recording measurements, synchronous instruments provide an `Enabled` method.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code shows an example of how to check if an instrument implements the `EnabledInstrument` interface before using the `Enabled` function to avoid doing an expensive computation:
|
||||
|
||||
```go
|
||||
type enabledInstrument interface { Enabled(context.Context) bool }
|
||||
|
||||
ctr, err := m.Int64Counter("expensive-counter")
|
||||
c, ok := ctr.(enabledInstrument)
|
||||
if !ok || c.Enabled(context.Background()) {
|
||||
c.Add(expensiveComputation())
|
||||
}
|
||||
```
|
||||
|
||||
## Compatibility and Stability
|
||||
|
||||
Experimental features do not fall within the scope of the OpenTelemetry Go versioning and stability [policy](../../../../VERSIONING.md).
|
||||
|
|
|
|||
58
vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go
generated
vendored
58
vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go
generated
vendored
|
|
@ -8,41 +8,26 @@
|
|||
package x // import "go.opentelemetry.io/otel/sdk/metric/internal/x"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
// Exemplars is an experimental feature flag that defines if exemplars
|
||||
// should be recorded for metric data-points.
|
||||
//
|
||||
// To enable this feature set the OTEL_GO_X_EXEMPLAR environment variable
|
||||
// to the case-insensitive string value of "true" (i.e. "True" and "TRUE"
|
||||
// will also enable this).
|
||||
Exemplars = newFeature("EXEMPLAR", func(v string) (string, bool) {
|
||||
if strings.ToLower(v) == "true" {
|
||||
return v, true
|
||||
}
|
||||
return "", false
|
||||
})
|
||||
|
||||
// CardinalityLimit is an experimental feature flag that defines if
|
||||
// cardinality limits should be applied to the recorded metric data-points.
|
||||
//
|
||||
// To enable this feature set the OTEL_GO_X_CARDINALITY_LIMIT environment
|
||||
// variable to the integer limit value you want to use.
|
||||
//
|
||||
// Setting OTEL_GO_X_CARDINALITY_LIMIT to a value less than or equal to 0
|
||||
// will disable the cardinality limits.
|
||||
CardinalityLimit = newFeature("CARDINALITY_LIMIT", func(v string) (int, bool) {
|
||||
n, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
return n, true
|
||||
})
|
||||
)
|
||||
// CardinalityLimit is an experimental feature flag that defines if
|
||||
// cardinality limits should be applied to the recorded metric data-points.
|
||||
//
|
||||
// To enable this feature set the OTEL_GO_X_CARDINALITY_LIMIT environment
|
||||
// variable to the integer limit value you want to use.
|
||||
//
|
||||
// Setting OTEL_GO_X_CARDINALITY_LIMIT to a value less than or equal to 0
|
||||
// will disable the cardinality limits.
|
||||
var CardinalityLimit = newFeature("CARDINALITY_LIMIT", func(v string) (int, bool) {
|
||||
n, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
return n, true
|
||||
})
|
||||
|
||||
// Feature is an experimental feature control flag. It provides a uniform way
|
||||
// to interact with these feature flags and parse their values.
|
||||
|
|
@ -83,3 +68,14 @@ func (f Feature[T]) Enabled() bool {
|
|||
_, ok := f.Lookup()
|
||||
return ok
|
||||
}
|
||||
|
||||
// EnabledInstrument informs whether the instrument is enabled.
|
||||
//
|
||||
// EnabledInstrument interface is implemented by synchronous instruments.
|
||||
type EnabledInstrument interface {
|
||||
// Enabled returns whether the instrument will process measurements for the given context.
|
||||
//
|
||||
// This function can be used in places where measuring an instrument
|
||||
// would result in computationally expensive operations.
|
||||
Enabled(context.Context) bool
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue