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

Renamed ISpan and ITransaction to ISpanTracer and ITransactionTracer #2731

Merged
merged 6 commits into from Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -31,6 +31,7 @@ API Changes:
- Removed the `Scope.Platform` property as it was never applied. ([#2695](https://github.com/getsentry/sentry-dotnet/pull/2695))
- 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))
- `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
1 change: 1 addition & 0 deletions Sentry-CI-Build-Windows.slnf
Expand Up @@ -32,6 +32,7 @@
"src\\Sentry.AspNetCore\\Sentry.AspNetCore.csproj",
"src\\Sentry.Azure.Functions.Worker\\Sentry.Azure.Functions.Worker.csproj",
"src\\Sentry.Bindings.Android\\Sentry.Bindings.Android.csproj",
"src\\Sentry.Bindings.Native\\Sentry.Bindings.Native.csproj",
"src\\Sentry.DiagnosticSource\\Sentry.DiagnosticSource.csproj",
"src\\Sentry.EntityFramework\\Sentry.EntityFramework.csproj",
"src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj",
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Sentry.Benchmarks/StackFrameBenchmarks.cs
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
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
Expand Up @@ -27,7 +27,7 @@ internal class SentryTracingMiddleware
_options = options.Value;
}

private ITransaction? TryStartTransaction(HttpContext context)
private ITransactionTracer? TryStartTransaction(HttpContext context)
{
if (context.Request.Method == HttpMethod.Options.Method)
{
Expand Down
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
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
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);
}
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
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 @@ public void OnNext(KeyValuePair<string, object?> kvp)
}
}

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
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
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
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
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
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
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 void WithScope(Action<Scope> scopeCallback)
/// <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
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 void WithScope(Action<Scope> scopeCallback)
/// 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 @@ public void WithScope(Action<Scope> scopeCallback)
/// 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