summaryrefslogtreecommitdiff
path: root/vendor/github.com/prometheus/otlptranslator/strconv.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-07-22 18:00:27 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-07-22 18:00:27 +0200
commitc00cad2cebcb8136a998f6f7ba2c27672f785d10 (patch)
tree863516d8459713cc4b91c83d8aeeef3cac486b39 /vendor/github.com/prometheus/otlptranslator/strconv.go
parent[chore/deps] Upgrade to go-sqlite 0.27.1 (#4334) (diff)
downloadgotosocial-c00cad2cebcb8136a998f6f7ba2c27672f785d10.tar.xz
[chore] bump dependencies (#4339)
- github.com/KimMachineGun/automemlimit v0.7.4 - github.com/miekg/dns v1.1.67 - github.com/minio/minio-go/v7 v7.0.95 - github.com/spf13/pflag v1.0.7 - github.com/tdewolff/minify/v2 v2.23.9 - github.com/uptrace/bun v1.2.15 - github.com/uptrace/bun/dialect/pgdialect v1.2.15 - github.com/uptrace/bun/dialect/sqlitedialect v1.2.15 - github.com/uptrace/bun/extra/bunotel v1.2.15 - golang.org/x/image v0.29.0 - golang.org/x/net v0.42.0 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4339 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/prometheus/otlptranslator/strconv.go')
-rw-r--r--vendor/github.com/prometheus/otlptranslator/strconv.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/github.com/prometheus/otlptranslator/strconv.go b/vendor/github.com/prometheus/otlptranslator/strconv.go
new file mode 100644
index 000000000..81d534e8d
--- /dev/null
+++ b/vendor/github.com/prometheus/otlptranslator/strconv.go
@@ -0,0 +1,42 @@
+// Copyright 2025 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// Provenance-includes-location: https://github.com/prometheus/prometheus/blob/93e991ef7ed19cc997a9360c8016cac3767b8057/storage/remote/otlptranslator/prometheus/strconv.go.go
+// Provenance-includes-license: Apache-2.0
+// Provenance-includes-copyright: Copyright The Prometheus Authors
+// Provenance-includes-location: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/95e8f8fdc2a9dc87230406c9a3cf02be4fd68bea/pkg/translator/prometheus/normalize_name_test.go
+// Provenance-includes-license: Apache-2.0
+// Provenance-includes-copyright: Copyright The OpenTelemetry Authors.
+
+package otlptranslator
+
+import (
+ "strings"
+)
+
+// sanitizeLabelName replaces any characters not valid according to the
+// classical Prometheus label naming scheme with an underscore.
+// Note: this does not handle all Prometheus label name restrictions (such as
+// not starting with a digit 0-9), and hence should only be used if the label
+// name is prefixed with a known valid string.
+func sanitizeLabelName(name string) string {
+ var b strings.Builder
+ b.Grow(len(name))
+ for _, r := range name {
+ if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9') {
+ b.WriteRune(r)
+ } else {
+ b.WriteRune('_')
+ }
+ }
+ return b.String()
+}