Skip to content

Commit

Permalink
[receiver/datadog] Implement '/info' endpoint (#34772)
Browse files Browse the repository at this point in the history
**Description:** <Describe what has changed.>
The Datadog agent exposes a `/info`
[endpoint](https://github.com/DataDog/datadog-agent/blob/ab888632bb71bcd57716e3428ed4c242ed7b9aaa/pkg/trace/api/api.go#L205),
communicating its available endpoints and capabilities.

This endpoint is used for the [trace
libraries](https://github.com/DataDog/dd-trace-java/blob/master/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java#L140-L173)
to infer the features available in the queried agent, and make some
decisions about the telemetry data at hand, including whether to send
[client
stats](https://github.com/DataDog/dd-trace-java/blob/master/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java#L40)
for the [local sampled
spans](https://github.com/DataDog/dd-trace-java/blob/master/dd-trace-core/src/main/java/datadog/trace/core/CoreTracer.java#L993-L1008)
used to calculate the [trace
metrics](https://docs.datadoghq.com/tracing/metrics/metrics_namespace/).

PS: in order to dynamically expose the available endpoints, this PR also
does a minor refactor on the endpoint configuration structure, defining
them in a `[]Endpoint` rather than registering them directly in the
`ServeMux`.

**Link to tracking Issue:**

**Testing:**

**Documentation:**

---------

Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
lopes-felipe and jpkrohling authored Aug 21, 2024
1 parent 4bac647 commit 8477a83
Show file tree
Hide file tree
Showing 8 changed files with 403 additions and 24 deletions.
27 changes: 27 additions & 0 deletions .chloggen/datadogreceiver-info-endpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: datadogreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Implement '/info' endpoint

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34772]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
8 changes: 8 additions & 0 deletions receiver/datadogreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.0

require (
github.com/DataDog/agent-payload/v5 v5.0.130
github.com/DataDog/datadog-agent/pkg/obfuscate v0.55.3
github.com/DataDog/datadog-agent/pkg/proto v0.56.0-rc.12
github.com/DataDog/datadog-api-client-go/v2 v2.29.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.107.0
Expand All @@ -26,10 +27,14 @@ require (
)

require (
github.com/DataDog/datadog-go/v5 v5.5.0 // indirect
github.com/DataDog/go-sqllexer v0.0.12 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
Expand All @@ -52,7 +57,9 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.107.0 // indirect
github.com/outcaste-io/ristretto v0.2.1 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
Expand Down Expand Up @@ -82,6 +89,7 @@ require (
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.23.0 // indirect
Expand Down
43 changes: 43 additions & 0 deletions receiver/datadogreceiver/go.sum

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

44 changes: 44 additions & 0 deletions receiver/datadogreceiver/internal/translator/info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package translator // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadogreceiver/internal/translator"

import (
"github.com/DataDog/datadog-agent/pkg/obfuscate"
)

type ReducedObfuscationConfig struct {
ElasticSearch bool `json:"elastic_search"`
Mongo bool `json:"mongo"`
SQLExecPlan bool `json:"sql_exec_plan"`
SQLExecPlanNormalize bool `json:"sql_exec_plan_normalize"`
HTTP obfuscate.HTTPConfig `json:"http"`
RemoveStackTraces bool `json:"remove_stack_traces"`
Redis obfuscate.RedisConfig `json:"redis"`
Memcached obfuscate.MemcachedConfig `json:"memcached"`
}

type ReducedConfig struct {
DefaultEnv string `json:"default_env"`
TargetTPS float64 `json:"target_tps"`
MaxEPS float64 `json:"max_eps"`
ReceiverPort int `json:"receiver_port"`
ReceiverSocket string `json:"receiver_socket"`
ConnectionLimit int `json:"connection_limit"`
ReceiverTimeout int `json:"receiver_timeout"`
MaxRequestBytes int64 `json:"max_request_bytes"`
StatsdPort int `json:"statsd_port"`
MaxMemory float64 `json:"max_memory"`
MaxCPU float64 `json:"max_cpu"`
AnalyzedSpansByService map[string]map[string]float64 `json:"analyzed_spans_by_service"`
Obfuscation ReducedObfuscationConfig `json:"obfuscation"`
}

type DDInfo struct {
Version string `json:"version"`
Endpoints []string `json:"endpoints"`
ClientDropP0s bool `json:"client_drop_p0s"`
SpanMetaStructs bool `json:"span_meta_structs"`
LongRunningSpans bool `json:"long_running_spans"`
Config *ReducedConfig `json:"config"`
}
Loading

0 comments on commit 8477a83

Please sign in to comment.