mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
chore(gomod): update otel to 1.0.0 (#2414)
This commit is contained in:
@@ -3,6 +3,8 @@ package metrics
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -93,9 +95,9 @@ func (h *Handler) containsMetricsMethod(method MetricType) bool {
|
||||
}
|
||||
|
||||
func RegisterRequestCounter(r *http.Request) {
|
||||
var labels = map[string]interface{}{
|
||||
URI: strings.Split(r.RequestURI, "?")[0],
|
||||
Method: r.Method,
|
||||
var labels = map[string]attribute.Value{
|
||||
URI: attribute.StringValue(strings.Split(r.RequestURI, "?")[0]),
|
||||
Method: attribute.StringValue(r.Method),
|
||||
}
|
||||
RegisterCounter(RequestCounter, RequestCountDescription)
|
||||
AddCount(r.Context(), RequestCounter, 1, labels)
|
||||
@@ -107,10 +109,10 @@ func RegisterTotalRequestCounter(r *http.Request) {
|
||||
}
|
||||
|
||||
func RegisterRequestCodeCounter(recorder *StatusRecorder, r *http.Request) {
|
||||
var labels = map[string]interface{}{
|
||||
URI: strings.Split(r.RequestURI, "?")[0],
|
||||
Method: r.Method,
|
||||
ReturnCode: recorder.Status,
|
||||
var labels = map[string]attribute.Value{
|
||||
URI: attribute.StringValue(strings.Split(r.RequestURI, "?")[0]),
|
||||
Method: attribute.StringValue(r.Method),
|
||||
ReturnCode: attribute.IntValue(recorder.Status),
|
||||
}
|
||||
RegisterCounter(ReturnCodeCounter, ReturnCodeCounterDescription)
|
||||
AddCount(r.Context(), ReturnCodeCounter, 1, labels)
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
||||
@@ -20,7 +21,7 @@ type Metrics interface {
|
||||
GetExporter() http.Handler
|
||||
GetMetricsProvider() metric.MeterProvider
|
||||
RegisterCounter(name, description string) error
|
||||
AddCount(ctx context.Context, name string, value int64, labels map[string]interface{}) error
|
||||
AddCount(ctx context.Context, name string, value int64, labels map[string]attribute.Value) error
|
||||
RegisterUpDownSumObserver(name, description string, callbackFunc metric.Int64ObserverFunc) error
|
||||
RegisterValueObserver(name, description string, callbackFunc metric.Int64ObserverFunc) error
|
||||
}
|
||||
@@ -52,7 +53,7 @@ func RegisterCounter(name, description string) error {
|
||||
return M.RegisterCounter(name, description)
|
||||
}
|
||||
|
||||
func AddCount(ctx context.Context, name string, value int64, labels map[string]interface{}) error {
|
||||
func AddCount(ctx context.Context, name string, value int64, labels map[string]attribute.Value) error {
|
||||
if M == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
label "go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/exporters/prometheus"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
export "go.opentelemetry.io/otel/sdk/export/metric"
|
||||
@@ -62,7 +62,7 @@ func (m *Metrics) RegisterCounter(name, description string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Metrics) AddCount(ctx context.Context, name string, value int64, labels map[string]interface{}) error {
|
||||
func (m *Metrics) AddCount(ctx context.Context, name string, value int64, labels map[string]attribute.Value) error {
|
||||
counter, exists := m.Counters.Load(name)
|
||||
if !exists {
|
||||
return caos_errs.ThrowNotFound(nil, "METER-4u8fs", "Errors.Metrics.Counter.NotFound")
|
||||
@@ -93,13 +93,16 @@ func (m *Metrics) RegisterValueObserver(name, description string, callbackFunc m
|
||||
return nil
|
||||
}
|
||||
|
||||
func MapToKeyValue(labels map[string]interface{}) []label.KeyValue {
|
||||
func MapToKeyValue(labels map[string]attribute.Value) []attribute.KeyValue {
|
||||
if labels == nil {
|
||||
return nil
|
||||
}
|
||||
keyValues := make([]label.KeyValue, 0, len(labels))
|
||||
keyValues := make([]attribute.KeyValue, 0, len(labels))
|
||||
for key, value := range labels {
|
||||
keyValues = append(keyValues, label.Any(key, value))
|
||||
keyValues = append(keyValues, attribute.KeyValue{
|
||||
Key: attribute.Key(key),
|
||||
Value: value,
|
||||
})
|
||||
}
|
||||
return keyValues
|
||||
}
|
||||
|
Reference in New Issue
Block a user