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

Tracing without performance #833

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

ribice
Copy link
Collaborator

@ribice ribice commented May 15, 2024

Continuation from #752

greywolve and others added 8 commits November 30, 2023 14:44
…745)

* feat(tracing without performance): add propagation context to scope

* remove redundant dynamic context assignment

* more tests
Add ContinueTrace as a method on the hub. This is how other SDKs that
have to deal with concurrency tend to do it, ie Java.
@@ -379,6 +405,31 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint) *Event {
}
}

// Apply the trace context to errors if there is a Span on the scope. If
// there isn't then fall back to the propagation context.
if event.Type != transactionType {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@cleptric There was a comment on old type to use this for transactions as well?

Copy link
Member

@cleptric cleptric May 15, 2024

Choose a reason for hiding this comment

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

We have to throw this on all events, so check-ins, errors, transactios, etc.

Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 89.43089% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 81.92%. Comparing base (23c5137) to head (9f80641).

Files Patch % Lines
propagation_context.go 86.66% 3 Missing and 3 partials ⚠️
scope.go 84.84% 4 Missing and 1 partial ⚠️
hub.go 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #833      +/-   ##
==========================================
+ Coverage   81.80%   81.92%   +0.12%     
==========================================
  Files          50       51       +1     
  Lines        4436     4543     +107     
==========================================
+ Hits         3629     3722      +93     
- Misses        660      669       +9     
- Partials      147      152       +5     

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

tracing.go Show resolved Hide resolved
hub.go Show resolved Hide resolved
@ribice
Copy link
Collaborator Author

ribice commented May 19, 2024

The thing I feel wrong about is that I don't get the traces nested. Am I doing something wrong here?

The parent span ID is set properly.

CleanShot 2024-05-19 at 07 06 25@2x

@ribice ribice requested a review from cleptric May 19, 2024 05:07
@aldy505
Copy link
Contributor

aldy505 commented May 20, 2024

The thing I feel wrong about is that I don't get the traces nested. Am I doing something wrong here?

The parent span ID is set properly.

CleanShot 2024-05-19 at 07 06 25@2x

@ribice can I see the code to repro this one?

@ribice
Copy link
Collaborator Author

ribice commented May 20, 2024

The thing I feel wrong about is that I don't get the traces nested. Am I doing something wrong here?
The parent span ID is set properly.
CleanShot 2024-05-19 at 07 06 25@2x

@ribice can I see the code to repro this one?

https://gist.github.com/ribice/2c583f9c1edc3084d3572e2ea5065419

@aldy505
Copy link
Contributor

aldy505 commented May 20, 2024

The thing I feel wrong about is that I don't get the traces nested. Am I doing something wrong here?
The parent span ID is set properly.
CleanShot 2024-05-19 at 07 06 25@2x

@ribice can I see the code to repro this one?

https://gist.github.com/ribice/2c583f9c1edc3084d3572e2ea5065419

I think your sentry.ContinueTrace is conflicting with the ones from here on the sentryhttp middleware

options := []sentry.SpanOption{
sentry.WithOpName("http.server"),
sentry.ContinueFromRequest(r),
sentry.WithTransactionSource(sentry.SourceURL),
}
transaction := sentry.StartTransaction(ctx,
fmt.Sprintf("%s %s", r.Method, r.URL.Path),
options...,
)

The sentry.ContinueFromRequest should acquire the Sentry-related headers and append it to the span options. Try to remove that part from the middleware and see if everything works, maybe?

@aldy505
Copy link
Contributor

aldy505 commented May 26, 2024

Got time to finally come back to this, made a repro on Nodejs, nothing wrong about it not being nested. But I wonder why it got the same parent span id though. It should only got 2-3 captured events

image

Repro https://gist.github.com/aldy505/90354abc6877071dec601c8ddabca092

@ribice
Copy link
Collaborator Author

ribice commented May 26, 2024

Hmm, seems you're right. Capturing it first time works properly (same as in node snippet above), but every subsequent request appends to that trace which is weird. I'll investigate now.

First:

CleanShot 2024-05-26 at 18 07 52

Second:

CleanShot 2024-05-26 at 18 09 27

@ribice
Copy link
Collaborator Author

ribice commented May 26, 2024

I was able to resolve it by creating a new Scope/Hub in every request. This way it generates new traceID/spanID.

https://gist.github.com/ribice/2c583f9c1edc3084d3572e2ea5065419 (service1-updated.go).

Not sure if this is the intended way.

@aldy505
Copy link
Contributor

aldy505 commented May 27, 2024

On the JS SDK, the ContinueTrace is a function that accepts a callback. I think on the callback, it creates a new scope internally, Not sure if this should also be done on Go though.

@getsentry getsentry locked as off-topic and limited conversation to collaborators May 27, 2024
cleptric
cleptric previously approved these changes May 27, 2024
hub.go Outdated Show resolved Hide resolved
@cleptric cleptric dismissed their stale review May 27, 2024 16:47

Wanted to comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants