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] add client info to datadogreceiver #22992

Merged
merged 1 commit into from
Jun 7, 2023

Conversation

povilasv
Copy link
Contributor

@povilasv povilasv commented Jun 1, 2023

Description:

Fix add client context and use other http settings defined in config.

I've used ToServer() and ToListener(), which is similiar to otlp http receiver. They add a bunch of common logic, such as handling client context.

Link to tracking Issue: #22991

Testing:

  • Tested with python app that sends dd traces

Documentation:

@povilasv povilasv marked this pull request as ready for review June 1, 2023 10:49
@povilasv povilasv requested a review from a team as a code owner June 1, 2023 10:49
Copy link
Contributor

@MovieStoreGuy MovieStoreGuy left a comment

Choose a reason for hiding this comment

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

These changes look great, just a couple nits on errors messages and keen to get your ideas on them.

Once I've heard back, happy to go ahead :)

ddmux.HandleFunc("/v0.7/traces", ddr.handleTraces)
ddr.server.Handler = ddmux
if err := ddr.server.ListenAndServe(); err != http.ErrServerClosed {
if err := ddr.server.Serve(hln); err != http.ErrServerClosed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mind updating the error check here? It is somewhat out of scope of the PR but it be nice if we could do something like:

if err := dd.server.Serve(hln); err != nil && ! errors.Is(err, http.ErrServerClosed) {

This way we can be a little more explicit and defensive.

return &datadogReceiver{
params: params,
config: config,
nextConsumer: nextConsumer,
server: &http.Server{
ReadTimeout: config.ReadTimeout,
Addr: config.HTTPServerSettings.Endpoint,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm, this is no longer needed because we are using the listener to bind the interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}
hln, err := ddr.config.HTTPServerSettings.ToListener()
if err != nil {
return fmt.Errorf("error configuring datadog receiver listener: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect that this error will be logged at either ERROR status or Error: %w so we could be overly verbose.

What do you think about changing the error to be: failed to create datadog listener: %w ?

ddmux,
)
if err != nil {
return fmt.Errorf("error configuring datadog receiver http server: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

With the error wording, would you mind if we make it more concise?

I mostly worry that when we log it, the message will already say something like: Failed to start "datadog": %w, so what if it was to be failed to create server definition: %w ?

@povilasv
Copy link
Contributor Author

povilasv commented Jun 1, 2023

@MovieStoreGuy thanks for a review :) Updated the PR :)

@fatsheep9146 fatsheep9146 added the ready to merge Code review completed; ready to merge by maintainers label Jun 3, 2023
@codeboten codeboten merged commit e9491b5 into open-telemetry:main Jun 7, 2023
@github-actions github-actions bot added this to the next release milestone Jun 7, 2023
@povilasv povilasv deleted the dd-receiver-listener branch June 8, 2023 11:58
Caleb-Hurshman pushed a commit to observIQ/opentelemetry-collector-contrib that referenced this pull request Jul 6, 2023
…#22992)

Fix add client context and use other http settings defined in config.

I've used ToServer() and ToListener(), which is similiar to otlp http receiver. They add a bunch of common logic, such as handling client context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Code review completed; ready to merge by maintainers receiver/datadog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants