Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/datadog] Implement '/info' endpoint #34772

Merged

Conversation

lopes-felipe
Copy link
Member

@lopes-felipe lopes-felipe commented Aug 20, 2024

Description:
The Datadog agent exposes a /info endpoint, communicating its available endpoints and capabilities.

This endpoint is used for the trace libraries 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 for the local sampled spans used to calculate the trace metrics.

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:

@lopes-felipe lopes-felipe requested a review from a team August 20, 2024 18:43
@lopes-felipe lopes-felipe changed the title [receiver/datadogreceiver] Implement '/info' endpoint [receiver/datadog] Implement '/info' endpoint Aug 20, 2024
@github-actions github-actions bot added the cmd/otelcontribcol otelcontribcol command label Aug 20, 2024
@lopes-felipe
Copy link
Member Author

lopes-felipe commented Aug 20, 2024

I'm having a bit of a hard time with the CI checks (as you can see from the list of "fix issues" commits) 😞

Any help on this would be really appreciated here. Thanks 🙂

Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied a couple of fixes and added comments about how to find and fix them. Let's see if the CI Lords are happy now.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this component is included by other ones (like tests and the dev distribution), you need to run make gotidy. Running it here, it yielded these changes:

> git st
On branch datadog-receiver/info-endpoint
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   receiver/datadogreceiver/go.sum
	modified:   testbed/go.mod
	modified:   testbed/go.sum

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good to know, thanks :)

@@ -8,6 +8,7 @@ import (
"context"
"errors"
"fmt"
"go.opentelemetry.io/collector/consumer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing the linter, as we require the imports to be split in three blocks: stdlib, third-party, local packages. This here is a third-party among the stdlib. You can run make lint from the component's directory, and it should this:

datadogreceiver/receiver_test.go:11: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/open-telemetry/opentelemetry-collector-contrib) (gci)
	"go.opentelemetry.io/collector/consumer"
datadogreceiver/receiver_test.go:20: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/open-telemetry/opentelemetry-collector-contrib) (gci)
	"go.opentelemetry.io/collector/component/componenttest"
datadogreceiver/receiver_test.go:16: File is not `goimports`-ed with -local github.com/open-telemetry/opentelemetry-collector-contrib (goimports)

This is how it looks like:

diff --git a/receiver/datadogreceiver/receiver_test.go b/receiver/datadogreceiver/receiver_test.go
index 76ab51d4c3..573e271ba8 100644
--- a/receiver/datadogreceiver/receiver_test.go
+++ b/receiver/datadogreceiver/receiver_test.go
@@ -8,7 +8,6 @@ import (
        "context"
        "errors"
        "fmt"
-       "go.opentelemetry.io/collector/consumer"
        "io"
        "net/http"
        "strings"
@@ -18,6 +17,7 @@ import (
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
        "go.opentelemetry.io/collector/component/componenttest"
+       "go.opentelemetry.io/collector/consumer"
        "go.opentelemetry.io/collector/consumer/consumertest"
        "go.opentelemetry.io/collector/pdata/pcommon"
        "go.opentelemetry.io/collector/pdata/pmetric"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that makes sense. Thanks!

@lopes-felipe
Copy link
Member Author

I applied a couple of fixes and added comments about how to find and fix them. Let's see if the CI Lords are happy now.

It looks like they are! Thank you for the help ☺️

@jpkrohling jpkrohling merged commit 8477a83 into open-telemetry:main Aug 21, 2024
156 checks passed
@github-actions github-actions bot added this to the next release milestone Aug 21, 2024
jpkrohling pushed a commit that referenced this pull request Aug 27, 2024
**Description:** <Describe what has changed.>
Following up on #34772, this PR implements Datadog Agent's `/stats`
endpoint, which is used for sending [client
stats](https://github.com/DataDog/dd-trace-java/blob/master/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java#L40)
of 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)
to calculate the [trace
metrics](https://docs.datadoghq.com/tracing/metrics/metrics_namespace/).

This PR also does a minor refactor in the usage of Datadog's common
headers, moving from literal strings to centralized constants.

**Link to tracking Issue:** <Issue number if applicable>

**Testing:** <Describe what testing was performed and which tests were
added.>

**Documentation:** <Describe the documentation added.>
@lopes-felipe lopes-felipe deleted the datadog-receiver/info-endpoint branch August 27, 2024 20:01
f7o pushed a commit to f7o/opentelemetry-collector-contrib that referenced this pull request Sep 12, 2024
**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]>
f7o pushed a commit to f7o/opentelemetry-collector-contrib that referenced this pull request Sep 12, 2024
**Description:** <Describe what has changed.>
Following up on open-telemetry#34772, this PR implements Datadog Agent's `/stats`
endpoint, which is used for sending [client
stats](https://github.com/DataDog/dd-trace-java/blob/master/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java#L40)
of 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)
to calculate the [trace
metrics](https://docs.datadoghq.com/tracing/metrics/metrics_namespace/).

This PR also does a minor refactor in the usage of Datadog's common
headers, moving from literal strings to centralized constants.

**Link to tracking Issue:** <Issue number if applicable>

**Testing:** <Describe what testing was performed and which tests were
added.>

**Documentation:** <Describe the documentation added.>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants