From e77a66c2ac99c5ff9754dcaa6df5008df77a27b3 Mon Sep 17 00:00:00 2001 From: Suyash Choudhary <57896905+sssash18@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:06:05 +0530 Subject: [PATCH] Fixed datadog logs json format issue --- pkg/log/datadog.go | 13 +++++++++++++ pkg/tracing/datadog/datadog.go | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 pkg/log/datadog.go diff --git a/pkg/log/datadog.go b/pkg/log/datadog.go new file mode 100644 index 000000000..dda0fed5d --- /dev/null +++ b/pkg/log/datadog.go @@ -0,0 +1,13 @@ +package log + +type DatadogLogger struct { + logger Logger +} + +func NewDatadogLogger(logger Logger) *DatadogLogger { + return &DatadogLogger{logger: logger} +} + +func (d DatadogLogger) Log(msg string) { + d.logger.Debug(msg) +} diff --git a/pkg/tracing/datadog/datadog.go b/pkg/tracing/datadog/datadog.go index b0c32643f..30e99fcda 100644 --- a/pkg/tracing/datadog/datadog.go +++ b/pkg/tracing/datadog/datadog.go @@ -1,6 +1,7 @@ package datadog import ( + "context" "io" "net" "os" @@ -47,6 +48,8 @@ func (c *Config) SetDefaults() { // Setup sets up the tracer. func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error) { + ctx := log.With(context.Background(), log.Str(log.MetricsProviderName, "datadog")) + opts := []datadog.StartOption{ datadog.WithService(serviceName), datadog.WithDebugMode(c.Debug), @@ -56,6 +59,7 @@ func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error PriorityHeader: c.SamplingPriorityHeaderName, BaggagePrefix: c.BagagePrefixHeaderName, })), + datadog.WithLogger(log.NewDatadogLogger(log.FromContext(ctx))), } if c.LocalAgentSocket != "" {