-
Notifications
You must be signed in to change notification settings - Fork 229
feat: http client integration #876
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #876 +/- ##
==========================================
+ Coverage 84.00% 84.24% +0.24%
==========================================
Files 50 51 +1
Lines 5171 5244 +73
==========================================
+ Hits 4344 4418 +74
+ Misses 673 671 -2
- Partials 154 155 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@aldy505 We should document this (in _examples, and perhaps sentry-docs?), and also update changelog accordingly. |
httpclient/sentryhttpclient.go
Outdated
// Only create the `http.client` span only if there is a parent span. | ||
parentSpan := sentry.GetSpanFromContext(request.Context()) | ||
if parentSpan == nil { | ||
return s.originalRoundTripper.RoundTrip(request) | ||
} |
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.
A quick note why I prefer this instead of creating a sentry.WithOnlyIfParentExists()
(a SpanOption
type):
I used the JS SDK a lot at work lately, and I've been wondering the entire week, on their startSpan
function, they have this as an option: https://github.com/getsentry/sentry-javascript/blob/216aaeba1ee27cce8a4876e1f9212ba374eb30b3/packages/types/src/startSpanOptions.ts#L14-L15
Should the Go SDK move forward with that, as a SpanOption
or not?
We could to the SpanOption
thing, but it feels really weird since the way Go SDK handles scopes/hubs with span is to add the span pointer into the scope. See
Lines 196 to 199 in a6acd05
if clientOptions.EnableTracing { | |
hub := hubFromContext(ctx) | |
hub.Scope().SetSpan(&span) | |
} |
Although we could just not call the scope.SetSpan()
function, I don't know about the behavior if this span that we're creating will ever have a child span being created manually by the user.
// Always add `Baggage` and `Sentry-Trace` headers. | ||
request.Header.Add("Baggage", span.ToBaggage()) | ||
request.Header.Add("Sentry-Trace", span.ToSentryTrace()) |
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.
To support the recently added "Tracing without Performance" feature, we should use hub.GetTraceparent()
and hub.GetBaggage()
httpclient/sentryhttpclient.go
Outdated
cleanRequestURL := request.URL.Redacted() | ||
|
||
span := parentSpan.StartChild("http.client", sentry.WithTransactionName(fmt.Sprintf("%s %s", request.Method, cleanRequestURL))) | ||
span.Tags = s.tags |
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.
Why are we setting span tags here?
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.
Is it not ideal? Should I remove it?
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.
What info is in there?
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.
Decided to just remove it.
client.go
Outdated
// Control with URLs trace propagation should be enabled. Does not support regex patterns. | ||
TracePropagationTargets []string | ||
// When set to true, the SDK will start a span for outgoing HTTP OPTIONS requests. | ||
TraceOptionsRequests bool |
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.
Why did you add this option?
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.
Saw it on the dev docs. Should I not implement that?
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.
Link?
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.
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.
When set to true transactions should be created for HTTP OPTIONS requests.
This option does not apply to outgoing HTTP requests.
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.
Okay. Will update that later.
Some golint errors, I'll fix that later |
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.
Looks good, only the description is missing from the span.
Co-authored-by: Giannis Gkiortzis <[email protected]>
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.
Looks good, let's fix the lint errors and the name in the examples and then it's ready to be merged.
Co-authored-by: Giannis Gkiortzis <[email protected]>
@giortzisg @cleptric Is there anything that's blocking this PR to be merged? |
Not sure we actually want to go the route with the round tripper. But we take another look after logs. |
An effort to implement this: https://develop.sentry.dev/sdk/telemetry/traces/modules/requests/
Since we already have tracing without performance, this should be good to go.