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

captureException not linking to trace #502

Closed
ImDevinC opened this issue Nov 24, 2022 · 4 comments · Fixed by #505
Closed

captureException not linking to trace #502

ImDevinC opened this issue Nov 24, 2022 · 4 comments · Fixed by #505
Assignees

Comments

@ImDevinC
Copy link

Summary

When creating a transaction and a trace and then doing sentry.CaptureException(err), the error is not linked to the trace properly.

Steps To Reproduce

func TestTracing(t *testing.T) {
	err := sentry.Init(sentry.ClientOptions{
		Dsn:              os.Getenv("SENTRY_DSN"), // test-project
		Debug:            true,
		TracesSampleRate: 1.0,
		Release:          "development",
	})
	if err != nil {
		t.Error(err)
	}
	ctx := context.Background()
	defer sentry.Flush(2 * time.Second)
	transaction := sentry.StartTransaction(ctx, "TestTracing", sentry.OpName("function"))
	defer transaction.Finish()
	span := transaction.StartChild("function")
	defer span.Finish()
	err = errors.New("this is an error")
	sentry.CaptureException(err)
}

Expected Behavior

When viewing the issue on sentry.io, the exception should have a link to the relevant trace. When viewing the trace, the exception should be shown in the trace view.

Screenshots

image
image

Sentry.io Event

Error Event: 120248f44d174a1a8d2a60073153e75a
Trace Event: 7b8eaba5361f4c698e79508fa6af68f4

Environment

SDK

  • sentry-go version: v0.15.0
  • Go version: 1.19.3
  • Using Go Modules? yes

Sentry

  • Using hosted Sentry in sentry.io? yes
@cleptric
Copy link
Member

cleptric commented Nov 25, 2022

Thanks for writing in.
I do confirm that the error event sent to Sentry does indeed not contain the required contexts.trace values to make the link between the transaction and error work.

I'll take a look!

@cleptric cleptric self-assigned this Nov 25, 2022
@ImDevinC
Copy link
Author

Thanks! Let me know if I can provide any more information to help

@ImDevinC
Copy link
Author

ImDevinC commented Nov 26, 2022

For clarification, this seems to work just fine

func TestTracing(t *testing.T) {
	err := sentry.Init(sentry.ClientOptions{
		Dsn:              os.Getenv("SENTRY_DSN"),
		Debug:            true,
		TracesSampleRate: 1.0,
		Release:          "development",
	})
	if err != nil {
		t.Error(err)
	}
	ctx := context.Background()
	defer sentry.Flush(2 * time.Second)
	span := sentry.StartSpan(ctx, "function", sentry.TransactionName("TestTracing"))
	defer span.Finish()
	err = errors.New("this is an error")
	sentry.CaptureException(err)
}

@cleptric
Copy link
Member

@ImDevinC I opened a PR to get this fixed. This might take a while to get released, for the moment I suggest using StartSpan instead.

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

Successfully merging a pull request may close this issue.

2 participants