Skip to content

Commit

Permalink
Improvements (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo authored Nov 25, 2024
1 parent fd7981a commit 2df916f
Show file tree
Hide file tree
Showing 16 changed files with 383 additions and 561 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.1.22</Version>
<Version>0.2.0</Version>
<Authors>Tony Redondo, Grégory Léocadie</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
147 changes: 0 additions & 147 deletions src/TimeItSharp.Common/AsyncUtil.cs

This file was deleted.

21 changes: 6 additions & 15 deletions src/TimeItSharp.Common/DatadogMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,22 @@ namespace TimeItSharp.Common;
internal static class DatadogMetadata
{
private static readonly ConcurrentDictionary<object, Metadata> MetadataByExecution;
private static readonly bool UseAllBits;

static DatadogMetadata()
{
MetadataByExecution = new();
CIVisibility.InitializeFromManualInstrumentation();
UseAllBits = CIVisibility.Settings.TracerSettings?.TraceId128BitGenerationEnabled ?? true;
}

public static void GetIds(object key, out TraceId traceId, out ulong spanId)
{
var value = MetadataByExecution.GetOrAdd(key, @case => new());
if (value.TraceId is null)
{
var useAllBits = CIVisibility.Settings.TracerSettings?.TraceId128BitGenerationEnabled ?? true;
value.TraceId = RandomIdGenerator.Shared.NextTraceId(useAllBits);
value.SpanId = RandomIdGenerator.Shared.NextSpanId(useAllBits);
}

traceId = value.TraceId.Value;
var value = MetadataByExecution.GetOrAdd(key, @case => new Metadata(RandomIdGenerator.Shared.NextTraceId(UseAllBits),
RandomIdGenerator.Shared.NextSpanId(UseAllBits)));
traceId = value.TraceId;
spanId = value.SpanId;
}

private class Metadata
{
public TraceId? TraceId { get; set; }

public ulong SpanId { get; set; }
}
private record struct Metadata(TraceId TraceId, ulong SpanId);
}
Loading

0 comments on commit 2df916f

Please sign in to comment.