From 360eab94e33e7cc600d3e9f60c414ff132aec80c Mon Sep 17 00:00:00 2001 From: Sheridan C Rawlins Date: Thu, 12 Dec 2024 23:18:01 -0800 Subject: [PATCH] Ditch use of slog for now (until #4103). --- metrics/config/metrics.go | 4 ++-- metrics/opentelemetry/engine.go | 6 +++--- metrics/opentelemetry/metrics.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/metrics/config/metrics.go b/metrics/config/metrics.go index 3312f6dbd6..3d823c8446 100644 --- a/metrics/config/metrics.go +++ b/metrics/config/metrics.go @@ -1,9 +1,9 @@ package config import ( - "log/slog" "time" + "github.com/golang/glog" "github.com/prebid/prebid-server/v3/config" "github.com/prebid/prebid-server/v3/metrics" "github.com/prebid/prebid-server/v3/metrics/opentelemetry" @@ -48,7 +48,7 @@ func NewMetricsEngine(cfg *config.Configuration, adapterList []openrtb_ext.Bidde if cfg.Metrics.Otel.Enabled { otelEngine, err := opentelemetry.NewEngine(cfg.Metrics.Otel.Prefix, &cfg.Metrics.Disabled) if err != nil { - slog.Error("error creating otel engine", "err", err.Error()) + glog.Error("error creating otel engine: %v", err) } engineList = append(engineList, otelEngine) } diff --git a/metrics/opentelemetry/engine.go b/metrics/opentelemetry/engine.go index 9cbc9fc2dc..06228a6307 100644 --- a/metrics/opentelemetry/engine.go +++ b/metrics/opentelemetry/engine.go @@ -2,10 +2,10 @@ package opentelemetry import ( "context" - "log/slog" "strings" "time" + "github.com/golang/glog" "github.com/prebid/prebid-server/v3/config" "github.com/prebid/prebid-server/v3/metrics" "github.com/prebid/prebid-server/v3/openrtb_ext" @@ -401,7 +401,7 @@ func (o *PbsMetricsEngine) RecordStoredDataFetchTime(labels metrics.StoredDataLa case metrics.ResponseDataType: histogramPtr = &o.StoredResponsesFetchTime default: - slog.DebugContext(ctx, "unknown data type", "dataType", labels.DataType) + glog.Error("unknown data type: %v", labels.DataType) return } // Record the chosen histogram @@ -427,7 +427,7 @@ func (o *PbsMetricsEngine) RecordStoredDataError(labels metrics.StoredDataLabels case metrics.ResponseDataType: counterPtr = &o.StoredResponsesErrors default: - slog.DebugContext(ctx, "unknown data type", "dataType", labels.DataType) + glog.Error(ctx, "unknown data type: %v", labels.DataType) return } // Record the chosen histogram diff --git a/metrics/opentelemetry/metrics.go b/metrics/opentelemetry/metrics.go index 3f4b8b29fe..7b3d0648c0 100644 --- a/metrics/opentelemetry/metrics.go +++ b/metrics/opentelemetry/metrics.go @@ -3,12 +3,12 @@ package opentelemetry import ( "errors" "fmt" - "log/slog" "reflect" "strconv" "strings" "github.com/gobeam/stringy" + "github.com/golang/glog" "go.opentelemetry.io/otel/metric" ) @@ -85,7 +85,7 @@ func HistogramOptions(elem Elem) []metric.HistogramOption { var err error for i, s := range floatStrings { if floats[i], err = strconv.ParseFloat(s, 64); err != nil { - slog.Error("failed to parse bucket boundary", "boundary", s, "err", err.Error()) + glog.Error("failed to parse bucket boundary: %s: %v", s, err) return nil } } @@ -113,7 +113,7 @@ func InitMetrics(meter metric.Meter, m any, prefix string) error { // possibly with altered Name or Tags. func InitMetricElem(meter metric.Meter, elem Elem, prefix string) error { if elem.Tag.Get("metric") == "-" { - slog.Debug("skipping metric", "name", elem.Name) + glog.Info("skipping metric: %s", elem.Name) return nil } var opts []metric.InstrumentOption @@ -142,7 +142,7 @@ func InitMetricElem(meter metric.Meter, elem Elem, prefix string) error { case "metric.Float64Histogram": m, err = CreateHistogramMetric(metricName, meter.Float64Histogram, HistogramOptions(elem), opts...) default: - slog.Warn("unknown metric type; skipping", "type", elem.Value.Type().String()) + glog.Error("unknown metric type; skipping: %s", elem.Value.Type().String()) return nil } if err != nil {