mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-10 09:47:28 -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
70
vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go
generated
vendored
70
vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go
generated
vendored
|
|
@ -4,51 +4,49 @@
|
|||
package metric // import "go.opentelemetry.io/otel/sdk/metric"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"slices"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal/exemplar"
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal/x"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/sdk/metric/exemplar"
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal/aggregate"
|
||||
)
|
||||
|
||||
// ExemplarReservoirProviderSelector selects the
|
||||
// [exemplar.ReservoirProvider] to use
|
||||
// based on the [Aggregation] of the metric.
|
||||
type ExemplarReservoirProviderSelector func(Aggregation) exemplar.ReservoirProvider
|
||||
|
||||
// reservoirFunc returns the appropriately configured exemplar reservoir
|
||||
// creation func based on the passed InstrumentKind and user defined
|
||||
// environment variables.
|
||||
// creation func based on the passed InstrumentKind and filter configuration.
|
||||
func reservoirFunc[N int64 | float64](provider exemplar.ReservoirProvider, filter exemplar.Filter) func(attribute.Set) aggregate.FilteredExemplarReservoir[N] {
|
||||
return func(attrs attribute.Set) aggregate.FilteredExemplarReservoir[N] {
|
||||
return aggregate.NewFilteredExemplarReservoir[N](filter, provider(attrs))
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultExemplarReservoirProviderSelector returns the default
|
||||
// [exemplar.ReservoirProvider] for the
|
||||
// provided [Aggregation].
|
||||
//
|
||||
// Note: This will only return non-nil values when the experimental exemplar
|
||||
// feature is enabled and the OTEL_METRICS_EXEMPLAR_FILTER environment variable
|
||||
// is not set to always_off.
|
||||
func reservoirFunc[N int64 | float64](agg Aggregation) func() exemplar.FilteredReservoir[N] {
|
||||
if !x.Exemplars.Enabled() {
|
||||
return nil
|
||||
}
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/d4b241f451674e8f611bb589477680341006ad2b/specification/configuration/sdk-environment-variables.md#exemplar
|
||||
const filterEnvKey = "OTEL_METRICS_EXEMPLAR_FILTER"
|
||||
|
||||
var filter exemplar.Filter
|
||||
|
||||
switch os.Getenv(filterEnvKey) {
|
||||
case "always_on":
|
||||
filter = exemplar.AlwaysOnFilter
|
||||
case "always_off":
|
||||
return exemplar.Drop
|
||||
case "trace_based":
|
||||
fallthrough
|
||||
default:
|
||||
filter = exemplar.SampledFilter
|
||||
}
|
||||
|
||||
// For explicit bucket histograms with more than 1 bucket, it uses the
|
||||
// [exemplar.HistogramReservoirProvider].
|
||||
// For exponential histograms, it uses the
|
||||
// [exemplar.FixedSizeReservoirProvider]
|
||||
// with a size of min(20, max_buckets).
|
||||
// For all other aggregations, it uses the
|
||||
// [exemplar.FixedSizeReservoirProvider]
|
||||
// with a size equal to the number of CPUs.
|
||||
//
|
||||
// Exemplar default reservoirs MAY change in a minor version bump. No
|
||||
// guarantees are made on the shape or statistical properties of returned
|
||||
// exemplars.
|
||||
func DefaultExemplarReservoirProviderSelector(agg Aggregation) exemplar.ReservoirProvider {
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/d4b241f451674e8f611bb589477680341006ad2b/specification/metrics/sdk.md#exemplar-defaults
|
||||
// Explicit bucket histogram aggregation with more than 1 bucket will
|
||||
// use AlignedHistogramBucketExemplarReservoir.
|
||||
a, ok := agg.(AggregationExplicitBucketHistogram)
|
||||
if ok && len(a.Boundaries) > 0 {
|
||||
cp := slices.Clone(a.Boundaries)
|
||||
return func() exemplar.FilteredReservoir[N] {
|
||||
bounds := cp
|
||||
return exemplar.NewFilteredReservoir[N](filter, exemplar.Histogram(bounds))
|
||||
}
|
||||
return exemplar.HistogramReservoirProvider(a.Boundaries)
|
||||
}
|
||||
|
||||
var n int
|
||||
|
|
@ -75,7 +73,5 @@ func reservoirFunc[N int64 | float64](agg Aggregation) func() exemplar.FilteredR
|
|||
}
|
||||
}
|
||||
|
||||
return func() exemplar.FilteredReservoir[N] {
|
||||
return exemplar.NewFilteredReservoir[N](filter, exemplar.FixedSize(n))
|
||||
}
|
||||
return exemplar.FixedSizeReservoirProvider(n)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue