mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-17 14:37:34 -06:00
[chore] Simplify the OTEL setup (#4110)
# Description This simplifies our OTEL setup by: * Getting rid of some deprecated things. * Using `autoexport` and letting things get configured by the `OTEL_` environment variables. * Removing all the unnecessary config options. ## Checklist Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]` If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want). - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [ ] I/we have commented the added code, particularly in hard-to-understand areas. - [x] I/we have made any necessary changes to documentation. - [ ] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4110 Reviewed-by: tobi <kipvandenbos@noreply.codeberg.org> Co-authored-by: Daenney <daenney@noreply.codeberg.org> Co-committed-by: Daenney <daenney@noreply.codeberg.org>
This commit is contained in:
parent
ad71066973
commit
ecbdc4227b
145 changed files with 21740 additions and 1319 deletions
140
vendor/go.opentelemetry.io/otel/log/logger.go
generated
vendored
Normal file
140
vendor/go.opentelemetry.io/otel/log/logger.go
generated
vendored
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package log // import "go.opentelemetry.io/otel/log"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/log/embedded"
|
||||
)
|
||||
|
||||
// Logger emits log records.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Logger interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Logger
|
||||
|
||||
// Emit emits a log record.
|
||||
//
|
||||
// The record may be held by the implementation. Callers should not mutate
|
||||
// the record after passed.
|
||||
//
|
||||
// Implementations of this method need to be safe for a user to call
|
||||
// concurrently.
|
||||
Emit(ctx context.Context, record Record)
|
||||
|
||||
// Enabled returns whether the Logger emits for the given context and
|
||||
// param.
|
||||
//
|
||||
// This is useful for users that want to know if a [Record]
|
||||
// will be processed or dropped before they perform complex operations to
|
||||
// construct the [Record].
|
||||
//
|
||||
// The passed param is likely to be a partial record information being
|
||||
// provided (e.g a param with only the Severity set).
|
||||
// If a Logger needs more information than is provided, it
|
||||
// is said to be in an indeterminate state (see below).
|
||||
//
|
||||
// The returned value will be true when the Logger will emit for the
|
||||
// provided context and param, and will be false if the Logger will not
|
||||
// emit. The returned value may be true or false in an indeterminate state.
|
||||
// An implementation should default to returning true for an indeterminate
|
||||
// state, but may return false if valid reasons in particular circumstances
|
||||
// exist (e.g. performance, correctness).
|
||||
//
|
||||
// The param should not be held by the implementation. A copy should be
|
||||
// made if the param needs to be held after the call returns.
|
||||
//
|
||||
// Implementations of this method need to be safe for a user to call
|
||||
// concurrently.
|
||||
Enabled(ctx context.Context, param EnabledParameters) bool
|
||||
}
|
||||
|
||||
// LoggerOption applies configuration options to a [Logger].
|
||||
type LoggerOption interface {
|
||||
// applyLogger is used to set a LoggerOption value of a LoggerConfig.
|
||||
applyLogger(LoggerConfig) LoggerConfig
|
||||
}
|
||||
|
||||
// LoggerConfig contains options for a [Logger].
|
||||
type LoggerConfig struct {
|
||||
// Ensure forward compatibility by explicitly making this not comparable.
|
||||
noCmp [0]func() //nolint: unused // This is indeed used.
|
||||
|
||||
version string
|
||||
schemaURL string
|
||||
attrs attribute.Set
|
||||
}
|
||||
|
||||
// NewLoggerConfig returns a new [LoggerConfig] with all the options applied.
|
||||
func NewLoggerConfig(options ...LoggerOption) LoggerConfig {
|
||||
var c LoggerConfig
|
||||
for _, opt := range options {
|
||||
c = opt.applyLogger(c)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// InstrumentationVersion returns the version of the library providing
|
||||
// instrumentation.
|
||||
func (cfg LoggerConfig) InstrumentationVersion() string {
|
||||
return cfg.version
|
||||
}
|
||||
|
||||
// InstrumentationAttributes returns the attributes associated with the library
|
||||
// providing instrumentation.
|
||||
func (cfg LoggerConfig) InstrumentationAttributes() attribute.Set {
|
||||
return cfg.attrs
|
||||
}
|
||||
|
||||
// SchemaURL returns the schema URL of the library providing instrumentation.
|
||||
func (cfg LoggerConfig) SchemaURL() string {
|
||||
return cfg.schemaURL
|
||||
}
|
||||
|
||||
type loggerOptionFunc func(LoggerConfig) LoggerConfig
|
||||
|
||||
func (fn loggerOptionFunc) applyLogger(cfg LoggerConfig) LoggerConfig {
|
||||
return fn(cfg)
|
||||
}
|
||||
|
||||
// WithInstrumentationVersion returns a [LoggerOption] that sets the
|
||||
// instrumentation version of a [Logger].
|
||||
func WithInstrumentationVersion(version string) LoggerOption {
|
||||
return loggerOptionFunc(func(config LoggerConfig) LoggerConfig {
|
||||
config.version = version
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
// WithInstrumentationAttributes returns a [LoggerOption] that sets the
|
||||
// instrumentation attributes of a [Logger].
|
||||
//
|
||||
// The passed attributes will be de-duplicated.
|
||||
func WithInstrumentationAttributes(attr ...attribute.KeyValue) LoggerOption {
|
||||
return loggerOptionFunc(func(config LoggerConfig) LoggerConfig {
|
||||
config.attrs = attribute.NewSet(attr...)
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
// WithSchemaURL returns a [LoggerOption] that sets the schema URL for a
|
||||
// [Logger].
|
||||
func WithSchemaURL(schemaURL string) LoggerOption {
|
||||
return loggerOptionFunc(func(config LoggerConfig) LoggerConfig {
|
||||
config.schemaURL = schemaURL
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
// EnabledParameters represents payload for [Logger]'s Enabled method.
|
||||
type EnabledParameters struct {
|
||||
Severity Severity
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue