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

[Otel]: A transaction, not a span, is created when its parent span is already finished. #669

Open
kamatama41 opened this issue Jul 17, 2023 · 0 comments
Assignees
Labels
Status: Backlog Topic: OpenTelemetry Issue/PR related to OpenTelemetry integration Type: Bug

Comments

@kamatama41
Copy link

Summary

A new transaction is created if its parent span is already finished with OpenTelemetry integration.

Steps To Reproduce

func TestOtelTrace(t *testing.T) {
	if err := sentry.Init(sentry.ClientOptions{
		Dsn:              "https://[email protected]/0",
		EnableTracing:    true,
		TracesSampleRate: 1.0,
		Environment:      "test",
		Debug:            true,
	}); err != nil {
		panic("Sentry initialization failed: " + err.Error())
	}
	defer sentry.Flush(2 * time.Second)

	tp := sdktrace.NewTracerProvider(
		sdktrace.WithSpanProcessor(sentryotel.NewSentrySpanProcessor()),
	)
	tracer := tp.Tracer("test_tracer")

	ctx, span := tracer.Start(context.Background(), "test_transaction")
	defer span.End()

	ctx, span2 := tracer.Start(ctx, "test_span_1")
	time.Sleep(time.Second)
	span2.End()
	ctx, span3 := tracer.Start(ctx, "test_span_2")
	time.Sleep(time.Second)
	span3.End()
}

Run the test then test_span_2 became a transaction.
スクリーンショット 2023-07-17 16 28 46

Expected Behavior

I would like test_span_2 to be a span.
Using sentry-go directly works as expected.

func TestSentryTrace(t *testing.T) {
	if err := sentry.Init(sentry.ClientOptions{
		Dsn:              "https://[email protected]/0",
		EnableTracing:    true,
		TracesSampleRate: 1.0,
		Environment:      "test",
		Debug:            true,
	}); err != nil {
		panic("Sentry initialization failed: " + err.Error())
	}
	defer sentry.Flush(2 * time.Second)

	ctx := context.Background()
	span := sentry.StartTransaction(ctx, "test_transaction")
	defer span.Finish()

	span2 := sentry.StartSpan(span.Context(), "test_span_1")
	time.Sleep(time.Second)
	span2.Finish()
	span3 := sentry.StartSpan(span2.Context(), "test_span_2")
	time.Sleep(time.Second)
	span3.Finish()
}
スクリーンショット 2023-07-17 16 11 55

SDK

  • sentry-go version: v0.22.0
  • Go version: 1.20
  • Using Go Modules? [yes]

Sentry

  • Using hosted Sentry in sentry.io? [yes]
  • Using your own Sentry installation? Version:
  • Anything particular to your environment that could be related to this issue?

Additional context

@tonyo tonyo added Status: Backlog Topic: OpenTelemetry Issue/PR related to OpenTelemetry integration labels Jul 17, 2023
@cleptric cleptric self-assigned this Aug 9, 2023
@getsentry getsentry deleted a comment from github-actions bot Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Backlog Topic: OpenTelemetry Issue/PR related to OpenTelemetry integration Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants