Skip to content

fix: route libcurl debug output through SENTRY_TRACE#1854

Merged
jpnurmi merged 2 commits into
masterfrom
jpnurmi/fix/curl-debug
Jul 10, 2026
Merged

fix: route libcurl debug output through SENTRY_TRACE#1854
jpnurmi merged 2 commits into
masterfrom
jpnurmi/fix/curl-debug

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Note

This is an opinionated behavior change. Previously, sentry_options_set_debug(options, true) also made libcurl's verbose debug output visible. With this change, that output is routed through the Sentry logger at TRACE level and is therefore no longer shown by default.

Applications that still want the curl/transport diagnostics can opt in:

sentry_options_set_debug(options, true);
sentry_options_set_logger_level(options, SENTRY_LEVEL_TRACE);

Using the existing logger level provides explicit control over this useful but noisy output without introducing curl- or transport-specific configuration flags.

Problem A: Sentry logger cannot capture curl output (#887)

  • Install CURLOPT_DEBUGFUNCTION and route curl debug logs through the Sentry logger. As a bonus, this makes curl debug output visible in sentry-daemon logs.

Problem B: curl debug output is overly verbose (#555)

  • Use SENTRY_TRACE (instead of SENTRY_DEBUG) to avoid the verbose curl debug output being visible by default when debug logging is enabled.

Before

[sentry] DEBUG shutting down background worker thread
[sentry] DEBUG submitting task to background worker thread
< HTTP/2 200 
< server: nginx
< date: Thu, 09 Jul 2026 15:16:01 GMT
< content-type: application/json
< content-length: 2
< vary: origin, access-control-request-method, access-control-request-headers
< access-control-allow-origin: *
< access-control-expose-headers: x-sentry-error,x-sentry-rate-limits,retry-after
< cross-origin-resource-policy: cross-origin
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< via: 1.1 google
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
< 
{}* Connection #0 to host o447951.ingest.us.sentry.io left intact
[sentry] DEBUG executing task on worker thread

After

[sentry] DEBUG shutting down background worker thread
[sentry] DEBUG submitting task to background worker thread
[sentry] TRACE < HTTP/2 200 
[sentry] TRACE < server: nginx
[sentry] TRACE < date: Thu, 09 Jul 2026 15:06:58 GMT
[sentry] TRACE < content-type: application/json
[sentry] TRACE < content-length: 2
[sentry] TRACE < vary: origin, access-control-request-method, access-control-request-headers
[sentry] TRACE < access-control-allow-origin: *
[sentry] TRACE < access-control-expose-headers: x-sentry-error,x-sentry-rate-limits,retry-after
[sentry] TRACE < cross-origin-resource-policy: cross-origin
[sentry] TRACE < strict-transport-security: max-age=31536000; includeSubDomains; preload
[sentry] TRACE < via: 1.1 google
[sentry] TRACE < alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
[sentry] TRACE {}
[sentry] TRACE * Connection #0 to host o447951.ingest.us.sentry.io left intact
[sentry] DEBUG executing task on worker thread

Close: #555
Close: #887

Replaces `CURLOPT_WRITEDATA = stderr` with `CURLOPT_DEBUGFUNCTION` and
a custom `CURLOPT_WRITEFUNCTION` so curl's verbose trace and the HTTP
response body flow through `SENTRY_TRACE` instead of being written to
`stderr` in debug mode.
@jpnurmi jpnurmi force-pushed the jpnurmi/fix/curl-debug branch from f17bcf5 to 153dcea Compare July 9, 2026 15:24

@JoshuaMoelans JoshuaMoelans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, also agree with putting these in "TRACE" level. Thanks for the cleanup / consolidation 🧹 !!

@jpnurmi jpnurmi merged commit 252e4c6 into master Jul 10, 2026
102 of 103 checks passed
@jpnurmi jpnurmi deleted the jpnurmi/fix/curl-debug branch July 10, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cURL logging is not unified with sentry logging Separate curl (transport) and Sentry logging option

2 participants