From ea934289ce9db3cb41d92a34f88bd4a19f4470dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Casta=C3=B1=C3=A9?= Date: Mon, 2 Dec 2024 17:28:12 +0100 Subject: [PATCH] fix(ddtrace/tracer): avoid tests to fail with error "non-constant format string" from upcoming go 1.24 release --- ddtrace/tracer/abandonedspans.go | 2 +- ddtrace/tracer/option_test.go | 2 +- ddtrace/tracer/otel_dd_mappings.go | 2 +- ddtrace/tracer/slog.go | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ddtrace/tracer/abandonedspans.go b/ddtrace/tracer/abandonedspans.go index defad41831..e94b0ec39e 100644 --- a/ddtrace/tracer/abandonedspans.go +++ b/ddtrace/tracer/abandonedspans.go @@ -273,7 +273,7 @@ func (d *abandonedSpansDebugger) log(interval *time.Duration) { log.Warn("Too many abandoned spans. Truncating message.") sb.WriteString("...") } - log.Warn(sb.String()) + log.Warn("%s", sb.String()) } // formatAbandonedSpans takes a bucket and returns a human-readable string representing diff --git a/ddtrace/tracer/option_test.go b/ddtrace/tracer/option_test.go index d915cb45b7..8e3a6262f7 100644 --- a/ddtrace/tracer/option_test.go +++ b/ddtrace/tracer/option_test.go @@ -338,7 +338,7 @@ func TestIntegrationEnabled(t *testing.T) { var out contribPkg err := stream.Decode(&out) if err != nil { - t.Fatalf(err.Error()) + t.Fatal(err.Error()) } packages = append(packages, out) } diff --git a/ddtrace/tracer/otel_dd_mappings.go b/ddtrace/tracer/otel_dd_mappings.go index 1b17d86560..ec8ebb10ee 100644 --- a/ddtrace/tracer/otel_dd_mappings.go +++ b/ddtrace/tracer/otel_dd_mappings.go @@ -98,7 +98,7 @@ func getDDorOtelConfig(configName string) string { } else { v, err := config.remapper(otVal) if err != nil { - log.Warn(err.Error()) + log.Warn("%s", err.Error()) telemetryTags := []string{ddPrefix + strings.ToLower(config.dd), otelPrefix + strings.ToLower(config.ot)} telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.invalid", 1.0, telemetryTags, true) } diff --git a/ddtrace/tracer/slog.go b/ddtrace/tracer/slog.go index 06a477d02d..02523bc23b 100644 --- a/ddtrace/tracer/slog.go +++ b/ddtrace/tracer/slog.go @@ -41,13 +41,13 @@ func (h slogHandler) Handle(ctx context.Context, r slog.Record) error { msg := strings.Join(parts, " ") switch r.Level { case slog.LevelDebug: - log.Debug(msg) + log.Debug("%s", msg) case slog.LevelInfo: - log.Info(msg) + log.Info("%s", msg) case slog.LevelWarn: - log.Warn(msg) + log.Warn("%s", msg) case slog.LevelError: - log.Error(msg) + log.Error("%s", msg) } return nil }