From 08b9103cac39fd1cdbae415cfb52235f64f45ebf Mon Sep 17 00:00:00 2001 From: Yang Song Date: Mon, 9 Dec 2024 16:14:37 -0500 Subject: [PATCH] [pkg/otlp/logs] upgrade datadog-api-client-go version --- pkg/otlp/logs/go.mod | 4 +++- pkg/otlp/logs/go.sum | 14 +++++++++++-- pkg/otlp/logs/transform.go | 2 +- pkg/otlp/logs/transform_test.go | 36 ++++++++++++++++----------------- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/pkg/otlp/logs/go.mod b/pkg/otlp/logs/go.mod index 6b9586b1..ca428ab5 100644 --- a/pkg/otlp/logs/go.mod +++ b/pkg/otlp/logs/go.mod @@ -3,7 +3,7 @@ module github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/logs go 1.20 require ( - github.com/DataDog/datadog-api-client-go/v2 v2.13.0 + github.com/DataDog/datadog-api-client-go/v2 v2.33.0 github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.21.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.94.1 @@ -21,8 +21,10 @@ require ( github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/knadh/koanf/maps v0.1.1 // indirect github.com/knadh/koanf/providers/confmap v0.1.0 // indirect diff --git a/pkg/otlp/logs/go.sum b/pkg/otlp/logs/go.sum index 6c6ab2d3..03f7356b 100644 --- a/pkg/otlp/logs/go.sum +++ b/pkg/otlp/logs/go.sum @@ -1,5 +1,5 @@ -github.com/DataDog/datadog-api-client-go/v2 v2.13.0 h1:2c1dXSyUfum2YIVoYlqnBhV5JOG1cLSW+4jB3RrKjLc= -github.com/DataDog/datadog-api-client-go/v2 v2.13.0/go.mod h1:kntOqXEh1SmjwSDzW/eJkr9kS7EqttvEkelglWtJRbg= +github.com/DataDog/datadog-api-client-go/v2 v2.33.0 h1:OI6kDnJeQmkjfGzxmP0XUQUxMD4tp6oAPXnnJ4VpgUM= +github.com/DataDog/datadog-api-client-go/v2 v2.33.0/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -16,6 +16,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 h1:TQcrn6Wq+sKGkpyPvppOz99zsMBaUOKXq6HSv655U1c= github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= @@ -24,7 +26,10 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -36,7 +41,9 @@ github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC github.com/knadh/koanf/v2 v2.0.2 h1:sEZzPW2rVWSahcYILNq/syJdEyRafZIG0l9aWwL86HA= github.com/knadh/koanf/v2 v2.0.2/go.mod h1:HN9uZ+qFAejH1e4G41gnoffIanINWQuONLXiV7kir6k= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c h1:cqn374mizHuIWj+OSJCajGr/phAmuMug9qIX3l9CflE= @@ -59,6 +66,7 @@ github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1B github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= @@ -89,6 +97,7 @@ go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6 go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= @@ -152,5 +161,6 @@ google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7 google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/otlp/logs/transform.go b/pkg/otlp/logs/transform.go index ae0544e9..2e46f1ea 100644 --- a/pkg/otlp/logs/transform.go +++ b/pkg/otlp/logs/transform.go @@ -70,7 +70,7 @@ func Transform(lr plog.LogRecord, res pcommon.Resource, logger *zap.Logger) data func transform(lr plog.LogRecord, host, service string, res pcommon.Resource, logger *zap.Logger) datadogV2.HTTPLogItem { l := datadogV2.HTTPLogItem{ - AdditionalProperties: make(map[string]string), + AdditionalProperties: make(map[string]interface{}), } if host != "" { l.Hostname = datadog.PtrString(host) diff --git a/pkg/otlp/logs/transform_test.go b/pkg/otlp/logs/transform_test.go index a609c898..23655eed 100644 --- a/pkg/otlp/logs/transform_test.go +++ b/pkg/otlp/logs/transform_test.go @@ -62,7 +62,7 @@ func TestTranslator(t *testing.T) { want: datadogV2.HTTPLogItem{ Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -89,7 +89,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("service:otlp_col,otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -118,7 +118,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("service:otlp_col,foo:bar,otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -146,7 +146,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -175,7 +175,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -208,7 +208,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -241,7 +241,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -274,7 +274,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -305,7 +305,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -336,7 +336,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "alert", otelSeverityText: "alert", @@ -371,7 +371,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "message": "This is log", "app": "test", "status": "warn", @@ -406,7 +406,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "message": "This is log", "app": "test", "status": "error", @@ -438,7 +438,7 @@ func TestTranslator(t *testing.T) { Ddtags: datadog.PtrString("service:otlp_col,otel_source:test"), Message: *datadog.PtrString(""), Service: datadog.PtrString("otlp_col"), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -466,7 +466,7 @@ func TestTranslator(t *testing.T) { want: datadogV2.HTTPLogItem{ Ddtags: datadog.PtrString("service:otlp_col,otel_source:test"), Message: *datadog.PtrString(""), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "app": "test", "status": "debug", otelSeverityNumber: "5", @@ -505,7 +505,7 @@ func TestTranslator(t *testing.T) { want: datadogV2.HTTPLogItem{ Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "root.nest1.nest2": "val", "root.nest12.nest22.nest3": "val2", "root.nest13": "val3", @@ -529,7 +529,7 @@ func TestTranslator(t *testing.T) { want: datadogV2.HTTPLogItem{ Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "status": "", }, }, @@ -579,7 +579,7 @@ func TestTranslator(t *testing.T) { want: datadogV2.HTTPLogItem{ Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "nest1.nest2.nest3.nest4.nest5.nest6.nest7.nest8.nest9.nest10": "{\"nest11\":{\"nest12\":\"ok\"}}", "nest1.nest2.nest3.nest4.nest5.nest14.nest15": "ok2", "status": "", @@ -603,7 +603,7 @@ func TestTranslator(t *testing.T) { want: datadogV2.HTTPLogItem{ Ddtags: datadog.PtrString("otel_source:test"), Message: *datadog.PtrString(""), - AdditionalProperties: map[string]string{ + AdditionalProperties: map[string]interface{}{ "status": "debug", otelSeverityNumber: "5", ddTimestamp: "2023-11-20T16:55:03.397Z",