From e70db8138255490c45febfc8825a699d91127167 Mon Sep 17 00:00:00 2001 From: Anton Ovchinnikov Date: Tue, 11 Apr 2023 14:56:42 +0200 Subject: [PATCH] fix(tracing): Add WithTransactionSource() span option, deprecate TransctionSource() (#611) --- dynamic_sampling_context_test.go | 4 ++-- http/sentryhttp.go | 2 +- tracing.go | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dynamic_sampling_context_test.go b/dynamic_sampling_context_test.go index b176ca4da..ac791bb24 100644 --- a/dynamic_sampling_context_test.go +++ b/dynamic_sampling_context_test.go @@ -90,7 +90,7 @@ func TestDynamicSamplingContextFromTransaction(t *testing.T) { hubFromContext(ctx).ConfigureScope(func(scope *Scope) { scope.SetUser(User{Segment: "user_segment"}) }) - txn := StartTransaction(ctx, "name", TransctionSource(SourceCustom)) + txn := StartTransaction(ctx, "name", WithTransactionSource(SourceCustom)) txn.TraceID = TraceIDFromHex("d49d9bf66f13450b81f65bc51cf49c03") return txn }(), @@ -116,7 +116,7 @@ func TestDynamicSamplingContextFromTransaction(t *testing.T) { Dsn: "http://public@example.com/sentry/1", Release: "1.0.0", }) - txn := StartTransaction(ctx, "name", TransctionSource(SourceURL)) + txn := StartTransaction(ctx, "name", WithTransactionSource(SourceURL)) txn.TraceID = TraceIDFromHex("d49d9bf66f13450b81f65bc51cf49c03") return txn }(), diff --git a/http/sentryhttp.go b/http/sentryhttp.go index 10515310c..b9f62285f 100644 --- a/http/sentryhttp.go +++ b/http/sentryhttp.go @@ -89,7 +89,7 @@ func (h *Handler) handle(handler http.Handler) http.HandlerFunc { options := []sentry.SpanOption{ sentry.OpName("http.server"), sentry.ContinueFromRequest(r), - sentry.TransctionSource(sentry.SourceURL), + sentry.WithTransactionSource(sentry.SourceURL), } // We don't mind getting an existing transaction back so we don't need to // check if it is. diff --git a/tracing.go b/tracing.go index a4a94e8ad..3084d5e1e 100644 --- a/tracing.go +++ b/tracing.go @@ -801,8 +801,14 @@ func OpName(name string) SpanOption { } // TransctionSource sets the source of the transaction name. -// TODO(anton): Fix the typo. +// +// Deprecated: Use WithTransactionSource() instead. func TransctionSource(source TransactionSource) SpanOption { + return WithTransactionSource(source) +} + +// WithTransactionSource sets the source of the transaction name. +func WithTransactionSource(source TransactionSource) SpanOption { return func(s *Span) { s.Source = source }