forked from toolshed/abra
chore: deps and vendor
This commit is contained in:
4
vendor/go.opentelemetry.io/otel/sdk/metric/exporter.go
generated
vendored
4
vendor/go.opentelemetry.io/otel/sdk/metric/exporter.go
generated
vendored
@ -5,14 +5,14 @@ package metric // import "go.opentelemetry.io/otel/sdk/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
)
|
||||
|
||||
// ErrExporterShutdown is returned if Export or Shutdown are called after an
|
||||
// Exporter has been Shutdown.
|
||||
var ErrExporterShutdown = fmt.Errorf("exporter is shutdown")
|
||||
var ErrExporterShutdown = errors.New("exporter is shutdown")
|
||||
|
||||
// Exporter handles the delivery of metric data to external receivers. This is
|
||||
// the final component in the metric push pipeline.
|
||||
|
11
vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go
generated
vendored
11
vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go
generated
vendored
@ -16,6 +16,7 @@ import (
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
"go.opentelemetry.io/otel/sdk/instrumentation"
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal/aggregate"
|
||||
"go.opentelemetry.io/otel/sdk/metric/internal/x"
|
||||
)
|
||||
|
||||
var zeroScope instrumentation.Scope
|
||||
@ -190,6 +191,7 @@ var (
|
||||
_ metric.Int64UpDownCounter = (*int64Inst)(nil)
|
||||
_ metric.Int64Histogram = (*int64Inst)(nil)
|
||||
_ metric.Int64Gauge = (*int64Inst)(nil)
|
||||
_ x.EnabledInstrument = (*int64Inst)(nil)
|
||||
)
|
||||
|
||||
func (i *int64Inst) Add(ctx context.Context, val int64, opts ...metric.AddOption) {
|
||||
@ -202,6 +204,10 @@ func (i *int64Inst) Record(ctx context.Context, val int64, opts ...metric.Record
|
||||
i.aggregate(ctx, val, c.Attributes())
|
||||
}
|
||||
|
||||
func (i *int64Inst) Enabled(_ context.Context) bool {
|
||||
return len(i.measures) != 0
|
||||
}
|
||||
|
||||
func (i *int64Inst) aggregate(ctx context.Context, val int64, s attribute.Set) { // nolint:revive // okay to shadow pkg with method.
|
||||
for _, in := range i.measures {
|
||||
in(ctx, val, s)
|
||||
@ -222,6 +228,7 @@ var (
|
||||
_ metric.Float64UpDownCounter = (*float64Inst)(nil)
|
||||
_ metric.Float64Histogram = (*float64Inst)(nil)
|
||||
_ metric.Float64Gauge = (*float64Inst)(nil)
|
||||
_ x.EnabledInstrument = (*float64Inst)(nil)
|
||||
)
|
||||
|
||||
func (i *float64Inst) Add(ctx context.Context, val float64, opts ...metric.AddOption) {
|
||||
@ -234,6 +241,10 @@ func (i *float64Inst) Record(ctx context.Context, val float64, opts ...metric.Re
|
||||
i.aggregate(ctx, val, c.Attributes())
|
||||
}
|
||||
|
||||
func (i *float64Inst) Enabled(_ context.Context) bool {
|
||||
return len(i.measures) != 0
|
||||
}
|
||||
|
||||
func (i *float64Inst) aggregate(ctx context.Context, val float64, s attribute.Set) {
|
||||
for _, in := range i.measures {
|
||||
in(ctx, val, s)
|
||||
|
12
vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go
generated
vendored
12
vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go
generated
vendored
@ -50,16 +50,16 @@ type expoHistogramDataPoint[N int64 | float64] struct {
|
||||
|
||||
func newExpoHistogramDataPoint[N int64 | float64](attrs attribute.Set, maxSize int, maxScale int32, noMinMax, noSum bool) *expoHistogramDataPoint[N] {
|
||||
f := math.MaxFloat64
|
||||
max := N(f) // if N is int64, max will overflow to -9223372036854775808
|
||||
min := N(-f)
|
||||
ma := N(f) // if N is int64, max will overflow to -9223372036854775808
|
||||
mi := N(-f)
|
||||
if N(maxInt64) > N(f) {
|
||||
max = N(maxInt64)
|
||||
min = N(minInt64)
|
||||
ma = N(maxInt64)
|
||||
mi = N(minInt64)
|
||||
}
|
||||
return &expoHistogramDataPoint[N]{
|
||||
attrs: attrs,
|
||||
min: max,
|
||||
max: min,
|
||||
min: ma,
|
||||
max: mi,
|
||||
maxSize: maxSize,
|
||||
noMinMax: noMinMax,
|
||||
noSum: noSum,
|
||||
|
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).
|
||||
|
12
vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go
generated
vendored
12
vendor/go.opentelemetry.io/otel/sdk/metric/internal/x/x.go
generated
vendored
@ -8,6 +8,7 @@
|
||||
package x // import "go.opentelemetry.io/otel/sdk/metric/internal/x"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
@ -67,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
|
||||
}
|
||||
|
2
vendor/go.opentelemetry.io/otel/sdk/metric/meter.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/metric/meter.go
generated
vendored
@ -475,7 +475,7 @@ func (m *meter) RegisterCallback(f metric.Callback, insts ...metric.Observable)
|
||||
validInstruments = append(validInstruments, inst)
|
||||
default:
|
||||
// Instrument external to the SDK.
|
||||
return nil, fmt.Errorf("invalid observable: from different implementation")
|
||||
return nil, errors.New("invalid observable: from different implementation")
|
||||
}
|
||||
}
|
||||
|
||||
|
14
vendor/go.opentelemetry.io/otel/sdk/metric/reader.go
generated
vendored
14
vendor/go.opentelemetry.io/otel/sdk/metric/reader.go
generated
vendored
@ -5,26 +5,26 @@ package metric // import "go.opentelemetry.io/otel/sdk/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
|
||||
"go.opentelemetry.io/otel/sdk/metric/metricdata"
|
||||
)
|
||||
|
||||
// errDuplicateRegister is logged by a Reader when an attempt to registered it
|
||||
// more than once occurs.
|
||||
var errDuplicateRegister = fmt.Errorf("duplicate reader registration")
|
||||
var errDuplicateRegister = errors.New("duplicate reader registration")
|
||||
|
||||
// ErrReaderNotRegistered is returned if Collect or Shutdown are called before
|
||||
// the reader is registered with a MeterProvider.
|
||||
var ErrReaderNotRegistered = fmt.Errorf("reader is not registered")
|
||||
var ErrReaderNotRegistered = errors.New("reader is not registered")
|
||||
|
||||
// ErrReaderShutdown is returned if Collect or Shutdown are called after a
|
||||
// reader has been Shutdown once.
|
||||
var ErrReaderShutdown = fmt.Errorf("reader is shutdown")
|
||||
var ErrReaderShutdown = errors.New("reader is shutdown")
|
||||
|
||||
// errNonPositiveDuration is logged when an environmental variable
|
||||
// has non-positive value.
|
||||
var errNonPositiveDuration = fmt.Errorf("non-positive duration")
|
||||
var errNonPositiveDuration = errors.New("non-positive duration")
|
||||
|
||||
// Reader is the interface used between the SDK and an
|
||||
// exporter. Control flow is bi-directional through the
|
||||
@ -60,8 +60,8 @@ type Reader interface {
|
||||
aggregation(InstrumentKind) Aggregation // nolint:revive // import-shadow for method scoped by type.
|
||||
|
||||
// Collect gathers and returns all metric data related to the Reader from
|
||||
// the SDK and stores it in out. An error is returned if this is called
|
||||
// after Shutdown or if out is nil.
|
||||
// the SDK and stores it in rm. An error is returned if this is called
|
||||
// after Shutdown or if rm is nil.
|
||||
//
|
||||
// This method needs to be concurrent safe, and the cancellation of the
|
||||
// passed context is expected to be honored.
|
||||
|
2
vendor/go.opentelemetry.io/otel/sdk/metric/version.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/metric/version.go
generated
vendored
@ -5,5 +5,5 @@ package metric // import "go.opentelemetry.io/otel/sdk/metric"
|
||||
|
||||
// version is the current release version of the metric SDK in use.
|
||||
func version() string {
|
||||
return "1.32.0"
|
||||
return "1.33.0"
|
||||
}
|
||||
|
5
vendor/go.opentelemetry.io/otel/sdk/trace/sampler_env.go
generated
vendored
5
vendor/go.opentelemetry.io/otel/sdk/trace/sampler_env.go
generated
vendored
@ -5,7 +5,6 @@ package trace // import "go.opentelemetry.io/otel/sdk/trace"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -26,7 +25,7 @@ const (
|
||||
type errUnsupportedSampler string
|
||||
|
||||
func (e errUnsupportedSampler) Error() string {
|
||||
return fmt.Sprintf("unsupported sampler: %s", string(e))
|
||||
return "unsupported sampler: " + string(e)
|
||||
}
|
||||
|
||||
var (
|
||||
@ -39,7 +38,7 @@ type samplerArgParseError struct {
|
||||
}
|
||||
|
||||
func (e samplerArgParseError) Error() string {
|
||||
return fmt.Sprintf("parsing sampler argument: %s", e.parseErr.Error())
|
||||
return "parsing sampler argument: " + e.parseErr.Error()
|
||||
}
|
||||
|
||||
func (e samplerArgParseError) Unwrap() error {
|
||||
|
101
vendor/go.opentelemetry.io/otel/sdk/trace/span.go
generated
vendored
101
vendor/go.opentelemetry.io/otel/sdk/trace/span.go
generated
vendored
@ -347,54 +347,99 @@ func truncateAttr(limit int, attr attribute.KeyValue) attribute.KeyValue {
|
||||
}
|
||||
switch attr.Value.Type() {
|
||||
case attribute.STRING:
|
||||
if v := attr.Value.AsString(); len(v) > limit {
|
||||
return attr.Key.String(safeTruncate(v, limit))
|
||||
}
|
||||
v := attr.Value.AsString()
|
||||
return attr.Key.String(truncate(limit, v))
|
||||
case attribute.STRINGSLICE:
|
||||
v := attr.Value.AsStringSlice()
|
||||
for i := range v {
|
||||
if len(v[i]) > limit {
|
||||
v[i] = safeTruncate(v[i], limit)
|
||||
}
|
||||
v[i] = truncate(limit, v[i])
|
||||
}
|
||||
return attr.Key.StringSlice(v)
|
||||
}
|
||||
return attr
|
||||
}
|
||||
|
||||
// safeTruncate truncates the string and guarantees valid UTF-8 is returned.
|
||||
func safeTruncate(input string, limit int) string {
|
||||
if trunc, ok := safeTruncateValidUTF8(input, limit); ok {
|
||||
return trunc
|
||||
// truncate returns a truncated version of s such that it contains less than
|
||||
// the limit number of characters. Truncation is applied by returning the limit
|
||||
// number of valid characters contained in s.
|
||||
//
|
||||
// If limit is negative, it returns the original string.
|
||||
//
|
||||
// UTF-8 is supported. When truncating, all invalid characters are dropped
|
||||
// before applying truncation.
|
||||
//
|
||||
// If s already contains less than the limit number of bytes, it is returned
|
||||
// unchanged. No invalid characters are removed.
|
||||
func truncate(limit int, s string) string {
|
||||
// This prioritize performance in the following order based on the most
|
||||
// common expected use-cases.
|
||||
//
|
||||
// - Short values less than the default limit (128).
|
||||
// - Strings with valid encodings that exceed the limit.
|
||||
// - No limit.
|
||||
// - Strings with invalid encodings that exceed the limit.
|
||||
if limit < 0 || len(s) <= limit {
|
||||
return s
|
||||
}
|
||||
trunc, _ := safeTruncateValidUTF8(strings.ToValidUTF8(input, ""), limit)
|
||||
return trunc
|
||||
}
|
||||
|
||||
// safeTruncateValidUTF8 returns a copy of the input string safely truncated to
|
||||
// limit. The truncation is ensured to occur at the bounds of complete UTF-8
|
||||
// characters. If invalid encoding of UTF-8 is encountered, input is returned
|
||||
// with false, otherwise, the truncated input will be returned with true.
|
||||
func safeTruncateValidUTF8(input string, limit int) (string, bool) {
|
||||
for cnt := 0; cnt <= limit; {
|
||||
r, size := utf8.DecodeRuneInString(input[cnt:])
|
||||
if r == utf8.RuneError {
|
||||
return input, false
|
||||
// Optimistically, assume all valid UTF-8.
|
||||
var b strings.Builder
|
||||
count := 0
|
||||
for i, c := range s {
|
||||
if c != utf8.RuneError {
|
||||
count++
|
||||
if count > limit {
|
||||
return s[:i]
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if cnt+size > limit {
|
||||
return input[:cnt], true
|
||||
_, size := utf8.DecodeRuneInString(s[i:])
|
||||
if size == 1 {
|
||||
// Invalid encoding.
|
||||
b.Grow(len(s) - 1)
|
||||
_, _ = b.WriteString(s[:i])
|
||||
s = s[i:]
|
||||
break
|
||||
}
|
||||
cnt += size
|
||||
}
|
||||
return input, true
|
||||
|
||||
// Fast-path, no invalid input.
|
||||
if b.Cap() == 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
// Truncate while validating UTF-8.
|
||||
for i := 0; i < len(s) && count < limit; {
|
||||
c := s[i]
|
||||
if c < utf8.RuneSelf {
|
||||
// Optimization for single byte runes (common case).
|
||||
_ = b.WriteByte(c)
|
||||
i++
|
||||
count++
|
||||
continue
|
||||
}
|
||||
|
||||
_, size := utf8.DecodeRuneInString(s[i:])
|
||||
if size == 1 {
|
||||
// We checked for all 1-byte runes above, this is a RuneError.
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
_, _ = b.WriteString(s[i : i+size])
|
||||
i += size
|
||||
count++
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// End ends the span. This method does nothing if the span is already ended or
|
||||
// is not being recorded.
|
||||
//
|
||||
// The only SpanOption currently supported is WithTimestamp which will set the
|
||||
// end time for a Span's life-cycle.
|
||||
// The only SpanEndOption currently supported are [trace.WithTimestamp], and
|
||||
// [trace.WithStackTrace].
|
||||
//
|
||||
// If this method is called while panicking an error event is added to the
|
||||
// Span before ending it and the panic is continued.
|
||||
|
2
vendor/go.opentelemetry.io/otel/sdk/version.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/version.go
generated
vendored
@ -5,5 +5,5 @@ package sdk // import "go.opentelemetry.io/otel/sdk"
|
||||
|
||||
// Version is the current release version of the OpenTelemetry SDK in use.
|
||||
func Version() string {
|
||||
return "1.32.0"
|
||||
return "1.33.0"
|
||||
}
|
||||
|
Reference in New Issue
Block a user