Skip to content

Commit

Permalink
Renamed ISpan and ITransaction to ISpanTracer and ITransactionTracer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell authored Oct 18, 2023
1 parent d32f05b commit ebbb500
Show file tree
Hide file tree
Showing 50 changed files with 377 additions and 376 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ API Changes:
- Reordered parameters for ther TransactionContext and SpanContext constructors. If you're constructing instances of these classes, you will need to adjust the order in which you pass parameters to these. ([#2696](https://github.com/getsentry/sentry-dotnet/pull/2696))
- The `DiagnosticLogger` signature for `LogError` and `LogFatal` changed to take the `exception` as the first parameter. That way it does no longer get mixed up with the TArgs. The `DiagnosticLogger` now also received an overload for `LogError` and `LogFatal` that accepts a message only. ([#2715](https://github.com/getsentry/sentry-dotnet/pull/2715))
- Integrate `sentry-native` as a static library in Native AOT builds to enable symbolication. ([2704](https://github.com/getsentry/sentry-dotnet/pull/2704))
- `ISpan` and `ITransaction` have been renamed to `ISpanTracer` and `ITransactionTracer`. You will need to update any references to these interfaces in your code to use the new interface names ([#2731](https://github.com/getsentry/sentry-dotnet/pull/2731))

## Unreleased

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Sentry.Benchmarks/StackFrameBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void ConfigureAppFrame()
Module ="Sentry.Extensions.Profiling"
},
new SentryStackFrame() {
Function ="SamplingTransactionProfiler.Start(class Sentry.ITransaction) {QuickJitted}",
Function ="SamplingTransactionProfiler.Start(class Sentry.ITransactionTracer) {QuickJitted}",
Module ="Sentry.Extensions.Profiling"
},
new SentryStackFrame() {
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry.AspNet/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void StartOrContinueTrace(this HttpContext httpContext)
/// <summary>
/// Starts a new Sentry transaction that encompasses the currently executing HTTP request.
/// </summary>
public static ITransaction StartSentryTransaction(this HttpContext httpContext)
public static ITransactionTracer StartSentryTransaction(this HttpContext httpContext)
{
var method = httpContext.Request.HttpMethod;
var path = httpContext.Request.Path;
Expand Down Expand Up @@ -136,7 +136,7 @@ public static void FinishSentryTransaction(this HttpContext httpContext)
return;
}

if (httpContext.Items[HttpContextTransactionItemName] is not ISpan transaction)
if (httpContext.Items[HttpContextTransactionItemName] is not ISpanTracer transaction)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.AspNetCore/SentryTracingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public SentryTracingMiddleware(
_options = options.Value;
}

private ITransaction? TryStartTransaction(HttpContext context)
private ITransactionTracer? TryStartTransaction(HttpContext context)
{
if (context.Request.Method == HttpMethod.Options.Method)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ internal EFCommandDiagnosticSourceHelper(IHub hub, SentryOptions options) : base

private static Guid? GetCommandId(object? diagnosticSourceValue) => diagnosticSourceValue?.GetGuidProperty("CommandId");

private static void SetCommandId(ISpan span, Guid? commandId)
private static void SetCommandId(ISpanTracer span, Guid? commandId)
{
Debug.Assert(commandId != Guid.Empty);

span.SetExtra(EFKeys.DbCommandId, commandId);
}

private static Guid? TryGetCommandId(ISpan span) => span.Extra.TryGetValue<string, Guid?>(EFKeys.DbCommandId);
private static Guid? TryGetCommandId(ISpanTracer span) => span.Extra.TryGetValue<string, Guid?>(EFKeys.DbCommandId);

protected override ISpan? GetSpanReference(ITransaction transaction, object? diagnosticSourceValue)
protected override ISpanTracer? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue)
{
if (GetCommandId(diagnosticSourceValue) is { } commandId)
{
Expand All @@ -38,7 +38,7 @@ private static void SetCommandId(ISpan span, Guid? commandId)
return null;
}

protected override void SetSpanReference(ISpan span, object? diagnosticSourceValue)
protected override void SetSpanReference(ISpanTracer span, object? diagnosticSourceValue)
{
if (GetCommandId(diagnosticSourceValue) is { } commandId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal EFConnectionDiagnosticSourceHelper(IHub hub, SentryOptions options) : b

protected override string? GetDescription(object? diagnosticSourceValue) => GetDatabaseName(diagnosticSourceValue);

protected override ISpan? GetSpanReference(ITransaction transaction, object? diagnosticSourceValue)
protected override ISpanTracer? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue)
{
if (GetConnectionId(diagnosticSourceValue) is { } connectionId)
{
Expand All @@ -27,7 +27,7 @@ internal EFConnectionDiagnosticSourceHelper(IHub hub, SentryOptions options) : b
return null;
}

protected override void SetSpanReference(ISpan span, object? diagnosticSourceValue)
protected override void SetSpanReference(ISpanTracer span, object? diagnosticSourceValue)
{
if (GetConnectionId(diagnosticSourceValue) is { } connectionId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sentry.Internal.DiagnosticSource;
internal abstract class EFDiagnosticSourceHelper
{
protected SentryOptions Options { get; }
protected ITransaction? Transaction { get; }
protected ITransactionTracer? Transaction { get; }
protected abstract string Operation { get; }

protected abstract string? GetDescription(object? diagnosticSourceValue);
Expand Down Expand Up @@ -39,11 +39,11 @@ internal EFDiagnosticSourceHelper(IHub hub, SentryOptions options)
Transaction = hub.GetTransactionIfSampled();
}

protected static Guid? TryGetConnectionId(ISpan span) => span.Extra.TryGetValue<string, Guid?>(EFKeys.DbConnectionId);
protected static Guid? TryGetConnectionId(ISpanTracer span) => span.Extra.TryGetValue<string, Guid?>(EFKeys.DbConnectionId);

protected static Guid? GetConnectionId(object? diagnosticSourceValue) => diagnosticSourceValue?.GetGuidProperty("ConnectionId");

protected static void SetConnectionId(ISpan span, Guid? connectionId)
protected static void SetConnectionId(ISpanTracer span, Guid? connectionId)
{
Debug.Assert(connectionId != Guid.Empty);

Expand Down Expand Up @@ -89,7 +89,7 @@ internal void FinishSpan(object? diagnosticSourceValue, SpanStatus status)
sourceSpan.Finish(status);
}

protected void SetDbData(ISpan span, object? diagnosticSourceValue)
protected void SetDbData(ISpanTracer span, object? diagnosticSourceValue)
{
if (GetDatabaseName(diagnosticSourceValue) is { } dataBaseName)
{
Expand Down Expand Up @@ -140,7 +140,7 @@ protected void LogTransactionSpans()
return str?[(str.IndexOf('\n') + 1)..];
}

protected abstract ISpan? GetSpanReference(ITransaction transaction, object? diagnosticSourceValue);
protected abstract ISpanTracer? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue);

protected abstract void SetSpanReference(ISpan span, object? diagnosticSourceValue);
protected abstract void SetSpanReference(ISpanTracer span, object? diagnosticSourceValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ internal EFQueryCompilerDiagnosticSourceHelper(IHub hub, SentryOptions options)
/// <summary>
/// We don't have a correlation id for compiled query events. We just return the first unfinished query compile span.
/// </summary>
protected override ISpan? GetSpanReference(ITransaction transaction, object? diagnosticSourceValue) =>
protected override ISpanTracer? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue) =>
transaction.Spans .FirstOrDefault(span => !span.IsFinished && span.Operation == Operation);

protected override void SetSpanReference(ISpan span, object? diagnosticSourceValue)
protected override void SetSpanReference(ISpanTracer span, object? diagnosticSourceValue)
{
// We don't have a correlation id for compiled query events.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,37 @@ public SentrySqlListener(IHub hub, SentryOptions options)
_options = options;
}

private static void SetDatabaseName(ISpan span, string databaseName)
private static void SetDatabaseName(ISpanTracer span, string databaseName)
{
Debug.Assert(databaseName != string.Empty);

span.SetExtra(OTelKeys.DbName, databaseName);
}

private static void SetDatabaseAddress(ISpan span, string databaseAddress)
private static void SetDatabaseAddress(ISpanTracer span, string databaseAddress)
{
Debug.Assert(databaseAddress != string.Empty);

span.SetExtra(OTelKeys.DbServer, databaseAddress);
}

private static void SetConnectionId(ISpan span, Guid? connectionId)
private static void SetConnectionId(ISpanTracer span, Guid? connectionId)
{
Debug.Assert(connectionId != Guid.Empty);

span.SetExtra(SqlKeys.DbConnectionId, connectionId);
}

private static void SetOperationId(ISpan span, Guid? operationId)
private static void SetOperationId(ISpanTracer span, Guid? operationId)
{
Debug.Assert(operationId != Guid.Empty);

span.SetExtra(SqlKeys.DbOperationId, operationId);
}

private static Guid? TryGetOperationId(ISpan span) => span.Extra.TryGetValue<string, Guid?>(SqlKeys.DbOperationId);
private static Guid? TryGetOperationId(ISpanTracer span) => span.Extra.TryGetValue<string, Guid?>(SqlKeys.DbOperationId);

private static Guid? TryGetConnectionId(ISpan span) => span.Extra.TryGetValue<string, Guid?>(SqlKeys.DbConnectionId);
private static Guid? TryGetConnectionId(ISpanTracer span) => span.Extra.TryGetValue<string, Guid?>(SqlKeys.DbConnectionId);

private void AddSpan(string operation, object? value)
{
Expand All @@ -85,7 +85,7 @@ private void AddSpan(string operation, object? value)
SetConnectionId(span, value?.GetGuidProperty("ConnectionId"));
}

private ISpan? GetSpan(SentrySqlSpanType type, object? value)
private ISpanTracer? GetSpan(SentrySqlSpanType type, object? value)
{
var transaction = _hub.GetTransactionIfSampled();
if (transaction == null)
Expand Down Expand Up @@ -124,15 +124,15 @@ private void AddSpan(string operation, object? value)
}
}

private static ISpan? TryGetConnectionSpan(ITransaction transaction, Guid? connectionId) =>
private static ISpanTracer? TryGetConnectionSpan(ITransactionTracer transaction, Guid? connectionId) =>
connectionId == null
? null
: transaction.Spans
.FirstOrDefault(span =>
span is {IsFinished: false, Operation: "db.connection"} &&
TryGetConnectionId(span) == connectionId);

private static ISpan? TryGetQuerySpan(ITransaction transaction, Guid? operationId) =>
private static ISpanTracer? TryGetQuerySpan(ITransactionTracer transaction, Guid? operationId) =>
operationId == null
? null
: transaction.Spans.FirstOrDefault(span => TryGetOperationId(span) == operationId);
Expand Down Expand Up @@ -248,7 +248,7 @@ when GetSpan(SentrySqlSpanType.Connection, kvp.Value) is { } closeSpan:
}
}

private static void TrySetConnectionStatistics(ISpan span, object? value)
private static void TrySetConnectionStatistics(ISpanTracer span, object? value)
{
if (value?.GetProperty("Statistics") is not Dictionary<object, object> statistics)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ namespace Sentry.EntityFramework;

internal static class DbCommandInterceptionContextExtensions
{
internal static ISpan? GetSpanFromContext<T>(this DbCommandInterceptionContext<T> interceptionContext)
=> interceptionContext.FindUserState(SentryQueryPerformanceListener.SentryUserStateKey) as ISpan;
internal static ISpanTracer? GetSpanFromContext<T>(this DbCommandInterceptionContext<T> interceptionContext)
=> interceptionContext.FindUserState(SentryQueryPerformanceListener.SentryUserStateKey) as ISpanTracer;

internal static void AttachSpan<T>(this DbCommandInterceptionContext<T> interceptionContext, ISpan span)
internal static void AttachSpan<T>(this DbCommandInterceptionContext<T> interceptionContext, ISpanTracer span)
=> interceptionContext.SetUserState(SentryQueryPerformanceListener.SentryUserStateKey, span);
}
2 changes: 1 addition & 1 deletion src/Sentry.OpenTelemetry/AspNetCoreEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class AspNetCoreEnricher : IOpenTelemetryEnricher

internal AspNetCoreEnricher(ISentryUserFactory userFactory) => _userFactory = userFactory;

public void Enrich(ISpan span, Activity activity, IHub hub, SentryOptions? options)
public void Enrich(ISpanTracer span, Activity activity, IHub hub, SentryOptions? options)
{
if (options?.SendDefaultPii is true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.OpenTelemetry/IOpenTelemetryEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace Sentry.OpenTelemetry;

internal interface IOpenTelemetryEnricher
{
void Enrich(ISpan span, Activity activity, IHub hub, SentryOptions? options);
void Enrich(ISpanTracer span, Activity activity, IHub hub, SentryOptions? options);
}
2 changes: 1 addition & 1 deletion src/Sentry.OpenTelemetry/SentrySpanProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SentrySpanProcessor : BaseProcessor<Activity>
private readonly IEnumerable<IOpenTelemetryEnricher> _enrichers;

// ReSharper disable once MemberCanBePrivate.Global - Used by tests
internal readonly ConcurrentDictionary<ActivitySpanId, ISpan> _map = new();
internal readonly ConcurrentDictionary<ActivitySpanId, ISpanTracer> _map = new();
private readonly SentryOptions? _options;
private readonly Lazy<IDictionary<string, object>> _resourceAttributes;

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Profiling/SamplingTransactionProfilerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private SamplingTransactionProfilerFactory(SentryOptions options, SampleProfiler
}

/// <inheritdoc />
public ITransactionProfiler? Start(ITransaction _, CancellationToken cancellationToken)
public ITransactionProfiler? Start(ITransactionTracer _, CancellationToken cancellationToken)
{
// Start a profiler if one wasn't running yet.
if (Interlocked.Exchange(ref _inProgress, TRUE) == FALSE)
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry/Extensibility/DisabledHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void WithScope(Action<Scope> scopeCallback)
/// <summary>
/// Returns a dummy transaction.
/// </summary>
public ITransaction StartTransaction(
public ITransactionTracer StartTransaction(
ITransactionContext context,
IReadOnlyDictionary<string, object?> customSamplingContext) =>
// Transactions from DisabledHub are always sampled out
Expand All @@ -60,14 +60,14 @@ public ITransaction StartTransaction(
/// <summary>
/// No-Op.
/// </summary>
public void BindException(Exception exception, ISpan span)
public void BindException(Exception exception, ISpanTracer span)
{
}

/// <summary>
/// Returns null.
/// </summary>
public ISpan? GetSpan() => null;
public ISpanTracer? GetSpan() => null;

/// <summary>
/// Returns null.
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/Extensibility/HubAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void WithScope(Action<Scope> scopeCallback)
/// Forwards the call to <see cref="SentrySdk"/>.
/// </summary>
[DebuggerStepThrough]
public ITransaction StartTransaction(
public ITransactionTracer StartTransaction(
ITransactionContext context,
IReadOnlyDictionary<string, object?> customSamplingContext)
=> SentrySdk.StartTransaction(context, customSamplingContext);
Expand All @@ -81,7 +81,7 @@ public ITransaction StartTransaction(
/// Forwards the call to <see cref="SentrySdk"/>.
/// </summary>
[DebuggerStepThrough]
internal ITransaction StartTransaction(
internal ITransactionTracer StartTransaction(
ITransactionContext context,
IReadOnlyDictionary<string, object?> customSamplingContext,
DynamicSamplingContext? dynamicSamplingContext)
Expand All @@ -91,14 +91,14 @@ internal ITransaction StartTransaction(
/// Forwards the call to <see cref="SentrySdk"/>.
/// </summary>
[DebuggerStepThrough]
public void BindException(Exception exception, ISpan span) =>
public void BindException(Exception exception, ISpanTracer span) =>
SentrySdk.BindException(exception, span);

/// <summary>
/// Forwards the call to <see cref="SentrySdk"/>.
/// </summary>
[DebuggerStepThrough]
public ISpan? GetSpan()
public ISpanTracer? GetSpan()
=> SentrySdk.GetSpan();

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions src/Sentry/HubExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public static class HubExtensions
/// <summary>
/// Starts a transaction.
/// </summary>
public static ITransaction StartTransaction(this IHub hub, ITransactionContext context) =>
public static ITransactionTracer StartTransaction(this IHub hub, ITransactionContext context) =>
hub.StartTransaction(context, new Dictionary<string, object?>());

/// <summary>
/// Starts a transaction.
/// </summary>
public static ITransaction StartTransaction(
public static ITransactionTracer StartTransaction(
this IHub hub,
string name,
string operation) =>
Expand All @@ -29,7 +29,7 @@ public static ITransaction StartTransaction(
/// <summary>
/// Starts a transaction.
/// </summary>
public static ITransaction StartTransaction(
public static ITransactionTracer StartTransaction(
this IHub hub,
string name,
string operation,
Expand All @@ -44,7 +44,7 @@ public static ITransaction StartTransaction(
/// <summary>
/// Starts a transaction from the specified trace header.
/// </summary>
public static ITransaction StartTransaction(
public static ITransactionTracer StartTransaction(
this IHub hub,
string name,
string operation,
Expand Down Expand Up @@ -224,7 +224,7 @@ public static SentryId CaptureMessage(this IHub hub, string message, Action<Scop
return hub.CaptureEvent(sentryEvent, configureScope);
}

internal static ITransaction StartTransaction(
internal static ITransactionTracer StartTransaction(
this IHub hub,
ITransactionContext context,
IReadOnlyDictionary<string, object?> customSamplingContext,
Expand All @@ -235,14 +235,14 @@ internal static ITransaction StartTransaction(
_ => hub.StartTransaction(context, customSamplingContext)
};

internal static ITransaction? GetTransaction(this IHub hub)
internal static ITransactionTracer? GetTransaction(this IHub hub)
{
ITransaction? transaction = null;
ITransactionTracer? transaction = null;
hub.ConfigureScope(scope => transaction = scope.Transaction);
return transaction;
}

internal static ITransaction? GetTransactionIfSampled(this IHub hub)
internal static ITransactionTracer? GetTransactionIfSampled(this IHub hub)
{
var transaction = hub.GetTransaction();
return transaction?.IsSampled == true ? transaction : null;
Expand Down
Loading

0 comments on commit ebbb500

Please sign in to comment.