Skip to content

Comments

Add HTTP server request headers from OpenTelemetry span attributes to sentry request in payload#4102

Merged
adinauer merged 24 commits intomainfrom
feat/otel-server-request-headers
Feb 26, 2025
Merged

Add HTTP server request headers from OpenTelemetry span attributes to sentry request in payload#4102
adinauer merged 24 commits intomainfrom
feat/otel-server-request-headers

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Jan 24, 2025

📜 Description

Add HTTP headers in OpenTelemetry span attributes to request.headers.

No longer add headers (prefixed with http.request.header. or http.response.header.) to contexts/otel/attributes.

To actually make this work, customers need to explicitly name the headers they want to see in Sentry in the OpenTelemetry config https://opentelemetry.io/docs/zero-code/java/agent/instrumentation/http/#capturing-http-request-and-response-headers

Screenshot 2025-01-24 at 13 46 19

💡 Motivation and Context

Enable reporting of request headers.

💚 How did you test it?

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b2fef65

@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 372.57 ms 441.46 ms 68.89 ms
Size 1.58 MiB 2.21 MiB 641.66 KiB

Previous results on branch: feat/otel-server-request-headers

Startup times

Revision Plain With Sentry Diff
01d4a6e 408.89 ms 451.35 ms 42.45 ms
3b96af0 364.39 ms 486.10 ms 121.72 ms
461c657 405.82 ms 430.92 ms 25.10 ms
f4ffaaa 395.13 ms 479.50 ms 84.37 ms
7780810 442.00 ms 507.36 ms 65.36 ms

App size

Revision Plain With Sentry Diff
01d4a6e 1.65 MiB 2.31 MiB 677.61 KiB
3b96af0 1.58 MiB 2.21 MiB 641.57 KiB
461c657 1.65 MiB 2.31 MiB 677.61 KiB
f4ffaaa 1.65 MiB 2.31 MiB 678.16 KiB
7780810 1.58 MiB 2.21 MiB 641.09 KiB

Base automatically changed from feat/request-for-otel to main January 24, 2025 13:44
@adinauer adinauer marked this pull request as draft January 27, 2025 14:17
@adinauer adinauer marked this pull request as ready for review February 20, 2025 07:11
);

private final @NotNull List<String> attributeToRemoveByPrefix =
Arrays.asList("http.request.header.");
Copy link
Member Author

Choose a reason for hiding this comment

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

should we add response headers here as well?

Copy link
Member

Choose a reason for hiding this comment

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

Would this mean that they would get removed and not sent to Sentry?
From what I see, HTTP client integrations don't usually send response headers.

Copy link
Member Author

Choose a reason for hiding this comment

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

By default there's no response headers being sent with OTel but they can be enabled via OTel config.

Until now, if enabled we send them. The same was true for request headers which we now filter out in this PR.

This does however not affect other things like Sentry integrations sending headers or attributes we extracted into special places like request. For the response we currently have no extraction logic in place. We could add that in to OpenTelemetryAttributesExtractor in the future.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, thanks. If we filter the request headers due to Sentry's PII policies, then I'd say we should probably filter response headers by default as well.

@adinauer adinauer mentioned this pull request Feb 26, 2025
@adinauer adinauer merged commit 3b6cfdf into main Feb 26, 2025
34 checks passed
@adinauer adinauer deleted the feat/otel-server-request-headers branch February 26, 2025 11:03
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.

3 participants