mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-08 11:11:10 -06:00
[chore] Add Go runtime and host metrics (#4137)
Daenney is a dummy and forgot to add these when he revamped the OTEL stuff. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4137 Co-authored-by: Daenney <daenney@noreply.codeberg.org> Co-committed-by: Daenney <daenney@noreply.codeberg.org>
This commit is contained in:
parent
4a6b357501
commit
90a5425fe9
14 changed files with 1124 additions and 0 deletions
38
vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/README.md
generated
vendored
Normal file
38
vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Feature Gates
|
||||
|
||||
The runtime package contains a feature gate used to ease the migration
|
||||
from the [previous runtime metrics conventions] to the new [OpenTelemetry Go
|
||||
Runtime conventions].
|
||||
|
||||
Note that the new runtime metrics conventions are still experimental, and may
|
||||
change in backwards incompatible ways as feedback is applied.
|
||||
|
||||
## Features
|
||||
|
||||
- [Include Deprecated Metrics](#include-deprecated-metrics)
|
||||
|
||||
### Include Deprecated Metrics
|
||||
|
||||
Once new experimental runtime metrics are added, they will be produced
|
||||
**in addition to** the existing runtime metrics. Users that migrate right away
|
||||
can disable the old runtime metrics:
|
||||
|
||||
```console
|
||||
export OTEL_GO_X_DEPRECATED_RUNTIME_METRICS=false
|
||||
```
|
||||
|
||||
In a later release, the deprecated runtime metrics will stop being produced by
|
||||
default. To temporarily re-enable the deprecated metrics:
|
||||
|
||||
```console
|
||||
export OTEL_GO_X_DEPRECATED_RUNTIME_METRICS=true
|
||||
```
|
||||
|
||||
After two additional releases, the deprecated runtime metrics will be removed,
|
||||
and setting the environment variable will no longer have any effect.
|
||||
|
||||
The value set must be the case-insensitive string of `"true"` to enable the
|
||||
feature, and `"false"` to disable the feature. All other values are ignored.
|
||||
|
||||
[previous runtime metrics conventions]: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/runtime@v0.52.0
|
||||
[OpenTelemetry Go Runtime conventions]: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/runtime/go-metrics.md
|
||||
53
vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go
generated
vendored
Normal file
53
vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package x contains support for OTel runtime instrumentation experimental features.
|
||||
//
|
||||
// This package should only be used for features defined in the specification.
|
||||
// It should not be used for experiments or new project ideas.
|
||||
package x // import "go.opentelemetry.io/contrib/instrumentation/runtime/internal/x"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DeprecatedRuntimeMetrics is an experimental feature flag that defines if the deprecated
|
||||
// runtime metrics should be produced. During development of the new
|
||||
// conventions, it is enabled by default.
|
||||
//
|
||||
// To disable this feature set the OTEL_GO_X_DEPRECATED_RUNTIME_METRICS environment variable
|
||||
// to the case-insensitive string value of "false" (i.e. "False" and "FALSE"
|
||||
// will also enable this).
|
||||
var DeprecatedRuntimeMetrics = newFeature("DEPRECATED_RUNTIME_METRICS", true)
|
||||
|
||||
// BoolFeature is an experimental feature control flag. It provides a uniform way
|
||||
// to interact with these feature flags and parse their values.
|
||||
type BoolFeature struct {
|
||||
key string
|
||||
defaultVal bool
|
||||
}
|
||||
|
||||
func newFeature(suffix string, defaultVal bool) BoolFeature {
|
||||
const envKeyRoot = "OTEL_GO_X_"
|
||||
return BoolFeature{
|
||||
key: envKeyRoot + suffix,
|
||||
defaultVal: defaultVal,
|
||||
}
|
||||
}
|
||||
|
||||
// Key returns the environment variable key that needs to be set to enable the
|
||||
// feature.
|
||||
func (f BoolFeature) Key() string { return f.key }
|
||||
|
||||
// Enabled returns if the feature is enabled.
|
||||
func (f BoolFeature) Enabled() bool {
|
||||
v := os.Getenv(f.key)
|
||||
if strings.ToLower(v) == "false" {
|
||||
return false
|
||||
}
|
||||
if strings.ToLower(v) == "true" {
|
||||
return true
|
||||
}
|
||||
return f.defaultVal
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue