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

Use ActivityTraceId/ActivitySpanId for exemplars #2125

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
18 changes: 9 additions & 9 deletions src/OpenTelemetry/Metrics/DataPoint/Exemplar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace OpenTelemetry.Metrics
{
internal readonly struct Exemplar : IExemplar
{
private static readonly KeyValuePair<string, object>[] EmptyTag = new KeyValuePair<string, object>[0];
private static readonly byte[] EmptyId = new byte[0];

private readonly IDataValue value;

internal Exemplar(DateTimeOffset timestamp, long value, byte[] spanId, byte[] traceId, KeyValuePair<string, object>[] filteredTags)
internal Exemplar(DateTimeOffset timestamp, long value, ActivityTraceId traceId, ActivitySpanId spanId, KeyValuePair<string, object>[] filteredTags)
{
this.Timestamp = timestamp;
this.FilteredTags = filteredTags;
Expand All @@ -35,7 +35,7 @@ internal Exemplar(DateTimeOffset timestamp, long value, byte[] spanId, byte[] tr
this.value = new DataValue<long>(value);
}

internal Exemplar(DateTimeOffset timestamp, double value, byte[] spanId, byte[] traceId, KeyValuePair<string, object>[] filteredTags)
internal Exemplar(DateTimeOffset timestamp, double value, ActivityTraceId traceId, ActivitySpanId spanId, KeyValuePair<string, object>[] filteredTags)
{
this.Timestamp = timestamp;
this.FilteredTags = filteredTags;
Expand All @@ -44,7 +44,7 @@ internal Exemplar(DateTimeOffset timestamp, double value, byte[] spanId, byte[]
this.value = new DataValue<double>(value);
}

internal Exemplar(DateTimeOffset timestamp, IDataValue value, byte[] spanId, byte[] traceId, KeyValuePair<string, object>[] filteredTags)
internal Exemplar(DateTimeOffset timestamp, IDataValue value, ActivityTraceId traceId, ActivitySpanId spanId, KeyValuePair<string, object>[] filteredTags)
{
this.Timestamp = timestamp;
this.FilteredTags = filteredTags;
Expand All @@ -54,27 +54,27 @@ internal Exemplar(DateTimeOffset timestamp, IDataValue value, byte[] spanId, byt
}

internal Exemplar(DateTimeOffset timestamp, long value)
: this(timestamp, value, Exemplar.EmptyId, Exemplar.EmptyId, Exemplar.EmptyTag)
: this(timestamp, value, default, default, Exemplar.EmptyTag)
{
}

internal Exemplar(DateTimeOffset timestamp, double value)
: this(timestamp, value, Exemplar.EmptyId, Exemplar.EmptyId, Exemplar.EmptyTag)
: this(timestamp, value, default, default, Exemplar.EmptyTag)
{
}

internal Exemplar(DateTimeOffset timestamp, IDataValue value)
: this(timestamp, value, Exemplar.EmptyId, Exemplar.EmptyId, Exemplar.EmptyTag)
: this(timestamp, value, default, default, Exemplar.EmptyTag)
{
}

public DateTimeOffset Timestamp { get; }

public readonly KeyValuePair<string, object>[] FilteredTags { get; }

public readonly byte[] SpanId { get; }
public readonly ActivityTraceId TraceId { get; }

public readonly byte[] TraceId { get; }
public readonly ActivitySpanId SpanId { get; }

public object Value => this.value.Value;
}
Expand Down
14 changes: 7 additions & 7 deletions src/OpenTelemetry/Metrics/DataPoint/Exemplar{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace OpenTelemetry.Metrics
{
internal readonly struct Exemplar<T> : IExemplar
where T : struct
{
private static readonly KeyValuePair<string, object>[] EmptyTag = new KeyValuePair<string, object>[0];
private static readonly byte[] EmptyId = new byte[0];

private readonly IDataValue value;

internal Exemplar(DateTimeOffset timestamp, T value, byte[] spanId, byte[] traceId, KeyValuePair<string, object>[] filteredTags)
internal Exemplar(DateTimeOffset timestamp, T value, ActivityTraceId traceId, ActivitySpanId spanId, KeyValuePair<string, object>[] filteredTags)
{
this.Timestamp = timestamp;
this.FilteredTags = filteredTags;
Expand All @@ -36,7 +36,7 @@ internal Exemplar(DateTimeOffset timestamp, T value, byte[] spanId, byte[] trace
this.value = new DataValue<T>(value);
}

internal Exemplar(DateTimeOffset timestamp, IDataValue value, byte[] spanId, byte[] traceId, KeyValuePair<string, object>[] filteredTags)
internal Exemplar(DateTimeOffset timestamp, IDataValue value, ActivityTraceId traceId, ActivitySpanId spanId, KeyValuePair<string, object>[] filteredTags)
{
this.Timestamp = timestamp;
this.FilteredTags = filteredTags;
Expand All @@ -46,22 +46,22 @@ internal Exemplar(DateTimeOffset timestamp, IDataValue value, byte[] spanId, byt
}

internal Exemplar(DateTimeOffset timestamp, T value)
: this(timestamp, value, Exemplar<T>.EmptyId, Exemplar<T>.EmptyId, Exemplar<T>.EmptyTag)
: this(timestamp, value, default, default, Exemplar<T>.EmptyTag)
{
}

internal Exemplar(DateTimeOffset timestamp, IDataValue value)
: this(timestamp, value, Exemplar<T>.EmptyId, Exemplar<T>.EmptyId, Exemplar<T>.EmptyTag)
: this(timestamp, value, default, default, Exemplar<T>.EmptyTag)
{
}

public DateTimeOffset Timestamp { get; }

public readonly KeyValuePair<string, object>[] FilteredTags { get; }

public readonly byte[] SpanId { get; }
public readonly ActivityTraceId TraceId { get; }

public readonly byte[] TraceId { get; }
public readonly ActivitySpanId SpanId { get; }

public object Value => this.value.Value;
}
Expand Down
5 changes: 3 additions & 2 deletions src/OpenTelemetry/Metrics/DataPoint/IExemplar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace OpenTelemetry.Metrics
{
Expand All @@ -25,8 +26,8 @@ public interface IExemplar : IDataValue

KeyValuePair<string, object>[] FilteredTags { get; }

byte[] SpanId { get; }
ActivityTraceId TraceId { get; }

byte[] TraceId { get; }
ActivitySpanId SpanId { get; }
}
}