diff options
| author | 2025-05-06 08:18:05 +0000 | |
|---|---|---|
| committer | 2025-05-06 08:18:05 +0000 | |
| commit | 90a5425fe9776a18ea9a8d2b6ec98dc36a9117af (patch) | |
| tree | fe6a0eb8569d369a8180cca24c9578b66cf8fef2 /vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go | |
| parent | [bugfix] Fixes to tablist, fileinput, checkbox (#4139) (diff) | |
| download | gotosocial-90a5425fe9776a18ea9a8d2b6ec98dc36a9117af.tar.xz | |
[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>
Diffstat (limited to 'vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go')
| -rw-r--r-- | vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go b/vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go new file mode 100644 index 000000000..7ffb473ad --- /dev/null +++ b/vendor/go.opentelemetry.io/contrib/instrumentation/runtime/internal/x/x.go @@ -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 +} |
