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

Minor: Improve Datadog::Profiling::HttpTransport error logging #3038

Merged

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Aug 9, 2023

What does this PR do?:

This PR tweaks the HttpTransport error logging to include the configuration being used.

For instance, it will now look like:

ERROR (lib/datadog/profiling/http_transport.rb:58:in `export') Failed to report profiling data ({:agent=>"unix:///fake-apm-socket.socket"}): failed ddog_prof_Exporter_send: error trying to connect: No such file or directory (os error 2): No such file or directory (os error 2)

...I did notice the libdatadog error message seems to be repeated and isn't particularly great; that's a separate issue for a future fix (on the libdatadog side).

Motivation:

While investigating #3037 I noticed this information was not being logged when the profiler failed to report, and I thought it would be come in handy when debugging future issues.

Additional Notes:

N/A

How to test the change?:

The change includes test coverage. You can also manually trigger an issue by running dd-trace-rb with an invalid configuration, e.g. the above error message was triggered by running with

$ DD_PROFILING_ENABLED=true DD_TRACE_AGENT_URL=unix:///fake-apm-socket.socket \
  bundle exec ddtracerb exec ruby -e "sleep 1"

**What does this PR do?**:

This PR tweaks the `HttpTransport` error logging to include the
configuration being used.

For instance, it will now look like:

```
ERROR (lib/datadog/profiling/http_transport.rb:58:in `export') Failed to
report profiling data ({:agent=>"unix:///fake-apm-socket.socket"}):
failed ddog_prof_Exporter_send: error trying to connect: No such file
or directory (os error 2): No such file or directory (os error 2)
```

...I did notice the libdatadog error message seems to be repeated and
isn't particularly great; that's a separate issue for a future fix
(on the libdatadog side).

**Motivation**:

While investigating #3037 I noticed this information was not being
logged when the profiler failed to report, and I thought it would be
come in handy when debugging future issues.

**Additional Notes**:

N/A

**How to test the change?**:

The change includes test coverage. You can also manually trigger an
issue by running dd-trace-rb with an invalid configuration, e.g.
the above error message was triggered by running with

```bash
$ DD_PROFILING_ENABLED=true DD_TRACE_AGENT_URL=unix:///fake-apm-socket.socket \
  bundle exec ddtracerb exec ruby -e "sleep 1"
```
@ivoanjo ivoanjo requested a review from a team August 9, 2023 13:33
@github-actions github-actions bot added the profiling Involves Datadog profiling label Aug 9, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #3038 (1212ece) into master (6031043) will increase coverage by 0.03%.
Report is 16 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3038      +/-   ##
==========================================
+ Coverage   98.08%   98.12%   +0.03%     
==========================================
  Files        1317     1322       +5     
  Lines       74362    74644     +282     
  Branches     3402     3403       +1     
==========================================
+ Hits        72941    73247     +306     
+ Misses       1421     1397      -24     
Files Changed Coverage Δ
spec/datadog/profiling/validate_benchmarks_spec.rb 100.00% <ø> (ø)
lib/datadog/profiling/http_transport.rb 97.72% <100.00%> (+0.10%) ⬆️
lib/datadog/tracing/contrib.rb 100.00% <100.00%> (ø)
lib/datadog/tracing/contrib/rails/log_injection.rb 100.00% <100.00%> (ø)
lib/datadog/tracing/contrib/rails/patcher.rb 100.00% <100.00%> (ø)
spec/datadog/profiling/http_transport_spec.rb 99.60% <100.00%> (+0.03%) ⬆️
...atadog/tracing/contrib/rails/log_injection_spec.rb 100.00% <100.00%> (ø)
.../datadog/tracing/contrib/suite/integration_spec.rb 100.00% <100.00%> (ø)
spec/datadog/tracing/contrib_spec.rb 100.00% <100.00%> (ø)

... and 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ivoanjo ivoanjo merged commit 75cb379 into master Aug 10, 2023
204 checks passed
@ivoanjo ivoanjo deleted the ivoanjo/improve-profiling-http-transport-error-logging branch August 10, 2023 08:03
@github-actions github-actions bot added this to the 1.13.1 milestone Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
profiling Involves Datadog profiling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants