mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-12 14:07:28 -06:00
[chore] Update usage of OTEL libraries (#2725)
* otel to 1.24 * prometheus exporter to 0.46 * bunotel to 1.1.17 Also: * Use schemaless URL for metrics * Add software version to tracing schema
This commit is contained in:
parent
8e88ee8d9c
commit
5e871e81a8
126 changed files with 12940 additions and 2267 deletions
25
vendor/go.opentelemetry.io/otel/sdk/resource/auto.go
generated
vendored
25
vendor/go.opentelemetry.io/otel/sdk/resource/auto.go
generated
vendored
|
|
@ -41,8 +41,20 @@ type Detector interface {
|
|||
// must never be done outside of a new major release.
|
||||
}
|
||||
|
||||
// Detect calls all input detectors sequentially and merges each result with the previous one.
|
||||
// It returns the merged error too.
|
||||
// Detect returns a new [Resource] merged from all the Resources each of the
|
||||
// detectors produces. Each of the detectors are called sequentially, in the
|
||||
// order they are passed, merging the produced resource into the previous.
|
||||
//
|
||||
// This may return a partial Resource along with an error containing
|
||||
// [ErrPartialResource] if that error is returned from a detector. It may also
|
||||
// return a merge-conflicting Resource along with an error containing
|
||||
// [ErrSchemaURLConflict] if merging Resources from different detectors results
|
||||
// in a schema URL conflict. It is up to the caller to determine if this
|
||||
// returned Resource should be used or not.
|
||||
//
|
||||
// If one of the detectors returns an error that is not [ErrPartialResource],
|
||||
// the resource produced by the detector will not be merged and the returned
|
||||
// error will wrap that detector's error.
|
||||
func Detect(ctx context.Context, detectors ...Detector) (*Resource, error) {
|
||||
r := new(Resource)
|
||||
return r, detect(ctx, r, detectors)
|
||||
|
|
@ -50,6 +62,10 @@ func Detect(ctx context.Context, detectors ...Detector) (*Resource, error) {
|
|||
|
||||
// detect runs all detectors using ctx and merges the result into res. This
|
||||
// assumes res is allocated and not nil, it will panic otherwise.
|
||||
//
|
||||
// If the detectors or merging resources produces any errors (i.e.
|
||||
// [ErrPartialResource] [ErrSchemaURLConflict]), a single error wrapping all of
|
||||
// these errors will be returned. Otherwise, nil is returned.
|
||||
func detect(ctx context.Context, res *Resource, detectors []Detector) error {
|
||||
var (
|
||||
r *Resource
|
||||
|
|
@ -78,6 +94,11 @@ func detect(ctx context.Context, res *Resource, detectors []Detector) error {
|
|||
if len(errs) == 0 {
|
||||
return nil
|
||||
}
|
||||
if errors.Is(errs, ErrSchemaURLConflict) {
|
||||
// If there has been a merge conflict, ensure the resource has no
|
||||
// schema URL.
|
||||
res.schemaURL = ""
|
||||
}
|
||||
return errs
|
||||
}
|
||||
|
||||
|
|
|
|||
2
vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go
generated
vendored
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/sdk"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
|
|||
4
vendor/go.opentelemetry.io/otel/sdk/resource/container.go
generated
vendored
4
vendor/go.opentelemetry.io/otel/sdk/resource/container.go
generated
vendored
|
|
@ -22,14 +22,14 @@ import (
|
|||
"os"
|
||||
"regexp"
|
||||
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
|
||||
)
|
||||
|
||||
type containerIDProvider func() (string, error)
|
||||
|
||||
var (
|
||||
containerID containerIDProvider = getContainerIDFromCGroup
|
||||
cgroupContainerIDRe = regexp.MustCompile(`^.*/(?:.*-)?([0-9a-f]+)(?:\.|\s*$)`)
|
||||
cgroupContainerIDRe = regexp.MustCompile(`^.*/(?:.*[-:])?([0-9a-f]+)(?:\.|\s*$)`)
|
||||
)
|
||||
|
||||
type cgroupContainerIDDetector struct{}
|
||||
|
|
|
|||
2
vendor/go.opentelemetry.io/otel/sdk/resource/env.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/resource/env.go
generated
vendored
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
2
vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go
generated
vendored
|
|
@ -19,7 +19,7 @@ import (
|
|||
"errors"
|
||||
"strings"
|
||||
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
|
||||
)
|
||||
|
||||
type hostIDProvider func() (string, error)
|
||||
|
|
|
|||
2
vendor/go.opentelemetry.io/otel/sdk/resource/os.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/resource/os.go
generated
vendored
|
|
@ -19,7 +19,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
|
||||
)
|
||||
|
||||
type osDescriptionProvider func() (string, error)
|
||||
|
|
|
|||
2
vendor/go.opentelemetry.io/otel/sdk/resource/process.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/resource/process.go
generated
vendored
|
|
@ -22,7 +22,7 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
|
|||
79
vendor/go.opentelemetry.io/otel/sdk/resource/resource.go
generated
vendored
79
vendor/go.opentelemetry.io/otel/sdk/resource/resource.go
generated
vendored
|
|
@ -17,6 +17,7 @@ package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
|
|
@ -40,9 +41,20 @@ var (
|
|||
defaultResourceOnce sync.Once
|
||||
)
|
||||
|
||||
var errMergeConflictSchemaURL = errors.New("cannot merge resource due to conflicting Schema URL")
|
||||
// ErrSchemaURLConflict is an error returned when two Resources are merged
|
||||
// together that contain different, non-empty, schema URLs.
|
||||
var ErrSchemaURLConflict = errors.New("conflicting Schema URL")
|
||||
|
||||
// New returns a Resource combined from the user-provided detectors.
|
||||
// New returns a [Resource] built using opts.
|
||||
//
|
||||
// This may return a partial Resource along with an error containing
|
||||
// [ErrPartialResource] if options that provide a [Detector] are used and that
|
||||
// error is returned from one or more of the Detectors. It may also return a
|
||||
// merge-conflict Resource along with an error containing
|
||||
// [ErrSchemaURLConflict] if merging Resources from the opts results in a
|
||||
// schema URL conflict (see [Resource.Merge] for more information). It is up to
|
||||
// the caller to determine if this returned Resource should be used or not
|
||||
// based on these errors.
|
||||
func New(ctx context.Context, opts ...Option) (*Resource, error) {
|
||||
cfg := config{}
|
||||
for _, opt := range opts {
|
||||
|
|
@ -98,7 +110,7 @@ func (r *Resource) String() string {
|
|||
return r.attrs.Encoded(attribute.DefaultEncoder())
|
||||
}
|
||||
|
||||
// MarshalLog is the marshaling function used by the logging system to represent this exporter.
|
||||
// MarshalLog is the marshaling function used by the logging system to represent this Resource.
|
||||
func (r *Resource) MarshalLog() interface{} {
|
||||
return struct {
|
||||
Attributes attribute.Set
|
||||
|
|
@ -146,16 +158,29 @@ func (r *Resource) Equal(eq *Resource) bool {
|
|||
return r.Equivalent() == eq.Equivalent()
|
||||
}
|
||||
|
||||
// Merge creates a new resource by combining resource a and b.
|
||||
// Merge creates a new [Resource] by merging a and b.
|
||||
//
|
||||
// If there are common keys between resource a and b, then the value
|
||||
// from resource b will overwrite the value from resource a, even
|
||||
// if resource b's value is empty.
|
||||
// If there are common keys between a and b, then the value from b will
|
||||
// overwrite the value from a, even if b's value is empty.
|
||||
//
|
||||
// The SchemaURL of the resources will be merged according to the spec rules:
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/resource/sdk.md#merge
|
||||
// If the resources have different non-empty schemaURL an empty resource and an error
|
||||
// will be returned.
|
||||
// The SchemaURL of the resources will be merged according to the
|
||||
// [OpenTelemetry specification rules]:
|
||||
//
|
||||
// - If a's schema URL is empty then the returned Resource's schema URL will
|
||||
// be set to the schema URL of b,
|
||||
// - Else if b's schema URL is empty then the returned Resource's schema URL
|
||||
// will be set to the schema URL of a,
|
||||
// - Else if the schema URLs of a and b are the same then that will be the
|
||||
// schema URL of the returned Resource,
|
||||
// - Else this is a merging error. If the resources have different,
|
||||
// non-empty, schema URLs an error containing [ErrSchemaURLConflict] will
|
||||
// be returned with the merged Resource. The merged Resource will have an
|
||||
// empty schema URL. It may be the case that some unintended attributes
|
||||
// have been overwritten or old semantic conventions persisted in the
|
||||
// returned Resource. It is up to the caller to determine if this returned
|
||||
// Resource should be used or not.
|
||||
//
|
||||
// [OpenTelemetry specification rules]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/resource/sdk.md#merge
|
||||
func Merge(a, b *Resource) (*Resource, error) {
|
||||
if a == nil && b == nil {
|
||||
return Empty(), nil
|
||||
|
|
@ -167,19 +192,6 @@ func Merge(a, b *Resource) (*Resource, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
// Merge the schema URL.
|
||||
var schemaURL string
|
||||
switch true {
|
||||
case a.schemaURL == "":
|
||||
schemaURL = b.schemaURL
|
||||
case b.schemaURL == "":
|
||||
schemaURL = a.schemaURL
|
||||
case a.schemaURL == b.schemaURL:
|
||||
schemaURL = a.schemaURL
|
||||
default:
|
||||
return Empty(), errMergeConflictSchemaURL
|
||||
}
|
||||
|
||||
// Note: 'b' attributes will overwrite 'a' with last-value-wins in attribute.Key()
|
||||
// Meaning this is equivalent to: append(a.Attributes(), b.Attributes()...)
|
||||
mi := attribute.NewMergeIterator(b.Set(), a.Set())
|
||||
|
|
@ -187,8 +199,23 @@ func Merge(a, b *Resource) (*Resource, error) {
|
|||
for mi.Next() {
|
||||
combine = append(combine, mi.Attribute())
|
||||
}
|
||||
merged := NewWithAttributes(schemaURL, combine...)
|
||||
return merged, nil
|
||||
|
||||
switch {
|
||||
case a.schemaURL == "":
|
||||
return NewWithAttributes(b.schemaURL, combine...), nil
|
||||
case b.schemaURL == "":
|
||||
return NewWithAttributes(a.schemaURL, combine...), nil
|
||||
case a.schemaURL == b.schemaURL:
|
||||
return NewWithAttributes(a.schemaURL, combine...), nil
|
||||
}
|
||||
// Return the merged resource with an appropriate error. It is up to
|
||||
// the user to decide if the returned resource can be used or not.
|
||||
return NewSchemaless(combine...), fmt.Errorf(
|
||||
"%w: %s and %s",
|
||||
ErrSchemaURLConflict,
|
||||
a.schemaURL,
|
||||
b.schemaURL,
|
||||
)
|
||||
}
|
||||
|
||||
// Empty returns an instance of Resource with no attributes. It is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue