Skip to content

Commit

Permalink
Undo renaming of ISpan (#2870)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell committed Nov 20, 2023
1 parent ebaed3e commit 84925a9
Show file tree
Hide file tree
Showing 41 changed files with 266 additions and 262 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased - 4.x

- ISpanTracer has been renamed back again to ISpan, to make it easier to upgrade from v3.x to v4.x ([#2870](https://github.com/getsentry/sentry-dotnet/pull/2870))

## 4.0.0-beta.1

### Features
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.AspNet/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static void FinishSentryTransaction(this HttpContext httpContext)
return;
}

if (httpContext.Items[HttpContextTransactionItemName] is not ISpanTracer transaction)
if (httpContext.Items[HttpContextTransactionItemName] is not ISpan transaction)
{
return;
}
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(ISpanTracer span, Guid? commandId)
private static void SetCommandId(ISpan span, Guid? commandId)
{
Debug.Assert(commandId != Guid.Empty);

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

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

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

protected override void SetSpanReference(ISpanTracer span, object? diagnosticSourceValue)
protected override void SetSpanReference(ISpan 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 ISpanTracer? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue)
protected override ISpan? 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(ISpanTracer span, object? diagnosticSourceValue)
protected override void SetSpanReference(ISpan span, object? diagnosticSourceValue)
{
if (GetConnectionId(diagnosticSourceValue) is { } connectionId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ internal EFDiagnosticSourceHelper(IHub hub, SentryOptions options)
Transaction = hub.GetTransactionIfSampled();
}

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

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

protected static void SetConnectionId(ISpanTracer span, Guid? connectionId)
protected static void SetConnectionId(ISpan 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(ISpanTracer span, object? diagnosticSourceValue)
protected void SetDbData(ISpan 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 ISpanTracer? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue);
protected abstract ISpan? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue);

protected abstract void SetSpanReference(ISpanTracer span, object? diagnosticSourceValue);
protected abstract void SetSpanReference(ISpan 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 ISpanTracer? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue) =>
protected override ISpan? GetSpanReference(ITransactionTracer transaction, object? diagnosticSourceValue) =>
transaction.Spans .FirstOrDefault(span => !span.IsFinished && span.Operation == Operation);

protected override void SetSpanReference(ISpanTracer span, object? diagnosticSourceValue)
protected override void SetSpanReference(ISpan 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(ISpanTracer span, string databaseName)
private static void SetDatabaseName(ISpan span, string databaseName)
{
Debug.Assert(databaseName != string.Empty);

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

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

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

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

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

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

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

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

private static Guid? TryGetConnectionId(ISpanTracer span) => span.Extra.TryGetValue<string, Guid?>(SqlKeys.DbConnectionId);
private static Guid? TryGetConnectionId(ISpan 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 ISpanTracer? GetSpan(SentrySqlSpanType type, object? value)
private ISpan? 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 ISpanTracer? TryGetConnectionSpan(ITransactionTracer transaction, Guid? connectionId) =>
private static ISpan? TryGetConnectionSpan(ITransactionTracer transaction, Guid? connectionId) =>
connectionId == null
? null
: transaction.Spans
.FirstOrDefault(span =>
span is {IsFinished: false, Operation: "db.connection"} &&
TryGetConnectionId(span) == connectionId);

private static ISpanTracer? TryGetQuerySpan(ITransactionTracer transaction, Guid? operationId) =>
private static ISpan? TryGetQuerySpan(ITransactionTracer transaction, Guid? operationId) =>
operationId == null
? null
: transaction.Spans.FirstOrDefault(span => TryGetOperationId(span) == operationId);
Expand Down Expand Up @@ -248,7 +248,7 @@ public void OnNext(KeyValuePair<string, object?> kvp)
}
}

private static void TrySetConnectionStatistics(ISpanTracer span, object? value)
private static void TrySetConnectionStatistics(ISpan 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 ISpanTracer? GetSpanFromContext<T>(this DbCommandInterceptionContext<T> interceptionContext)
=> interceptionContext.FindUserState(SentryQueryPerformanceListener.SentryUserStateKey) as ISpanTracer;
internal static ISpan? GetSpanFromContext<T>(this DbCommandInterceptionContext<T> interceptionContext)
=> interceptionContext.FindUserState(SentryQueryPerformanceListener.SentryUserStateKey) as ISpan;

internal static void AttachSpan<T>(this DbCommandInterceptionContext<T> interceptionContext, ISpanTracer span)
internal static void AttachSpan<T>(this DbCommandInterceptionContext<T> interceptionContext, ISpan 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(ISpanTracer span, Activity activity, IHub hub, SentryOptions? options)
public void Enrich(ISpan 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(ISpanTracer span, Activity activity, IHub hub, SentryOptions? options);
void Enrich(ISpan 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, ISpanTracer> _map = new();
internal readonly ConcurrentDictionary<ActivitySpanId, ISpan> _map = new();
private readonly SentryOptions? _options;
private readonly Lazy<IDictionary<string, object>> _resourceAttributes;

Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Extensibility/DisabledHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public void ConfigureScope(Action<Scope> configureScope)
/// <summary>
/// No-Op.
/// </summary>
public void BindException(Exception exception, ISpanTracer span)
public void BindException(Exception exception, ISpan span)
{
}

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

/// <summary>
/// Returns null.
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Extensibility/HubAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public IDisposable PushScope<TState>(TState state)
/// Forwards the call to <see cref="SentrySdk"/>.
/// </summary>
[DebuggerStepThrough]
public void BindException(Exception exception, ISpanTracer span) =>
public void BindException(Exception exception, ISpan span) =>
SentrySdk.BindException(exception, span);

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

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/IHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public interface IHub :
/// <remarks>
/// This method is used internally and is not meant for public use.
/// </remarks>
void BindException(Exception exception, ISpanTracer span);
void BindException(Exception exception, ISpan span);

/// <summary>
/// Gets the currently ongoing (not finished) span or <code>null</code> if none available.
/// </summary>
ISpanTracer? GetSpan();
ISpan? GetSpan();

/// <summary>
/// Gets the Sentry trace header that allows tracing across services
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/ISentryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface ISentryClient
/// </summary>
/// <remarks>
/// Note: this method is NOT meant to be called from user code!
/// Instead, call <see cref="ISpanTracer.Finish()"/> on the transaction.
/// Instead, call <see cref="ISpan.Finish()"/> on the transaction.
/// </remarks>
/// <param name="transaction">The transaction.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
Expand All @@ -41,7 +41,7 @@ public interface ISentryClient
/// </summary>
/// <remarks>
/// Note: this method is NOT meant to be called from user code!
/// Instead, call <see cref="ISpanTracer.Finish()"/> on the transaction.
/// Instead, call <see cref="ISpan.Finish()"/> on the transaction.
/// </remarks>
/// <param name="transaction">The transaction.</param>
/// <param name="scope">The scope to be applied to the transaction</param>
Expand Down
14 changes: 7 additions & 7 deletions src/Sentry/ISpanTracer.cs → src/Sentry/ISpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Sentry;
/// <summary>
/// SpanTracer interface
/// </summary>
public interface ISpanTracer : ISpanData
public interface ISpan : ISpanData
{
/// <summary>
/// Span description.
Expand All @@ -28,7 +28,7 @@ public interface ISpanTracer : ISpanData
/// <summary>
/// Starts a child span.
/// </summary>
ISpanTracer StartChild(string operation);
ISpan StartChild(string operation);

/// <summary>
/// Finishes the span.
Expand All @@ -52,23 +52,23 @@ public interface ISpanTracer : ISpanData
}

/// <summary>
/// Extensions for <see cref="ISpanTracer"/>.
/// Extensions for <see cref="ISpan"/>.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class SpanExtensions
{
/// <summary>
/// Starts a child span.
/// </summary>
public static ISpanTracer StartChild(this ISpanTracer span, string operation, string? description)
public static ISpan StartChild(this ISpan span, string operation, string? description)
{
var child = span.StartChild(operation);
child.Description = description;

return child;
}

internal static ISpanTracer StartChild(this ISpanTracer span, SpanContext context)
internal static ISpan StartChild(this ISpan span, SpanContext context)
{
var transaction = span.GetTransaction() as TransactionTracer;
if (transaction?.StartChild(context.SpanId, span.SpanId, context.Operation, context.Instrumenter)
Expand All @@ -84,7 +84,7 @@ internal static ISpanTracer StartChild(this ISpanTracer span, SpanContext contex
/// <summary>
/// Gets the transaction that this span belongs to.
/// </summary>
public static ITransactionTracer GetTransaction(this ISpanTracer span) =>
public static ITransactionTracer GetTransaction(this ISpan span) =>
span switch
{
ITransactionTracer transaction => transaction,
Expand All @@ -99,7 +99,7 @@ span switch
/// <remarks>
/// Used by EF, EF Core, and SQLClient integrations.
/// </remarks>
internal static ISpanTracer GetDbParentSpan(this ISpanTracer span)
internal static ISpan GetDbParentSpan(this ISpan span)
{
var transaction = span.GetTransaction();
return transaction.Spans
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry/ITransactionTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Sentry;
/// <summary>
/// TransactionTracer interface
/// </summary>
public interface ITransactionTracer : ITransactionData, ISpanTracer
public interface ITransactionTracer : ITransactionData, ISpan
{
/// <summary>
/// Transaction name.
Expand All @@ -20,10 +20,10 @@ public interface ITransactionTracer : ITransactionData, ISpanTracer
/// <summary>
/// Flat list of spans within this transaction.
/// </summary>
IReadOnlyCollection<ISpanTracer> Spans { get; }
IReadOnlyCollection<ISpan> Spans { get; }

/// <summary>
/// Gets the last active (not finished) span in this transaction.
/// </summary>
ISpanTracer? GetLastActiveSpan();
ISpan? GetLastActiveSpan();
}
Loading

0 comments on commit 84925a9

Please sign in to comment.