Fixed datadog logs json format issue
This commit is contained in:
parent
dae0491b61
commit
e77a66c2ac
2 changed files with 17 additions and 0 deletions
13
pkg/log/datadog.go
Normal file
13
pkg/log/datadog.go
Normal 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)
|
||||||
|
}
|
|
@ -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 != "" {
|
||||||
|
|
Loading…
Reference in a new issue