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

Kevin/randomize tests 2 #6508

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private void ProcessFolder(string folder, SearchOption searchOption)
// Is not part of the spec but useful for support tickets.
// We try to extract session variables (from out of process sessions)
// and try to send a message to the IPC server for setting the test.code_coverage.injected tag.
var extractedContext = SpanContextPropagator.Instance.Extract(
var extractedContext = TracerManager.Instance.SpanContextPropagator.Extract(
EnvironmentHelpers.GetEnvironmentVariables(),
new DictionaryGetterAndSetter(DictionaryGetterAndSetter.EnvironmentVariableKeyProcessor));

Expand Down
2 changes: 2 additions & 0 deletions tracer/src/Datadog.Trace.Tools.Runner/ConfigureCiCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ private async Task ExecuteAsync(InvocationContext context)
return;
}

await initResults.UploadRepositoryChangesTask().ConfigureAwait(false);

if (!TryExtractCiName(name, out var ciName))
{
context.ExitCode = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="SecurityReporter.cs" company="Datadog">
// <copyright file="SecurityReporter.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
Expand Down Expand Up @@ -98,7 +98,7 @@ internal void AddResponseHeadersToSpanAndCleanup()
_httpTransport.DisposeAdditiveContext();
}

private static void AddHeaderTags(Span span, IHeadersCollection headers, Dictionary<string, string?> headersToCollect, string prefix) => SpanContextPropagator.Instance.AddHeadersToSpanAsTags(span, headers, headersToCollect, defaultTagPrefix: prefix);
private static void AddHeaderTags(Span span, IHeadersCollection headers, Dictionary<string, string?> headersToCollect, string prefix) => TracerManager.Instance.SpanContextPropagator.AddHeadersToSpanAsTags(span, headers, headersToCollect, defaultTagPrefix: prefix);

