-
-
Notifications
You must be signed in to change notification settings - Fork 356
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
Conversation
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Hey @adinauer and @AbhiPrasad, it would be nice if you could take a look at this PR. |
There was a problem hiding this 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 :-)
There was a problem hiding this 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.
There was a problem hiding this 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 👏
Sources/Sentry/SentrySerialization.m
Outdated
[[value description] stringByAddingPercentEncodingWithAllowedCharacters:allowedSet]; | ||
|
||
NSString *item = [NSString stringWithFormat:@"%@=%@", keyDescription, valueDescription]; | ||
if (item.length + currentSize <= 8192) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@@ -245,6 +245,23 @@ class SentrySerializationTests: XCTestCase { | |||
XCTAssertNil(actual) | |||
} | |||
|
|||
func testDictionaryToBaggageEncoded() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have it.
sentry-cocoa/Tests/SentryTests/Helper/SentrySerializationTests.swift
Lines 258 to 262 in 76a7166
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
📜 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
🔮 Next steps