Skip to content

Commit

Permalink
exporter/datadogexporter: use pkg/trace (#9693)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbbr authored Jun 29, 2022
1 parent c97ea64 commit 234e3ad
Show file tree
Hide file tree
Showing 23 changed files with 596 additions and 4,602 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

### 🧰 Bug fixes 🧰

- `datadogexporter`: The `traces.span_name_remappings` setting now correctly refers to the OpenTelemetry key to be renamed without any sort of normalization. (#9693)
- `datadogexporter`: Unify traces exporter behavior with Datadog Agent OTLP traces ingest. (#9693)
- `aerospikereceiver`: Fix issue where namespaces would not be collected (#11465)
- `filestorageextension`: Copy values returned by Get (#11776)
- `redactionprocessor`: respect allow_all_keys configuration (#11542)
Expand Down
18 changes: 9 additions & 9 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ require (
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/ClickHouse/clickhouse-go v1.5.4 // indirect
github.com/DataDog/agent-payload/v5 v5.0.23 // indirect
github.com/DataDog/datadog-agent/pkg/quantile v0.36.0-rc.4.0.20220426134022-b55bccd5073f // indirect
github.com/DataDog/datadog-agent/pkg/trace/exportable v0.0.0-20201016145401-4646cf596b02 // indirect
github.com/DataDog/datadog-agent/pkg/util/log v0.0.0-20201009092105-58e18918b2db // indirect
github.com/DataDog/datadog-go v4.8.2+incompatible // indirect
github.com/DataDog/agent-payload/v5 v5.0.22 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/otlp/model v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/quantile v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/trace v0.38.0-rc.1 // indirect
github.com/DataDog/datadog-go/v5 v5.1.0 // indirect
github.com/DataDog/sketches-go v1.4.1 // indirect
github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v0.32.2 // indirect
Expand All @@ -58,7 +60,6 @@ require (
github.com/SermoDigital/jose v0.9.2-0.20161205224733-f6df55f235c2 // indirect
github.com/Shopify/sarama v1.34.1 // indirect
github.com/Showmax/go-fqdn v1.0.0 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/aerospike/aerospike-client-go/v5 v5.8.0 // indirect
github.com/alecthomas/participle/v2 v2.0.0-alpha9 // indirect
Expand Down Expand Up @@ -86,7 +87,6 @@ require (
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/checkpoint-restore/go-criu/v5 v5.3.0 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect
github.com/cilium/ebpf v0.7.0 // indirect
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/cloudfoundry-incubator/uaago v0.0.0-20190307164349-8136b7bbe76e // indirect
Expand Down Expand Up @@ -436,7 +436,7 @@ require (
github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9 // indirect
github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921 // indirect
github.com/shirou/gopsutil v3.21.10+incompatible // indirect
github.com/secure-systems-lab/go-securesystemslib v0.3.1 // indirect
github.com/shirou/gopsutil/v3 v3.22.5 // indirect
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 // indirect
github.com/signalfx/gohistogram v0.0.0-20160107210732-1ccfd2ff5083 // indirect
Expand All @@ -456,6 +456,7 @@ require (
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.429 // indirect
github.com/tg123/go-htpasswd v1.2.0 // indirect
github.com/theupdateframework/go-tuf v0.3.0 // indirect
github.com/tidwall/gjson v1.12.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
Expand Down Expand Up @@ -513,7 +514,6 @@ require (
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/DataDog/dd-trace-go.v1 v1.38.1 // indirect
gopkg.in/alexcesaro/statsd.v2 v2.0.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
Expand Down
321 changes: 32 additions & 289 deletions cmd/configschema/go.sum

Large diffs are not rendered by default.

57 changes: 0 additions & 57 deletions exporter/datadogexporter/denylister.go

This file was deleted.

83 changes: 0 additions & 83 deletions exporter/datadogexporter/denylister_test.go

This file was deleted.

5 changes: 5 additions & 0 deletions exporter/datadogexporter/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ exporters:
## Trace exporter specific configuration.
#
# traces:
## @param max_events_per_second - integer - optional - default: 200
## Maximum number of APM Analytics events per second to sample.
#
# max_events_per_second: 200

## @param endpoint - string - optional
## The host of the Datadog intake server to send traces to.
## If unset it will be determined from the `DD_APM_URL` environment variable (Deprecated: [v0.47.0] set environment variable explicitly on configuration instead).
Expand Down
48 changes: 28 additions & 20 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package datadogexporter // import "github.com/open-telemetry/opentelemetry-colle

import (
"context"
"errors"
"fmt"
"os"
"sync"
Expand Down Expand Up @@ -238,55 +239,62 @@ func (f *factory) createTracesExporter(
set component.ExporterCreateSettings,
c config.Exporter,
) (component.TracesExporter, error) {

cfg := c.(*ddconfig.Config)

cfg, ok := c.(*ddconfig.Config)
if !ok {
return nil, errors.New("programming error: config structure is not of type *ddconfig.Config")
}
if err := cfg.Sanitize(set.Logger); err != nil {
return nil, err
}

var (
pusher consumer.ConsumeTracesFunc
stop component.ShutdownFunc
)
hostProvider, err := f.SourceProvider(set.TelemetrySettings, cfg.Hostname)
if err != nil {
return nil, fmt.Errorf("failed to build hostname provider: %w", err)
}

ctx, cancel := context.WithCancel(ctx)
var pushTracesFn consumer.ConsumeTracesFunc

ctx, cancel := context.WithCancel(ctx) // nolint:govet
// cancel() runs on shutdown
if cfg.OnlyMetadata {
pushTracesFn = func(_ context.Context, td ptrace.Traces) error {
// only sending metadata, use only attributes
// only host metadata needs to be sent, once.
pusher = func(_ context.Context, td ptrace.Traces) error {
f.onceMetadata.Do(func() {
attrs := pcommon.NewMap()
if td.ResourceSpans().Len() > 0 {
attrs = td.ResourceSpans().At(0).Resource().Attributes()
}
go metadata.Pusher(ctx, set, newMetadataConfigfromConfig(cfg), hostProvider, attrs)
})

return nil
}
stop = func(context.Context) error {
cancel()
return nil
}
} else {
exporter, tracesErr := newTracesExporter(ctx, set, cfg, &f.onceMetadata, hostProvider)
if tracesErr != nil {
tracex, err2 := newTracesExporter(ctx, set, cfg, &f.onceMetadata, hostProvider)
if err2 != nil {
cancel()
return nil, tracesErr
return nil, err2
}
pusher = tracex.consumeTraces
stop = func(context.Context) error {
cancel() // first cancel context
tracex.waitShutdown() // then wait for shutdown
return nil
}
pushTracesFn = exporter.pushTraceDataScrubbed
}

return exporterhelper.NewTracesExporter(
cfg,
set,
pushTracesFn,
pusher,
// explicitly disable since we rely on http.Client timeout logic.
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0 * time.Second}),
// We don't do retries on traces because of deduping concerns on APM Events.
exporterhelper.WithRetry(exporterhelper.RetrySettings{Enabled: false}),
exporterhelper.WithQueue(cfg.QueueSettings),
exporterhelper.WithShutdown(func(context.Context) error {
cancel()
return nil
}),
exporterhelper.WithShutdown(stop),
)
}
12 changes: 11 additions & 1 deletion exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ func TestLoadConfig(t *testing.T) {
TCPAddr: confignet.TCPAddr{
Endpoint: "https://trace.agent.datadoghq.eu",
},
IgnoreResources: []string{},
SpanNameRemappings: map[string]string{
"old_name1": "new_name1",
"old_name2": "new_name2",
},
SpanNameAsResourceName: true,
IgnoreResources: []string{},
}, apiConfig.Traces)
assert.True(t, apiConfig.SendMetadata)
assert.False(t, apiConfig.OnlyMetadata)
Expand Down Expand Up @@ -243,6 +248,7 @@ func TestLoadConfigEnvVariables(t *testing.T) {
t.Setenv("DD_TAGS", "envexample:tag envexample2:tag")
t.Setenv("DD_URL", "https://api.datadoghq.com")
t.Setenv("DD_APM_URL", "https://trace.agent.datadoghq.com")
t.Setenv("DD_APM_MAX_TPS", "15")

factories, err := componenttest.NopFactories()
assert.NoError(t, err)
Expand Down Expand Up @@ -296,6 +302,10 @@ func TestLoadConfigEnvVariables(t *testing.T) {
TCPAddr: confignet.TCPAddr{
Endpoint: "https://trace.agent.datadoghq.test",
},
SpanNameRemappings: map[string]string{
"old_name3": "new_name3",
"old_name4": "new_name4",
},
IgnoreResources: []string{},
}, apiConfig.Traces)
assert.Equal(t,
Expand Down
Loading

0 comments on commit 234e3ad

Please sign in to comment.