private static void LogMatchesIfDebugEnabled(IReadOnlyCollection<object>? results, bool blocked)
{
Expand Down
6 changes: 3 additions & 3 deletions tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void OnBeginRequest(object sender, EventArgs eventArgs)
{
// extract propagated http headers
headers = requestHeaders.Wrap();
extractedContext = SpanContextPropagator.Instance.Extract(headers.Value).MergeBaggageInto(Baggage.Current);
extractedContext = tracer.TracerManager.SpanContextPropagator.Extract(headers.Value).MergeBaggageInto(Baggage.Current);
}
catch (Exception ex)
{
Expand All @@ -158,7 +158,7 @@ private void OnBeginRequest(object sender, EventArgs eventArgs)
scope.Span.DecorateWebServerSpan(resourceName: null, httpMethod, host, url, userAgent, tags);
if (headers is not null)
{
SpanContextPropagator.Instance.AddHeadersToSpanAsTags(scope.Span, headers.Value, tracer.Settings.HeaderTags, defaultTagPrefix: SpanContextPropagator.HttpRequestHeadersTagPrefix);
tracer.TracerManager.SpanContextPropagator.AddHeadersToSpanAsTags(scope.Span, headers.Value, tracer.Settings.HeaderTags, defaultTagPrefix: SpanContextPropagator.HttpRequestHeadersTagPrefix);
}

if (tracer.Settings.IpHeaderEnabled || Security.Instance.AppsecEnabled)
Expand All @@ -174,7 +174,7 @@ private void OnBeginRequest(object sender, EventArgs eventArgs)
if (HttpRuntime.UsingIntegratedPipeline)
{
var injectedContext = new PropagationContext(scope.Span.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(injectedContext, requestHeaders.Wrap());
tracer.TracerManager.SpanContextPropagator.Inject(injectedContext, requestHeaders.Wrap());
}

httpContext.Items[_httpContextScopeKey] = scope;
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/Ci/TestModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internal TestModule(string name, string? framework, string? frameworkVersion, Da

// Extract session variables (from out of process sessions)
var environmentVariables = EnvironmentHelpers.GetEnvironmentVariables();
var context = SpanContextPropagator.Instance.Extract(
var context = TracerManager.Instance.SpanContextPropagator.Extract(
environmentVariables, new DictionaryGetterAndSetter(DictionaryGetterAndSetter.EnvironmentVariableKeyProcessor));

if (context.SpanContext is { } sessionContext)
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/Ci/TestSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ private void OnIpcMessageReceived(object message)
[TestSuiteVisibilityTags.TestSessionWorkingDirectoryEnvironmentVariable] = tags.WorkingDirectory,
};

SpanContextPropagator.Instance.Inject(
TracerManager.Instance.SpanContextPropagator.Inject(
new PropagationContext(span.Context, Baggage.Current),
(IDictionary)environmentVariables,
new DictionaryGetterAndSetter(DictionaryGetterAndSetter.EnvironmentVariableKeyProcessor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static string BuildContextJson(PropagationContext context, string? event
var jsonBuilder = Util.StringBuilderCache.Acquire();
jsonBuilder.Append('{');

SpanContextPropagator.Instance.Inject(context, jsonBuilder, new StringBuilderCarrierSetter());
TracerManager.Instance.SpanContextPropagator.Inject(context, jsonBuilder, new StringBuilderCarrierSetter());

// Inject start time and bus name
var startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void InjectTraceIntoData<TRecordRequest>(TRecordRequest record, Sc

try
{
SpanContextPropagator.Instance.Inject(context, propagatedContext, default(DictionaryGetterAndSetter));
TracerManager.Instance.SpanContextPropagator.Inject(context, propagatedContext, default(DictionaryGetterAndSetter));
jsonData[KinesisKey] = propagatedContext;

var memoryStreamData = DictionaryToMemoryStream(jsonData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal abstract class LambdaCommon

internal static Scope CreatePlaceholderScope(Tracer tracer, NameValueHeadersCollection headers)
{
var context = SpanContextPropagator.Instance.Extract(headers).MergeBaggageInto(Baggage.Current);
var context = tracer.TracerManager.SpanContextPropagator.Extract(headers).MergeBaggageInto(Baggage.Current);

var span = tracer.StartSpan(
PlaceholderOperationName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private static void Inject(PropagationContext context, IDictionary messageAttrib
// Consolidate headers into one JSON object with <header_name>:<value>
var sb = Util.StringBuilderCache.Acquire();
sb.Append('{');
SpanContextPropagator.Instance.Inject(context, sb, default(StringBuilderCarrierSetter));
TracerManager.Instance.SpanContextPropagator.Inject(context, sb, default(StringBuilderCarrierSetter));

if (context.SpanContext?.PathwayContext is { } pathwayContext)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ internal static Scope CreateScope(ControllerContextStruct controllerContext)
{
// extract propagated http headers
headers = httpContext.Request.Headers.Wrap();
extractedContext = SpanContextPropagator.Instance.Extract(headers.Value).MergeBaggageInto(Baggage.Current);
extractedContext = tracer.TracerManager.SpanContextPropagator.Extract(headers.Value).MergeBaggageInto(Baggage.Current);
}
catch (Exception ex)
{
Expand All @@ -164,7 +164,7 @@ internal static Scope CreateScope(ControllerContextStruct controllerContext)

if (headers is not null)
{
SpanContextPropagator.Instance.AddHeadersToSpanAsTags(span, headers.Value, tracer.Settings.HeaderTags, SpanContextPropagator.HttpRequestHeadersTagPrefix);
tracer.TracerManager.SpanContextPropagator.AddHeadersToSpanAsTags(span, headers.Value, tracer.Settings.HeaderTags, SpanContextPropagator.HttpRequestHeadersTagPrefix);
}

if (tracer.Settings.IpHeaderEnabled || Security.Instance.AppsecEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal static Scope CreateScope(IHttpControllerContext controllerContext, out
{
// extract propagated http headers
headersCollection = new HttpHeadersCollection(request.Headers);
extractedContext = SpanContextPropagator.Instance.Extract(headersCollection.Value).MergeBaggageInto(Baggage.Current);
extractedContext = tracer.TracerManager.SpanContextPropagator.Extract(headersCollection.Value).MergeBaggageInto(Baggage.Current);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -101,7 +101,7 @@ internal static Scope CreateScope(IHttpControllerContext controllerContext, out

if (headersCollection is not null)
{
SpanContextPropagator.Instance.AddHeadersToSpanAsTags(scope.Span, headersCollection.Value, tracer.Settings.HeaderTags, SpanContextPropagator.HttpRequestHeadersTagPrefix, request.Headers.UserAgent.ToString());
tracer.TracerManager.SpanContextPropagator.AddHeadersToSpanAsTags(scope.Span, headersCollection.Value, tracer.Settings.HeaderTags, SpanContextPropagator.HttpRequestHeadersTagPrefix, request.Headers.UserAgent.ToString());
}

tags.SetAnalyticsSampleRate(IntegrationId, tracer.Settings, enabledWithGlobalSetting: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ internal static void OverridePropagatedContext<TTarget, TTypeData>(Tracer tracer
// the existing datadog headers
var useNullableHeaders = !string.IsNullOrEmpty(useNullableHeadersCapability);
var context = new PropagationContext(span.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(context, new RpcHttpHeadersCollection<TTarget>(typedData.Http, useNullableHeaders));
tracer.TracerManager.SpanContextPropagator.Inject(context, new RpcHttpHeadersCollection<TTarget>(typedData.Http, useNullableHeaders));
}
}

Expand Down Expand Up @@ -342,7 +342,7 @@ private static PropagationContext ExtractPropagatedContextFromHttp<T>(T context,
return default;
}

return SpanContextPropagator.Instance.Extract(new HttpHeadersCollection(httpRequest.Headers));
return TracerManager.Instance.SpanContextPropagator.Extract(new HttpHeadersCollection(httpRequest.Headers));
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="GrpcDotNetServerCommon.cs" company="Datadog">
// <copyright file="GrpcDotNetServerCommon.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
Expand Down Expand Up @@ -64,7 +64,7 @@ private static PropagationContext ExtractPropagatedContext(HttpRequest request)
// extract propagation details from http headers
if (request.Headers is { } requestHeaders)
{
return SpanContextPropagator.Instance.Extract(new HeadersCollectionAdapter(requestHeaders));
return TracerManager.Instance.SpanContextPropagator.Extract(new HeadersCollectionAdapter(requestHeaders));
}
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal static class GrpcDotNetClientCommon
// add distributed tracing headers to the HTTP request
// These will be overwritten by the HttpClient integration if that is enabled, per the RFC
var context = new PropagationContext(span.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(context, new HttpHeadersCollection(requestMessage.Headers));
tracer.TracerManager.SpanContextPropagator.Inject(context, new HttpHeadersCollection(requestMessage.Headers));

// Add the request metadata as tags
if (grpcCall.Options.Headers is { Count: > 0 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal static class GrpcLegacyClientCommon
{
// try extracting all the details we need
var requestMetadataWrapper = new MetadataHeadersCollection(requestMetadata);
var existingContext = SpanContextPropagator.Instance.Extract(requestMetadataWrapper);
var existingContext = tracer.TracerManager.SpanContextPropagator.Extract(requestMetadataWrapper);
var existingSpanContext = existingContext.SpanContext;

// If this operation creates the trace, then we will need to re-apply the sampling priority
Expand Down Expand Up @@ -145,7 +145,7 @@ public static void InjectHeaders<TMethod, TCallOptions>(Tracer tracer, TMethod m

// Add the propagation headers
var context = new PropagationContext(span.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(context, collection);
tracer.TracerManager.SpanContextPropagator.Inject(context, collection);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="GrpcLegacyServerCommon.cs" company="Datadog">
// <copyright file="GrpcLegacyServerCommon.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
Expand Down Expand Up @@ -68,7 +68,7 @@ private static PropagationContext ExtractPropagatedContext(IMetadata? metadata)
{
if (metadata is not null)
{
return SpanContextPropagator.Instance.Extract(new MetadataHeadersCollection(metadata));
return TracerManager.Instance.SpanContextPropagator.Extract(new MetadataHeadersCollection(metadata));
}
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static CallTargetState OnMethodBegin<TTarget, TRequest>(TTarget instance,

// add propagation headers to the HTTP request
var context = new PropagationContext(scope?.Span.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(context, new HttpHeadersCollection(headers));
tracer.TracerManager.SpanContextPropagator.Inject(context, new HttpHeadersCollection(headers));

return scope is null ? CallTargetState.GetDefault() : new CallTargetState(scope);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal static CallTargetState OnMethodBegin<TTarget>(TTarget instance, AsyncCa
// Additionally, add the request headers to a cache to indicate that distributed tracing headers were
// added by us, not the application
var context = new PropagationContext(span?.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(context, request.Headers.Wrap());
tracer.TracerManager.SpanContextPropagator.Inject(context, request.Headers.Wrap());
HeadersInjectedCache.SetInjectedHeaders(request.Headers);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="HttpWebRequest_EndGetResponseV9_Integration.cs" company="Datadog">
// <copyright file="HttpWebRequest_EndGetResponseV9_Integration.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>
Expand Down Expand Up @@ -63,7 +63,7 @@ public class HttpWebRequest_EndGetResponseV9_Integration
// We've already propagated baggage through the HTTP headers at this point,
// and when this method is called this is presumably the "bottom" of the call chain,
// and it may have been called on an entirely different thread.
existingContext = SpanContextPropagator.Instance.Extract(headers);
existingContext = TracerManager.Instance.SpanContextPropagator.Extract(headers);
}

var existingSpanContext = existingContext.SpanContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal static CallTargetReturn<TReturn> OnMethodEnd<TTarget, TReturn>(TTarget
// We've already propagated baggage through the HTTP headers at this point,
// and when this method is called this is presumably the "bottom" of the call chain,
// and it may have been called on an entirely different thread.
existingContext = SpanContextPropagator.Instance.Extract(headers);
existingContext = TracerManager.Instance.SpanContextPropagator.Extract(headers);
}

var existingSpanContext = existingContext.SpanContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static bool TryInjectHeaders<TTarget>(TTarget instance)
// Additionally, add the request headers to a cache to indicate that distributed tracing headers were
// added by us, not the application
var context = new PropagationContext(span?.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(context, request.Headers.Wrap());
tracer.TracerManager.SpanContextPropagator.Inject(context, request.Headers.Wrap());
HeadersInjectedCache.SetInjectedHeaders(request.Headers);
return true;
}
Expand All @@ -93,14 +93,15 @@ public static CallTargetState GetResponse_OnMethodBegin<TTarget>(TTarget instanc
// that we have injected context into
PropagationContext cachedContext = default;

var tracer = Tracer.Instance;

if (HeadersInjectedCache.TryGetInjectedHeaders(request.Headers))
{
var headers = request.Headers.Wrap();
cachedContext = SpanContextPropagator.Instance.Extract(headers).MergeBaggageInto(Baggage.Current);
cachedContext = tracer.TracerManager.SpanContextPropagator.Extract(headers).MergeBaggageInto(Baggage.Current);
}

var cachedSpanContext = cachedContext.SpanContext;
var tracer = Tracer.Instance;
int? cachedSamplingPriority = null;

// If this operation creates the trace, then we need to re-apply the sampling priority
Expand Down Expand Up @@ -132,7 +133,7 @@ public static CallTargetState GetResponse_OnMethodBegin<TTarget>(TTarget instanc
// add propagation headers to the HTTP request
var context = new PropagationContext(scope.Span.Context, Baggage.Current);
var headers = request.Headers.Wrap();
SpanContextPropagator.Instance.Inject(context, headers);
tracer.TracerManager.SpanContextPropagator.Inject(context, headers);

tracer.TracerManager.Telemetry.IntegrationGeneratedSpan(IntegrationId);
return new CallTargetState(scope);
Expand Down
Loading
Loading