Fixed datadog logs json format issue

This commit is contained in:
Suyash Choudhary 2023-12-06 19:06:05 +05:30 committed by GitHub
parent dae0491b61
commit e77a66c2ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

13
pkg/log/datadog.go Normal file
View file

@ -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)
}

View file

@ -1,6 +1,7 @@
package datadog package datadog
import ( import (
"context"
"io" "io"
"net" "net"
"os" "os"
@ -47,6 +48,8 @@ func (c *Config) SetDefaults() {
// Setup sets up the tracer. // Setup sets up the tracer.
func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error) { func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error) {
ctx := log.With(context.Background(), log.Str(log.MetricsProviderName, "datadog"))
opts := []datadog.StartOption{ opts := []datadog.StartOption{
datadog.WithService(serviceName), datadog.WithService(serviceName),
datadog.WithDebugMode(c.Debug), datadog.WithDebugMode(c.Debug),
@ -56,6 +59,7 @@ func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error
PriorityHeader: c.SamplingPriorityHeaderName, PriorityHeader: c.SamplingPriorityHeaderName,
BaggagePrefix: c.BagagePrefixHeaderName, BaggagePrefix: c.BagagePrefixHeaderName,
})), })),
datadog.WithLogger(log.NewDatadogLogger(log.FromContext(ctx))),
} }
if c.LocalAgentSocket != "" { if c.LocalAgentSocket != "" {