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

feat: Renamed Sentry.Span to Sentry.SentrySpan #3021

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- Class renamed `Sentry.User` to `Sentry.SentryUser` ([#3015](https://github.com/getsentry/sentry-dotnet/pull/3015))
- Class renamed `Sentry.Runtime` to `Sentry.SentryRuntime` ([#3016](https://github.com/getsentry/sentry-dotnet/pull/3016))
- Class renamed `Sentry.Span` to `Sentry.SentrySpan` ([#3021](https://github.com/getsentry/sentry-dotnet/pull/3021))

### Dependencies

Expand Down
14 changes: 7 additions & 7 deletions src/Sentry/Span.cs → src/Sentry/SentrySpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Sentry;
/// <summary>
/// Transaction span.
/// </summary>
public class Span : ISpanData, IJsonSerializable
public class SentrySpan : ISpanData, IJsonSerializable
{
/// <inheritdoc />
public SpanId SpanId { get; private set; }
Expand Down Expand Up @@ -75,9 +75,9 @@ public void SetExtra(string key, object? value) =>
(_extra ??= new Dictionary<string, object?>())[key] = value;

/// <summary>
/// Initializes an instance of <see cref="Span"/>.
/// Initializes an instance of <see cref="SentrySpan"/>.
/// </summary>
public Span(SpanId? parentSpanId, string operation)
public SentrySpan(SpanId? parentSpanId, string operation)
{
SpanId = SpanId.Create();
ParentSpanId = parentSpanId;
Expand All @@ -86,9 +86,9 @@ public Span(SpanId? parentSpanId, string operation)
}

/// <summary>
/// Initializes an instance of <see cref="Span"/>.
/// Initializes an instance of <see cref="SentrySpan"/>.
/// </summary>
public Span(ISpan tracer)
public SentrySpan(ISpan tracer)
: this(tracer.ParentSpanId, tracer.Operation)
{
SpanId = tracer.SpanId;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
/// <summary>
/// Parses a span from JSON.
/// </summary>
public static Span FromJson(JsonElement json)
public static SentrySpan FromJson(JsonElement json)
{
var spanId = json.GetPropertyOrNull("span_id")?.Pipe(SpanId.FromJson) ?? SpanId.Empty;
var parentSpanId = json.GetPropertyOrNull("parent_span_id")?.Pipe(SpanId.FromJson);
Expand All @@ -156,7 +156,7 @@ public static Span FromJson(JsonElement json)
var measurements = json.GetPropertyOrNull("measurements")?.GetDictionaryOrNull(Measurement.FromJson);
var data = json.GetPropertyOrNull("data")?.GetDictionaryOrNull()?.ToDict();

return new Span(parentSpanId, operation)
return new SentrySpan(parentSpanId, operation)
{
SpanId = spanId,
TraceId = traceId,
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ public IReadOnlyList<string> Fingerprint
public IReadOnlyDictionary<string, string> Tags => _tags;

// Not readonly because of deserialization
private Span[] _spans = Array.Empty<Span>();
private SentrySpan[] _spans = Array.Empty<SentrySpan>();

/// <summary>
/// Flat list of spans within this transaction.
/// </summary>
public IReadOnlyCollection<Span> Spans => _spans;
public IReadOnlyCollection<SentrySpan> Spans => _spans;

/// <inheritdoc />
public bool IsFinished => EndTimestamp is not null;
Expand Down Expand Up @@ -265,7 +265,7 @@ public Transaction(ITransactionTracer tracer)
_tags = tracer.Tags.ToDict();
_spans = tracer.Spans
.Where(s => s is not SpanTracer { IsSentryRequest: true }) // Filter sentry requests created by Sentry.OpenTelemetry.SentrySpanProcessor
.Select(s => new Span(s)).ToArray();
.Select(s => new SentrySpan(s)).ToArray();
_measurements = tracer.Measurements.ToDict();

// Some items are not on the interface, but we only ever pass in a TransactionTracer anyway.
Expand Down Expand Up @@ -383,7 +383,7 @@ public static Transaction FromJson(JsonElement json)
var measurements = json.GetPropertyOrNull("measurements")?
.GetDictionaryOrNull(Measurement.FromJson) ?? new();
var spans = json.GetPropertyOrNull("spans")?
.EnumerateArray().Select(Span.FromJson).ToArray() ?? Array.Empty<Span>();
.EnumerateArray().Select(SentrySpan.FromJson).ToArray() ?? Array.Empty<SentrySpan>();

return new Transaction(name, nameSource)
{
Expand Down
4 changes: 2 additions & 2 deletions test/Sentry.Testing/VerifyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public static SettingsTask IgnoreStandardSentryMembers(this SettingsTask setting
.IgnoreStackTrace();
}

private class SpansConverter : WriteOnlyJsonConverter<IReadOnlyCollection<Span>>
private class SpansConverter : WriteOnlyJsonConverter<IReadOnlyCollection<SentrySpan>>
{
public override void Write(VerifyJsonWriter writer, IReadOnlyCollection<Span> spans)
public override void Write(VerifyJsonWriter writer, IReadOnlyCollection<SentrySpan> spans)
{
var ordered = spans
.OrderBy(x => x.StartTimestamp)
Expand Down
52 changes: 26 additions & 26 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,31 @@ namespace Sentry
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { }
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { }
}
public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public SentrySpan(Sentry.ISpan tracer) { }
public SentrySpan(Sentry.SpanId? parentSpanId, string operation) { }
public string? Description { get; set; }
public System.DateTimeOffset? EndTimestamp { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public bool IsFinished { get; }
public bool? IsSampled { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, Sentry.Protocol.Measurement> Measurements { get; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
public Sentry.SpanId SpanId { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; set; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
public Sentry.SentryId TraceId { get; }
public Sentry.SentryTraceHeader GetTraceHeader() { }
public void SetExtra(string key, object? value) { }
public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { }
public void SetTag(string key, string value) { }
public void UnsetTag(string key) { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.SentrySpan FromJson(System.Text.Json.JsonElement json) { }
}
public sealed class SentryStackFrame : Sentry.IJsonSerializable
{
public SentryStackFrame() { }
Expand Down Expand Up @@ -879,31 +904,6 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.SessionUpdate FromJson(System.Text.Json.JsonElement json) { }
}
public class Span : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public Span(Sentry.ISpan tracer) { }
public Span(Sentry.SpanId? parentSpanId, string operation) { }
public string? Description { get; set; }
public System.DateTimeOffset? EndTimestamp { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public bool IsFinished { get; }
public bool? IsSampled { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, Sentry.Protocol.Measurement> Measurements { get; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
public Sentry.SpanId SpanId { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; set; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
public Sentry.SentryId TraceId { get; }
public Sentry.SentryTraceHeader GetTraceHeader() { }
public void SetExtra(string key, object? value) { }
public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { }
public void SetTag(string key, string value) { }
public void UnsetTag(string key) { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.Span FromJson(System.Text.Json.JsonElement json) { }
}
public class SpanContext : Sentry.Protocol.ITraceContext
{
public SpanContext(string operation, Sentry.SpanId? spanId = default, Sentry.SpanId? parentSpanId = default, Sentry.SentryId? traceId = default, string? description = null, Sentry.SpanStatus? status = default, bool? isSampled = default) { }
Expand Down Expand Up @@ -1054,7 +1054,7 @@ namespace Sentry
public double? SampleRate { get; }
public Sentry.SdkVersion Sdk { get; }
public Sentry.SpanId SpanId { get; }
public System.Collections.Generic.IReadOnlyCollection<Sentry.Span> Spans { get; }
public System.Collections.Generic.IReadOnlyCollection<Sentry.SentrySpan> Spans { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
Expand Down
52 changes: 26 additions & 26 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,31 @@ namespace Sentry
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { }
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { }
}
public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public SentrySpan(Sentry.ISpan tracer) { }
public SentrySpan(Sentry.SpanId? parentSpanId, string operation) { }
public string? Description { get; set; }
public System.DateTimeOffset? EndTimestamp { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public bool IsFinished { get; }
public bool? IsSampled { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, Sentry.Protocol.Measurement> Measurements { get; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
public Sentry.SpanId SpanId { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; set; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
public Sentry.SentryId TraceId { get; }
public Sentry.SentryTraceHeader GetTraceHeader() { }
public void SetExtra(string key, object? value) { }
public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { }
public void SetTag(string key, string value) { }
public void UnsetTag(string key) { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.SentrySpan FromJson(System.Text.Json.JsonElement json) { }
}
public sealed class SentryStackFrame : Sentry.IJsonSerializable
{
public SentryStackFrame() { }
Expand Down Expand Up @@ -879,31 +904,6 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.SessionUpdate FromJson(System.Text.Json.JsonElement json) { }
}
public class Span : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public Span(Sentry.ISpan tracer) { }
public Span(Sentry.SpanId? parentSpanId, string operation) { }
public string? Description { get; set; }
public System.DateTimeOffset? EndTimestamp { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public bool IsFinished { get; }
public bool? IsSampled { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, Sentry.Protocol.Measurement> Measurements { get; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
public Sentry.SpanId SpanId { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; set; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
public Sentry.SentryId TraceId { get; }
public Sentry.SentryTraceHeader GetTraceHeader() { }
public void SetExtra(string key, object? value) { }
public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { }
public void SetTag(string key, string value) { }
public void UnsetTag(string key) { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.Span FromJson(System.Text.Json.JsonElement json) { }
}
public class SpanContext : Sentry.Protocol.ITraceContext
{
public SpanContext(string operation, Sentry.SpanId? spanId = default, Sentry.SpanId? parentSpanId = default, Sentry.SentryId? traceId = default, string? description = null, Sentry.SpanStatus? status = default, bool? isSampled = default) { }
Expand Down Expand Up @@ -1054,7 +1054,7 @@ namespace Sentry
public double? SampleRate { get; }
public Sentry.SdkVersion Sdk { get; }
public Sentry.SpanId SpanId { get; }
public System.Collections.Generic.IReadOnlyCollection<Sentry.Span> Spans { get; }
public System.Collections.Generic.IReadOnlyCollection<Sentry.SentrySpan> Spans { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
Expand Down
52 changes: 26 additions & 26 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,31 @@ namespace Sentry
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { }
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { }
}
public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public SentrySpan(Sentry.ISpan tracer) { }
public SentrySpan(Sentry.SpanId? parentSpanId, string operation) { }
public string? Description { get; set; }
public System.DateTimeOffset? EndTimestamp { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public bool IsFinished { get; }
public bool? IsSampled { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, Sentry.Protocol.Measurement> Measurements { get; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
public Sentry.SpanId SpanId { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; set; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
public Sentry.SentryId TraceId { get; }
public Sentry.SentryTraceHeader GetTraceHeader() { }
public void SetExtra(string key, object? value) { }
public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { }
public void SetTag(string key, string value) { }
public void UnsetTag(string key) { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.SentrySpan FromJson(System.Text.Json.JsonElement json) { }
}
public sealed class SentryStackFrame : Sentry.IJsonSerializable
{
public SentryStackFrame() { }
Expand Down Expand Up @@ -880,31 +905,6 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.SessionUpdate FromJson(System.Text.Json.JsonElement json) { }
}
public class Span : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public Span(Sentry.ISpan tracer) { }
public Span(Sentry.SpanId? parentSpanId, string operation) { }
public string? Description { get; set; }
public System.DateTimeOffset? EndTimestamp { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, object?> Extra { get; }
public bool IsFinished { get; }
public bool? IsSampled { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, Sentry.Protocol.Measurement> Measurements { get; }
public string Operation { get; set; }
public Sentry.SpanId? ParentSpanId { get; }
public Sentry.SpanId SpanId { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; set; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
public Sentry.SentryId TraceId { get; }
public Sentry.SentryTraceHeader GetTraceHeader() { }
public void SetExtra(string key, object? value) { }
public void SetMeasurement(string name, Sentry.Protocol.Measurement measurement) { }
public void SetTag(string key, string value) { }
public void UnsetTag(string key) { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
public static Sentry.Span FromJson(System.Text.Json.JsonElement json) { }
}
public class SpanContext : Sentry.Protocol.ITraceContext
{
public SpanContext(string operation, Sentry.SpanId? spanId = default, Sentry.SpanId? parentSpanId = default, Sentry.SentryId? traceId = default, string? description = null, Sentry.SpanStatus? status = default, bool? isSampled = default) { }
Expand Down Expand Up @@ -1055,7 +1055,7 @@ namespace Sentry
public double? SampleRate { get; }
public Sentry.SdkVersion Sdk { get; }
public Sentry.SpanId SpanId { get; }
public System.Collections.Generic.IReadOnlyCollection<Sentry.Span> Spans { get; }
public System.Collections.Generic.IReadOnlyCollection<Sentry.SentrySpan> Spans { get; }
public System.DateTimeOffset StartTimestamp { get; }
public Sentry.SpanStatus? Status { get; }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get; }
Expand Down
Loading