Skip to content

Commit

Permalink
[exporter/datadogexporter] Add example for host metadata (open-teleme…
Browse files Browse the repository at this point in the history
…try#31604)

**Description:** 
Adds example `host-metadata.yaml` that demonstrates use of [Mapping
OpenTelemetry Semantic Conventions to Infrastructure List Host
Information](https://docs.datadoghq.com/opentelemetry/schema_semantics/host_metadata)
with the exporter and connector.
  • Loading branch information
liustanley authored Mar 6, 2024
1 parent 0c7785d commit 5b4e92a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions connector/datadogconnector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,5 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sa
replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage => ../../extension/storage

replace github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor => ../../processor/transformprocessor
43 changes: 43 additions & 0 deletions exporter/datadogexporter/examples/host-metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
receivers:
otlp:
protocols:
http:
endpoint: "localhost:4318"
grpc:
endpoint: "localhost:4317"
processors:
probabilistic_sampler:
sampling_percentage: 20
batch:
send_batch_max_size: 1000
send_batch_size: 100
timeout: 10s
transform:
metric_statements:
- context: resource
statements:
- set(attributes["datadog.host.use_as_metadata"], true)
trace_statements:
- context: resource
statements:
- set(attributes["datadog.host.use_as_metadata"], true)
connectors:
datadog/connector:
exporters:
datadog:
api:
key: ${env:DD_API_KEY}
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch, transform]
exporters: [datadog/connector]
traces/2:
receivers: [datadog/connector]
processors: [batch, probabilistic_sampler]
exporters: [datadog]
metrics:
receivers: [datadog/connector]
processors: [batch, transform]
exporters: [datadog]
2 changes: 2 additions & 0 deletions exporter/datadogexporter/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver"
Expand Down Expand Up @@ -112,6 +113,7 @@ func newTestComponents(t *testing.T) otelcol.Factories {
k8sattributesprocessor.NewFactory(),
resourcedetectionprocessor.NewFactory(),
probabilisticsamplerprocessor.NewFactory(),
transformprocessor.NewFactory(),
}...,
)
require.NoError(t, err)
Expand Down
6 changes: 6 additions & 0 deletions exporter/datadogexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.96.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.96.0
Expand Down Expand Up @@ -81,6 +82,7 @@ require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Showmax/go-fqdn v1.0.0 // indirect
github.com/alecthomas/participle/v2 v2.1.1 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -154,6 +156,7 @@ require (
github.com/hashicorp/nomad/api v0.0.0-20230721134942-515895c7690c // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/hetznercloud/hcloud-go/v2 v2.4.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/ionos-cloud/sdk-go/v6 v6.1.9 // indirect
Expand Down Expand Up @@ -189,6 +192,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.96.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/docker v0.96.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter v0.96.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl v0.96.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.96.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza v0.96.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.96.0 // indirect
Expand Down Expand Up @@ -362,3 +366,5 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator
replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor => ../../processor/tailsamplingprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage => ../../extension/storage

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor => ../../processor/transformprocessor
6 changes: 6 additions & 0 deletions exporter/datadogexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions exporter/datadogexporter/integrationtest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,5 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator
replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor => ../../../processor/probabilisticsamplerprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => ../../../receiver/prometheusreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor => ../../../processor/transformprocessor

0 comments on commit 5b4e92a

Please sign in to comment.