Skip to content

feat: Replace tracestate header with baggage #1867

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

Merged
merged 22 commits into from
Jun 20, 2022
Merged

feat: Replace tracestate header with baggage #1867

merged 22 commits into from
Jun 20, 2022

Conversation

brustolin
Copy link
Contributor

@brustolin brustolin commented Jun 7, 2022

📜 Description

Replaced the tracestate header in outbound http requests for a baggage header

💡 Motivation and Context

This is a required feature to enable dynamic sampling

💚 How did you test it?

Unit tests

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • Review from the native team if needed
  • No breaking changes

🔮 Next steps

Sorry, something went wrong.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2022

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

Generated by 🚫 dangerJS against 1b79195

@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2022

Codecov Report

Merging #1867 (76a7166) into master (472d146) will increase coverage by 0.21%.
The diff coverage is 93.06%.

❗ Current head 76a7166 differs from pull request most recent head 1b79195. Consider uploading reports for the commit 1b79195 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1867      +/-   ##
==========================================
+ Coverage   91.91%   92.13%   +0.21%     
==========================================
  Files         200      202       +2     
  Lines        9450     9497      +47     
==========================================
+ Hits         8686     8750      +64     
+ Misses        764      747      -17     
Impacted Files Coverage Δ
Sources/Sentry/SentryHttpTransport.m 100.00% <ø> (ø)
Sources/Sentry/include/SentryBaggage.h 0.00% <0.00%> (ø)
Sources/Sentry/include/SentryNetworkTracker.h 100.00% <ø> (ø)
Sources/Sentry/include/SentryTracer.h 100.00% <ø> (ø)
Sources/Sentry/Public/SentryEnvelope.h 100.00% <100.00%> (ø)
Sources/Sentry/SentryBaggage.m 100.00% <100.00%> (ø)
Sources/Sentry/SentryClient.m 99.15% <100.00%> (+<0.01%) ⬆️
Sources/Sentry/SentryEnvelope.m 93.12% <100.00%> (ø)
Sources/Sentry/SentryNetworkTracker.m 98.87% <100.00%> (ø)
Sources/Sentry/SentrySerialization.m 87.50% <100.00%> (+1.09%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1706d81...1b79195. Read the comment docs.

brustolin and others added 7 commits June 13, 2022 11:41

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@brustolin brustolin marked this pull request as ready for review June 13, 2022 14:28
@brustolin
Copy link
Contributor Author

Hey @adinauer and @AbhiPrasad, it would be nice if you could take a look at this PR.

Copy link
Member

@adinauer adinauer left a comment

Choose a reason for hiding this comment

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

Only looked at baggage specific things, so best get another review for cocoa things :-)

@brustolin brustolin requested a review from adinauer June 14, 2022 08:16
Copy link
Member

@adinauer adinauer left a comment

Choose a reason for hiding this comment

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

One more tiny thing regarding the character limit, otherwise LGTM.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Almost LGTM. Good job 👏

[[value description] stringByAddingPercentEncodingWithAllowedCharacters:allowedSet];

NSString *item = [NSString stringWithFormat:@"%@=%@", keyDescription, valueDescription];
if (item.length + currentSize <= 8192) {
Copy link
Member

Choose a reason for hiding this comment

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

l: We could break if we exceeded the max size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's why we have this check, to avoid exceeding the max size.

Copy link
Member

Choose a reason for hiding this comment

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

I think @philipphofmann is suggesting we do not look at any more items once we reach max size. It could be possible though that there's smaller items that still fit even though the current loop item doesn't. So I think it's better this way.

Copy link
Contributor Author

@brustolin brustolin Jun 20, 2022

Choose a reason for hiding this comment

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

Ow, I see. @AbhiPrasad can correct me if Im wrong, but I remember reading somewhere from him that we should continue adding values that fits. So, break is not the best solution.

Copy link
Member

Choose a reason for hiding this comment

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

If the resulting baggage-string would be greater than 8192 bytes, some list-members MAY be dropped until the resulting baggage-string is 8192 characters or less.

and

If a platform does not propagate all list-members, it is left to the implementer to decide which list-members to propagate.

See https://www.w3.org/TR/baggage/#limits

@@ -245,6 +245,23 @@ class SentrySerializationTests: XCTestCase {
XCTAssertNil(actual)
}

func testDictionaryToBaggageEncoded() {
Copy link
Member

Choose a reason for hiding this comment

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

m: Can we add a test for checking if the Baggage exceeds the max size please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have it.

let largeValue = String(repeating: "a", count: 8_188)
XCTAssertEqual(SentrySerialization.baggageEncodedDictionary(["key": largeValue]), "key=\(largeValue)")
XCTAssertEqual(SentrySerialization.baggageEncodedDictionary(["AKey": "something", "BKey": largeValue]), "AKey=something")
XCTAssertEqual(SentrySerialization.baggageEncodedDictionary(["AKey": "something", "BKey": largeValue, "CKey": "Other Value"]), "AKey=something,CKey=Other%20Value")

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

brustolin and others added 2 commits June 20, 2022 10:58
Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
@brustolin brustolin merged commit fa49e72 into master Jun 20, 2022
@brustolin brustolin deleted the feat/baggage branch June 20, 2022 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants