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

Add HTTP response code to Spring WebFlux transactions #2870

Merged
merged 5 commits into from Aug 3, 2023

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented Jul 28, 2023

📜 Description

Set HTTP status code on transactions

💡 Motivation and Context

Fixes #2835 for server side after client side was already done in #2786

💚 How did you test it?

Manually + Unit Tests

📝 Checklist

  • I reviewed the submitted code.
  • 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.
  • 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 Jul 28, 2023

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

Generated by 🚫 dangerJS against bb17e8a

@@ -117,6 +120,8 @@ class SentryTracingFilterTest {
verify(fixture.hub).captureTransaction(
check {
assertThat(it.contexts.trace!!.status).isEqualTo(SpanStatus.INTERNAL_ERROR)
assertThat(it.extras?.get(SpanDataConvention.HTTP_STATUS_CODE_KEY)).isEqualTo(500)
Copy link
Member Author

Choose a reason for hiding this comment

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

data of transactions lands in extras, is this OK?

Copy link
Member

Choose a reason for hiding this comment

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

why does it land in extras? shouldn't it be available through getData() method?

Copy link
Member Author

Choose a reason for hiding this comment

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

The following code seems to do this on purpose:

final Map<String, Object> data = sentryTracer.getData();
if (data != null) {
for (final Map.Entry<String, Object> tag : data.entrySet()) {
this.setExtra(tag.getKey(), tag.getValue());
}
}

Copy link
Member

Choose a reason for hiding this comment

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

oh, i see, i was missing it 😅
in #2786 and getsentry/team-sdks#9 we talked about span data, not transaction extra.
AFAIK the goal is to add the data directly to the spans, not to transactions.
Maybe @smeubank can help us removing any doubt?

@github-actions
Copy link
Contributor

github-actions bot commented Jul 28, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 328.73 ms 383.82 ms 55.09 ms
Size 1.72 MiB 2.29 MiB 575.71 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
fe10f05 304.13 ms 365.65 ms 61.52 ms
9246ed4 275.63 ms 321.31 ms 45.69 ms
fe10f05 294.30 ms 346.84 ms 52.54 ms
4c237f8 319.84 ms 354.47 ms 34.63 ms
fe10f05 314.71 ms 360.62 ms 45.90 ms
496bdfd 301.22 ms 343.96 ms 42.73 ms
9246ed4 281.79 ms 352.08 ms 70.29 ms
dc67004 273.86 ms 346.37 ms 72.51 ms
3baa73f 267.45 ms 388.30 ms 120.85 ms
c03a05e 390.40 ms 419.35 ms 28.94 ms

App size

Revision Plain With Sentry Diff
fe10f05 1.72 MiB 2.29 MiB 575.54 KiB
9246ed4 1.72 MiB 2.28 MiB 572.22 KiB
fe10f05 1.72 MiB 2.29 MiB 575.54 KiB
4c237f8 1.72 MiB 2.29 MiB 575.58 KiB
fe10f05 1.72 MiB 2.29 MiB 575.54 KiB
496bdfd 1.72 MiB 2.28 MiB 571.82 KiB
9246ed4 1.72 MiB 2.28 MiB 572.22 KiB
dc67004 1.72 MiB 2.28 MiB 573.45 KiB
3baa73f 1.72 MiB 2.29 MiB 575.52 KiB
c03a05e 1.72 MiB 2.29 MiB 574.43 KiB

Previous results on branch: feat/http-response-code-for-spring

Startup times

Revision Plain With Sentry Diff
e6c4e3d 319.66 ms 372.54 ms 52.88 ms
ea6784d 327.29 ms 376.58 ms 49.29 ms

App size

Revision Plain With Sentry Diff
e6c4e3d 1.72 MiB 2.29 MiB 575.54 KiB
ea6784d 1.72 MiB 2.29 MiB 575.54 KiB

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Patch coverage: 56.66% and project coverage change: -0.05% ⚠️

Comparison is base (4c237f8) 81.39% compared to head (d799261) 81.35%.

❗ Current head d799261 differs from pull request most recent head bb17e8a. Consider uploading reports for the commit bb17e8a to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2870      +/-   ##
============================================
- Coverage     81.39%   81.35%   -0.05%     
+ Complexity     4652     4646       -6     
============================================
  Files           354      354              
  Lines         17134    17134              
  Branches       2314     2314              
============================================
- Hits          13947    13939       -8     
- Misses         2237     2245       +8     
  Partials        950      950              
Files Changed Coverage Δ
...try/src/main/java/io/sentry/protocol/Contexts.java 80.00% <10.00%> (-7.78%) ⬇️
...pring/jakarta/webflux/AbstractSentryWebFilter.java 89.70% <80.00%> (+0.81%) ⬆️
...java/io/sentry/spring/webflux/SentryWebFilter.java 91.02% <80.00%> (+0.61%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

For transactions, we should set the response status code on the event context.response. See https://github.com/getsentry/relay/blob/master/relay-general/src/protocol/contexts/response.rs

@adinauer
Copy link
Member Author

adinauer commented Aug 1, 2023

For transactions, we should set the response status code on the event context.response

@cleptric PR has been updated to do so.

@stefanosiano can you please give this another pass? I've reverted the status code changes for Spring WebMVC as we always seem to get 200 so it's more confusing than helpful to add the wrong status code. For WebFlux it works, so i kept that. Also added a new withResponse to Contexts please let me know what you think about that.

@adinauer adinauer changed the title Add http response code to spring transactions Add HTTP response code to Spring WebFlux transactions Aug 2, 2023
Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@adinauer adinauer enabled auto-merge (squash) August 3, 2023 07:45
@adinauer adinauer merged commit f86fb22 into main Aug 3, 2023
18 of 19 checks passed
@adinauer adinauer deleted the feat/http-response-code-for-spring branch August 3, 2023 08:14
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.

Normalize http.response.status_code for Metrics & Alerts
4 participants