fix analysis issues: CA2000 (#4038)
This commit is contained in:
parent
d68307b1e7
commit
55556af592
|
|
@ -47,7 +47,7 @@ namespace Examples.Console
|
||||||
.AddConsoleExporter()
|
.AddConsoleExporter()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var source = new ActivitySource("grpc-net-client-test");
|
using var source = new ActivitySource("grpc-net-client-test");
|
||||||
using (var parent = source.StartActivity("Main", ActivityKind.Server))
|
using (var parent = source.StartActivity("Main", ActivityKind.Server))
|
||||||
{
|
{
|
||||||
using var channel = GrpcChannel.ForAddress("https://localhost:44335");
|
using var channel = GrpcChannel.ForAddress("https://localhost:44335");
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Examples.Console
|
||||||
.AddConsoleExporter()
|
.AddConsoleExporter()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var source = new ActivitySource("http-client-test");
|
using var source = new ActivitySource("http-client-test");
|
||||||
using (var parent = source.StartActivity("incoming request", ActivityKind.Server))
|
using (var parent = source.StartActivity("incoming request", ActivityKind.Server))
|
||||||
{
|
{
|
||||||
using var client = new HttpClient();
|
using var client = new HttpClient();
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ namespace Examples.Console
|
||||||
internal static object Run()
|
internal static object Run()
|
||||||
{
|
{
|
||||||
var zpagesOptions = new ZPagesExporterOptions() { Url = "http://localhost:7284/rpcz/", RetentionTime = 3600000 };
|
var zpagesOptions = new ZPagesExporterOptions() { Url = "http://localhost:7284/rpcz/", RetentionTime = 3600000 };
|
||||||
var zpagesExporter = new ZPagesExporter(zpagesOptions);
|
using var zpagesExporter = new ZPagesExporter(zpagesOptions);
|
||||||
var httpServer = new ZPagesExporterStatsHttpServer(zpagesExporter);
|
using var httpServer = new ZPagesExporterStatsHttpServer(zpagesExporter);
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
httpServer.Start();
|
httpServer.Start();
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Examples.Console
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
ActivitySource activitySource = new ActivitySource("zpages-test");
|
using var activitySource = new ActivitySource("zpages-test");
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace OpenTelemetry.Benchmarks
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
public void EventWithIdAllocation()
|
public void EventWithIdAllocation()
|
||||||
{
|
{
|
||||||
Activity activity = new Activity("TestActivity");
|
using var activity = new Activity("TestActivity");
|
||||||
activity.SetIdFormat(ActivityIdFormat.W3C);
|
activity.SetIdFormat(ActivityIdFormat.W3C);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
@ -36,7 +36,7 @@ namespace OpenTelemetry.Benchmarks
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
public void EventWithCheck()
|
public void EventWithCheck()
|
||||||
{
|
{
|
||||||
Activity activity = new Activity("TestActivity");
|
using var activity = new Activity("TestActivity");
|
||||||
activity.SetIdFormat(ActivityIdFormat.W3C);
|
activity.SetIdFormat(ActivityIdFormat.W3C);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ namespace Benchmarks.Exporter
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
public void ZipkinExporter_Batching()
|
public void ZipkinExporter_Batching()
|
||||||
{
|
{
|
||||||
var exporter = new ZipkinExporter(
|
using var exporter = new ZipkinExporter(
|
||||||
new ZipkinExporterOptions
|
new ZipkinExporterOptions
|
||||||
{
|
{
|
||||||
Endpoint = new Uri($"http://{this.serverHost}:{this.serverPort}"),
|
Endpoint = new Uri($"http://{this.serverHost}:{this.serverPort}"),
|
||||||
|
|
|
||||||
|
|
@ -50,17 +50,17 @@ namespace Benchmarks.Logs
|
||||||
|
|
||||||
public LogBenchmarks()
|
public LogBenchmarks()
|
||||||
{
|
{
|
||||||
var loggerFactoryWithNoListener = LoggerFactory.Create(builder => { });
|
using var loggerFactoryWithNoListener = LoggerFactory.Create(builder => { });
|
||||||
this.loggerWithNoListener = loggerFactoryWithNoListener.CreateLogger<LogBenchmarks>();
|
this.loggerWithNoListener = loggerFactoryWithNoListener.CreateLogger<LogBenchmarks>();
|
||||||
|
|
||||||
var loggerFactoryWithOneProcessor = LoggerFactory.Create(builder =>
|
using var loggerFactoryWithOneProcessor = LoggerFactory.Create(builder =>
|
||||||
{
|
{
|
||||||
builder.AddOpenTelemetry(options => options
|
builder.AddOpenTelemetry(options => options
|
||||||
.AddProcessor(new DummyLogProcessor()));
|
.AddProcessor(new DummyLogProcessor()));
|
||||||
});
|
});
|
||||||
this.loggerWithOneProcessor = loggerFactoryWithOneProcessor.CreateLogger<LogBenchmarks>();
|
this.loggerWithOneProcessor = loggerFactoryWithOneProcessor.CreateLogger<LogBenchmarks>();
|
||||||
|
|
||||||
var loggerFactoryWithTwoProcessor = LoggerFactory.Create(builder =>
|
using var loggerFactoryWithTwoProcessor = LoggerFactory.Create(builder =>
|
||||||
{
|
{
|
||||||
builder.AddOpenTelemetry(options => options
|
builder.AddOpenTelemetry(options => options
|
||||||
.AddProcessor(new DummyLogProcessor())
|
.AddProcessor(new DummyLogProcessor())
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Benchmarks.Logs
|
||||||
});
|
});
|
||||||
this.loggerWithTwoProcessors = loggerFactoryWithTwoProcessor.CreateLogger<LogBenchmarks>();
|
this.loggerWithTwoProcessors = loggerFactoryWithTwoProcessor.CreateLogger<LogBenchmarks>();
|
||||||
|
|
||||||
var loggerFactoryWithThreeProcessor = LoggerFactory.Create(builder =>
|
using var loggerFactoryWithThreeProcessor = LoggerFactory.Create(builder =>
|
||||||
{
|
{
|
||||||
builder.AddOpenTelemetry(options => options
|
builder.AddOpenTelemetry(options => options
|
||||||
.AddProcessor(new DummyLogProcessor())
|
.AddProcessor(new DummyLogProcessor())
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
[InlineData(false)]
|
[InlineData(false)]
|
||||||
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_AllPropertiesSet(bool isRootSpan)
|
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_AllPropertiesSet(bool isRootSpan)
|
||||||
{
|
{
|
||||||
var activity = CreateTestActivity(isRootSpan: isRootSpan);
|
using var activity = CreateTestActivity(isRootSpan: isRootSpan);
|
||||||
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
||||||
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
||||||
var linkTraceIdAsInt = new Int128(activity.Links.Single().Context.TraceId);
|
var linkTraceIdAsInt = new Int128(activity.Links.Single().Context.TraceId);
|
||||||
|
|
@ -128,7 +128,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_NoAttributes()
|
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_NoAttributes()
|
||||||
{
|
{
|
||||||
var activity = CreateTestActivity(setAttributes: false);
|
using var activity = CreateTestActivity(setAttributes: false);
|
||||||
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
||||||
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
||||||
var linkTraceIdAsInt = new Int128(activity.Links.Single().Context.TraceId);
|
var linkTraceIdAsInt = new Int128(activity.Links.Single().Context.TraceId);
|
||||||
|
|
@ -187,7 +187,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_NoEvents()
|
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_NoEvents()
|
||||||
{
|
{
|
||||||
var activity = CreateTestActivity(addEvents: false);
|
using var activity = CreateTestActivity(addEvents: false);
|
||||||
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
||||||
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
||||||
var linkTraceIdAsInt = new Int128(activity.Links.Single().Context.TraceId);
|
var linkTraceIdAsInt = new Int128(activity.Links.Single().Context.TraceId);
|
||||||
|
|
@ -245,7 +245,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_NoLinks()
|
public void JaegerActivityConverterTest_ConvertActivityToJaegerSpan_NoLinks()
|
||||||
{
|
{
|
||||||
var activity = CreateTestActivity(addLinks: false, ticksToAdd: 8000);
|
using var activity = CreateTestActivity(addLinks: false, ticksToAdd: 8000);
|
||||||
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
var traceIdAsInt = new Int128(activity.Context.TraceId);
|
||||||
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
var spanIdAsInt = new Int128(activity.Context.SpanId);
|
||||||
|
|
||||||
|
|
@ -357,7 +357,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void JaegerActivityConverterTest_GenerateJaegerSpan_RemoteEndpointOmittedByDefault()
|
public void JaegerActivityConverterTest_GenerateJaegerSpan_RemoteEndpointOmittedByDefault()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var span = CreateTestActivity();
|
using var span = CreateTestActivity();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jaegerSpan = span.ToJaegerSpan();
|
var jaegerSpan = span.ToJaegerSpan();
|
||||||
|
|
@ -370,7 +370,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void JaegerActivityConverterTest_GenerateJaegerSpan_RemoteEndpointResolution()
|
public void JaegerActivityConverterTest_GenerateJaegerSpan_RemoteEndpointResolution()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var span = CreateTestActivity(
|
using var span = CreateTestActivity(
|
||||||
additionalAttributes: new Dictionary<string, object>
|
additionalAttributes: new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
["net.peer.name"] = "RemoteServiceName",
|
["net.peer.name"] = "RemoteServiceName",
|
||||||
|
|
@ -388,7 +388,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void JaegerActivityConverterTest_GenerateJaegerSpan_PeerServiceNameIgnoredForServerSpan()
|
public void JaegerActivityConverterTest_GenerateJaegerSpan_PeerServiceNameIgnoredForServerSpan()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var span = CreateTestActivity(
|
using var span = CreateTestActivity(
|
||||||
additionalAttributes: new Dictionary<string, object>
|
additionalAttributes: new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
["http.host"] = "DiscardedRemoteServiceName",
|
["http.host"] = "DiscardedRemoteServiceName",
|
||||||
|
|
@ -408,7 +408,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void JaegerActivityConverterTest_GenerateJaegerSpan_RemoteEndpointResolutionPriority(RemoteEndpointPriorityTestCase testCase)
|
public void JaegerActivityConverterTest_GenerateJaegerSpan_RemoteEndpointResolutionPriority(RemoteEndpointPriorityTestCase testCase)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = CreateTestActivity(additionalAttributes: testCase.RemoteEndpointAttributes);
|
using var activity = CreateTestActivity(additionalAttributes: testCase.RemoteEndpointAttributes);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jaegerSpan = activity.ToJaegerSpan();
|
var jaegerSpan = activity.ToJaegerSpan();
|
||||||
|
|
@ -424,7 +424,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void JaegerActivityConverterTest_NullTagValueTest()
|
public void JaegerActivityConverterTest_NullTagValueTest()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = CreateTestActivity(additionalAttributes: new Dictionary<string, object> { ["nullTag"] = null });
|
using var activity = CreateTestActivity(additionalAttributes: new Dictionary<string, object> { ["nullTag"] = null });
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var jaegerSpan = activity.ToJaegerSpan();
|
var jaegerSpan = activity.ToJaegerSpan();
|
||||||
|
|
@ -441,7 +441,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void JaegerActivityConverterTest_Status_ErrorFlagTest(StatusCode expectedStatusCode, string statusCodeTagValue, string statusDescription)
|
public void JaegerActivityConverterTest_Status_ErrorFlagTest(StatusCode expectedStatusCode, string statusCodeTagValue, string statusDescription)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = CreateTestActivity();
|
using var activity = CreateTestActivity();
|
||||||
activity.SetTag(SpanAttributeConstants.StatusCodeKey, statusCodeTagValue);
|
activity.SetTag(SpanAttributeConstants.StatusCodeKey, statusCodeTagValue);
|
||||||
activity.SetTag(SpanAttributeConstants.StatusDescriptionKey, statusDescription);
|
activity.SetTag(SpanAttributeConstants.StatusDescriptionKey, statusDescription);
|
||||||
|
|
||||||
|
|
@ -487,7 +487,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void ToJaegerSpan_Activity_Status_And_StatusDescription_is_Set(ActivityStatusCode expectedStatusCode)
|
public void ToJaegerSpan_Activity_Status_And_StatusDescription_is_Set(ActivityStatusCode expectedStatusCode)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = CreateTestActivity();
|
using var activity = CreateTestActivity();
|
||||||
activity.SetStatus(expectedStatusCode);
|
activity.SetStatus(expectedStatusCode);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -528,7 +528,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsOk()
|
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsOk()
|
||||||
{
|
{
|
||||||
// Arrange.
|
// Arrange.
|
||||||
var activity = CreateTestActivity();
|
using var activity = CreateTestActivity();
|
||||||
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
||||||
activity.SetStatus(ActivityStatusCode.Ok);
|
activity.SetStatus(ActivityStatusCode.Ok);
|
||||||
activity.SetTag(SpanAttributeConstants.StatusCodeKey, "ERROR");
|
activity.SetTag(SpanAttributeConstants.StatusCodeKey, "ERROR");
|
||||||
|
|
@ -557,7 +557,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsError()
|
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsError()
|
||||||
{
|
{
|
||||||
// Arrange.
|
// Arrange.
|
||||||
var activity = CreateTestActivity();
|
using var activity = CreateTestActivity();
|
||||||
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
||||||
activity.SetStatus(ActivityStatusCode.Error, StatusDescriptionOnError);
|
activity.SetStatus(ActivityStatusCode.Error, StatusDescriptionOnError);
|
||||||
activity.SetTag(SpanAttributeConstants.StatusCodeKey, "OK");
|
activity.SetTag(SpanAttributeConstants.StatusCodeKey, "OK");
|
||||||
|
|
@ -584,7 +584,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
public void ActivityDescription_Takes_precedence_Over_Status_Tags_When_ActivityStatusCodeIsError()
|
public void ActivityDescription_Takes_precedence_Over_Status_Tags_When_ActivityStatusCodeIsError()
|
||||||
{
|
{
|
||||||
// Arrange.
|
// Arrange.
|
||||||
var activity = CreateTestActivity();
|
using var activity = CreateTestActivity();
|
||||||
|
|
||||||
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
||||||
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
||||||
|
|
@ -678,7 +678,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
|
|
||||||
var linkedSpanId = ActivitySpanId.CreateFromString("888915b6286b9c41".AsSpan());
|
var linkedSpanId = ActivitySpanId.CreateFromString("888915b6286b9c41".AsSpan());
|
||||||
|
|
||||||
var activitySource = new ActivitySource(nameof(CreateTestActivity));
|
using var activitySource = new ActivitySource(nameof(CreateTestActivity));
|
||||||
|
|
||||||
var tags = setAttributes ?
|
var tags = setAttributes ?
|
||||||
attributes
|
attributes
|
||||||
|
|
@ -693,7 +693,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation.Tests
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var activity = activitySource.StartActivity(
|
using var activity = activitySource.StartActivity(
|
||||||
"Name",
|
"Name",
|
||||||
kind,
|
kind,
|
||||||
parentContext: new ActivityContext(traceId, parentSpanId, ActivityTraceFlags.Recorded),
|
parentContext: new ActivityContext(traceId, parentSpanId, ActivityTraceFlags.Recorded),
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,14 @@ namespace OpenTelemetry.Exporter.ZPages.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CheckingPurge()
|
public void CheckingPurge()
|
||||||
{
|
{
|
||||||
ZPagesActivityTracker.CurrentHourList.TryAdd("new", new ZPagesActivityAggregate(new Activity("new")));
|
using var activity1 = new Activity("new");
|
||||||
|
ZPagesActivityTracker.CurrentHourList.TryAdd("new", new ZPagesActivityAggregate(activity1));
|
||||||
Assert.NotEmpty(ZPagesActivityTracker.CurrentHourList);
|
Assert.NotEmpty(ZPagesActivityTracker.CurrentHourList);
|
||||||
ZPagesActivityTracker.PurgeCurrentHourData(null, null);
|
ZPagesActivityTracker.PurgeCurrentHourData(null, null);
|
||||||
Assert.Empty(ZPagesActivityTracker.CurrentHourList);
|
Assert.Empty(ZPagesActivityTracker.CurrentHourList);
|
||||||
|
|
||||||
ZPagesActivityTracker.CurrentMinuteList.TryAdd("new", new ZPagesActivityAggregate(new Activity("new")));
|
using var activity2 = new Activity("new");
|
||||||
|
ZPagesActivityTracker.CurrentMinuteList.TryAdd("new", new ZPagesActivityAggregate(activity2));
|
||||||
Assert.NotEmpty(ZPagesActivityTracker.CurrentMinuteList);
|
Assert.NotEmpty(ZPagesActivityTracker.CurrentMinuteList);
|
||||||
ZPagesActivityTracker.PurgeCurrentMinuteData(null, null);
|
ZPagesActivityTracker.PurgeCurrentMinuteData(null, null);
|
||||||
Assert.Empty(ZPagesActivityTracker.CurrentMinuteList);
|
Assert.Empty(ZPagesActivityTracker.CurrentMinuteList);
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,8 @@ namespace OpenTelemetry.Exporter.ZPages.Tests
|
||||||
ZPagesExporter exporter = new ZPagesExporter(options);
|
ZPagesExporter exporter = new ZPagesExporter(options);
|
||||||
var zpagesProcessor = new ZPagesProcessor(exporter);
|
var zpagesProcessor = new ZPagesProcessor(exporter);
|
||||||
|
|
||||||
var source = new ActivitySource(ActivitySourceName);
|
using var source = new ActivitySource(ActivitySourceName);
|
||||||
var activity0 = source.StartActivity("Test Zipkin Activity 1");
|
using var activity0 = source.StartActivity("Test Zipkin Activity 1");
|
||||||
zpagesProcessor.OnStart(activity0);
|
zpagesProcessor.OnStart(activity0);
|
||||||
|
|
||||||
// checking size of dictionaries from ZPagesActivityTracker
|
// checking size of dictionaries from ZPagesActivityTracker
|
||||||
|
|
@ -125,7 +125,7 @@ namespace OpenTelemetry.Exporter.ZPages.Tests
|
||||||
Assert.Single(ZPagesActivityTracker.TotalErrorCount);
|
Assert.Single(ZPagesActivityTracker.TotalErrorCount);
|
||||||
Assert.Single(ZPagesActivityTracker.TotalLatency);
|
Assert.Single(ZPagesActivityTracker.TotalLatency);
|
||||||
|
|
||||||
var activity1 = source.StartActivity("Test Zipkin Activity 1");
|
using var activity1 = source.StartActivity("Test Zipkin Activity 1");
|
||||||
zpagesProcessor.OnStart(activity1);
|
zpagesProcessor.OnStart(activity1);
|
||||||
|
|
||||||
// checking size of dictionaries from ZPagesActivityTracker
|
// checking size of dictionaries from ZPagesActivityTracker
|
||||||
|
|
@ -135,7 +135,7 @@ namespace OpenTelemetry.Exporter.ZPages.Tests
|
||||||
Assert.Single(ZPagesActivityTracker.TotalErrorCount);
|
Assert.Single(ZPagesActivityTracker.TotalErrorCount);
|
||||||
Assert.Single(ZPagesActivityTracker.TotalLatency);
|
Assert.Single(ZPagesActivityTracker.TotalLatency);
|
||||||
|
|
||||||
var activity2 = source.StartActivity("Test Zipkin Activity 2");
|
using var activity2 = source.StartActivity("Test Zipkin Activity 2");
|
||||||
zpagesProcessor.OnStart(activity2);
|
zpagesProcessor.OnStart(activity2);
|
||||||
|
|
||||||
// checking size of dictionaries from ZPagesActivityTracker
|
// checking size of dictionaries from ZPagesActivityTracker
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
Tags = PooledList<KeyValuePair<string, object>>.Create(),
|
Tags = PooledList<KeyValuePair<string, object>>.Create(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Activity activity = new Activity("TestActivity");
|
using var activity = new Activity("TestActivity");
|
||||||
activity.SetTag(key, value);
|
activity.SetTag(key, value);
|
||||||
|
|
||||||
attributeEnumerationState.EnumerateTags(activity);
|
attributeEnumerationState.EnumerateTags(activity);
|
||||||
|
|
@ -56,7 +56,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
Tags = PooledList<KeyValuePair<string, object>>.Create(),
|
Tags = PooledList<KeyValuePair<string, object>>.Create(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Activity activity = new Activity("TestActivity");
|
using var activity = new Activity("TestActivity");
|
||||||
activity.SetTag(key, value);
|
activity.SetTag(key, value);
|
||||||
|
|
||||||
attributeEnumerationState.EnumerateTags(activity);
|
attributeEnumerationState.EnumerateTags(activity);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void ToZipkinSpan_AllPropertiesSet()
|
public void ToZipkinSpan_AllPropertiesSet()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
using var activity = ZipkinExporterTests.CreateTestActivity();
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var zipkinSpan = activity.ToZipkinSpan(DefaultZipkinEndpoint);
|
var zipkinSpan = activity.ToZipkinSpan(DefaultZipkinEndpoint);
|
||||||
|
|
@ -64,7 +64,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void ToZipkinSpan_NoEvents()
|
public void ToZipkinSpan_NoEvents()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity(addEvents: false);
|
using var activity = ZipkinExporterTests.CreateTestActivity(addEvents: false);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var zipkinSpan = activity.ToZipkinSpan(DefaultZipkinEndpoint);
|
var zipkinSpan = activity.ToZipkinSpan(DefaultZipkinEndpoint);
|
||||||
|
|
@ -95,7 +95,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void ToZipkinSpan_Status_ErrorFlagTest(StatusCode expectedStatusCode, string statusCodeTagValue)
|
public void ToZipkinSpan_Status_ErrorFlagTest(StatusCode expectedStatusCode, string statusCodeTagValue)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
using var activity = ZipkinExporterTests.CreateTestActivity();
|
||||||
activity.SetTag(SpanAttributeConstants.StatusCodeKey, statusCodeTagValue);
|
activity.SetTag(SpanAttributeConstants.StatusCodeKey, statusCodeTagValue);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -134,7 +134,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
{
|
{
|
||||||
// Arrange.
|
// Arrange.
|
||||||
const string description = "Description when ActivityStatusCode is Error.";
|
const string description = "Description when ActivityStatusCode is Error.";
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
using var activity = ZipkinExporterTests.CreateTestActivity();
|
||||||
activity.SetStatus(expectedStatusCode, description);
|
activity.SetStatus(expectedStatusCode, description);
|
||||||
|
|
||||||
// Act.
|
// Act.
|
||||||
|
|
@ -175,7 +175,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsOk()
|
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsOk()
|
||||||
{
|
{
|
||||||
// Arrange.
|
// Arrange.
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
using var activity = ZipkinExporterTests.CreateTestActivity();
|
||||||
activity.SetStatus(ActivityStatusCode.Ok);
|
activity.SetStatus(ActivityStatusCode.Ok);
|
||||||
activity.SetTag(SpanAttributeConstants.StatusCodeKey, "ERROR");
|
activity.SetTag(SpanAttributeConstants.StatusCodeKey, "ERROR");
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsError()
|
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsError()
|
||||||
{
|
{
|
||||||
// Arrange.
|
// Arrange.
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
using var activity = ZipkinExporterTests.CreateTestActivity();
|
||||||
|
|
||||||
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
||||||
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
||||||
|
|
@ -235,7 +235,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsError_SettingTagFirst()
|
public void ActivityStatus_Takes_precedence_Over_Status_Tags_ActivityStatusCodeIsError_SettingTagFirst()
|
||||||
{
|
{
|
||||||
// Arrange.
|
// Arrange.
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
using var activity = ZipkinExporterTests.CreateTestActivity();
|
||||||
|
|
||||||
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
const string StatusDescriptionOnError = "Description when ActivityStatusCode is Error.";
|
||||||
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
const string TagDescriptionOnError = "Description when TagStatusCode is Error.";
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void GenerateActivity_RemoteEndpointOmittedByDefault()
|
public void GenerateActivity_RemoteEndpointOmittedByDefault()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
using var activity = ZipkinExporterTests.CreateTestActivity();
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);
|
var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);
|
||||||
|
|
@ -40,7 +40,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void GenerateActivity_RemoteEndpointResolution()
|
public void GenerateActivity_RemoteEndpointResolution()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity(
|
using var activity = ZipkinExporterTests.CreateTestActivity(
|
||||||
additionalAttributes: new Dictionary<string, object>
|
additionalAttributes: new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
["net.peer.name"] = "RemoteServiceName",
|
["net.peer.name"] = "RemoteServiceName",
|
||||||
|
|
@ -58,7 +58,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation.Tests
|
||||||
public void GenerateActivity_RemoteEndpointResolutionPriority(RemoteEndpointPriorityTestCase testCase)
|
public void GenerateActivity_RemoteEndpointResolutionPriority(RemoteEndpointPriorityTestCase testCase)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var activity = ZipkinExporterTests.CreateTestActivity(additionalAttributes: testCase.RemoteEndpointAttributes);
|
using var activity = ZipkinExporterTests.CreateTestActivity(additionalAttributes: testCase.RemoteEndpointAttributes);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);
|
var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,8 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
|
||||||
{
|
{
|
||||||
Endpoint = new Uri($"http://{this.testServerHost}:{this.testServerPort}/api/v2/spans?requestId={requestId}"),
|
Endpoint = new Uri($"http://{this.testServerHost}:{this.testServerPort}/api/v2/spans?requestId={requestId}"),
|
||||||
};
|
};
|
||||||
var zipkinExporter = new ZipkinExporter(exporterOptions);
|
using var zipkinExporter = new ZipkinExporter(exporterOptions);
|
||||||
var exportActivityProcessor = new BatchActivityExportProcessor(zipkinExporter);
|
using var exportActivityProcessor = new BatchActivityExportProcessor(zipkinExporter);
|
||||||
|
|
||||||
var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||||
.AddSource(ActivitySourceName)
|
.AddSource(ActivitySourceName)
|
||||||
|
|
@ -138,8 +138,8 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
|
||||||
.AddHttpClientInstrumentation()
|
.AddHttpClientInstrumentation()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var source = new ActivitySource(ActivitySourceName);
|
using var source = new ActivitySource(ActivitySourceName);
|
||||||
var activity = source.StartActivity("Test Zipkin Activity");
|
using var activity = source.StartActivity("Test Zipkin Activity");
|
||||||
activity?.Stop();
|
activity?.Stop();
|
||||||
|
|
||||||
// We call ForceFlush on the exporter twice, so that in the event
|
// We call ForceFlush on the exporter twice, so that in the event
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
|
||||||
public void GrpcTagHelper_GetGrpcMethodFromActivity()
|
public void GrpcTagHelper_GetGrpcMethodFromActivity()
|
||||||
{
|
{
|
||||||
var grpcMethod = "/some.service/somemethod";
|
var grpcMethod = "/some.service/somemethod";
|
||||||
var activity = new Activity("operationName");
|
using var activity = new Activity("operationName");
|
||||||
activity.SetTag(GrpcTagHelper.GrpcMethodTagName, grpcMethod);
|
activity.SetTag(GrpcTagHelper.GrpcMethodTagName, grpcMethod);
|
||||||
|
|
||||||
var result = GrpcTagHelper.GetGrpcMethodFromActivity(activity);
|
var result = GrpcTagHelper.GetGrpcMethodFromActivity(activity);
|
||||||
|
|
@ -52,7 +52,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GrpcTagHelper_GetGrpcStatusCodeFromActivity()
|
public void GrpcTagHelper_GetGrpcStatusCodeFromActivity()
|
||||||
{
|
{
|
||||||
var activity = new Activity("operationName");
|
using var activity = new Activity("operationName");
|
||||||
activity.SetTag(GrpcTagHelper.GrpcStatusCodeTagName, "0");
|
activity.SetTag(GrpcTagHelper.GrpcStatusCodeTagName, "0");
|
||||||
|
|
||||||
bool validConversion = GrpcTagHelper.TryGetGrpcStatusCodeFromActivity(activity, out int status);
|
bool validConversion = GrpcTagHelper.TryGetGrpcStatusCodeFromActivity(activity, out int status);
|
||||||
|
|
@ -68,7 +68,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GrpcTagHelper_GetGrpcStatusCodeFromEmptyActivity()
|
public void GrpcTagHelper_GetGrpcStatusCodeFromEmptyActivity()
|
||||||
{
|
{
|
||||||
var activity = new Activity("operationName");
|
using var activity = new Activity("operationName");
|
||||||
|
|
||||||
bool validConversion = GrpcTagHelper.TryGetGrpcStatusCodeFromActivity(activity, out int status);
|
bool validConversion = GrpcTagHelper.TryGetGrpcStatusCodeFromActivity(activity, out int status);
|
||||||
Assert.False(validConversion);
|
Assert.False(validConversion);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
|
||||||
|
|
||||||
var processor = new Mock<BaseProcessor<Activity>>();
|
var processor = new Mock<BaseProcessor<Activity>>();
|
||||||
|
|
||||||
var parent = new Activity("parent")
|
using var parent = new Activity("parent")
|
||||||
.SetIdFormat(ActivityIdFormat.W3C)
|
.SetIdFormat(ActivityIdFormat.W3C)
|
||||||
.Start();
|
.Start();
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
|
||||||
c.SetTag("enrichedWithHttpResponseMessage", "no");
|
c.SetTag("enrichedWithHttpResponseMessage", "no");
|
||||||
});
|
});
|
||||||
|
|
||||||
var parent = new Activity("parent")
|
using var parent = new Activity("parent")
|
||||||
.Start();
|
.Start();
|
||||||
|
|
||||||
using (Sdk.CreateTracerProviderBuilder()
|
using (Sdk.CreateTracerProviderBuilder()
|
||||||
|
|
@ -194,7 +194,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
|
||||||
var uri = new Uri($"http://localhost:{this.server.Port}");
|
var uri = new Uri($"http://localhost:{this.server.Port}");
|
||||||
var processor = new Mock<BaseProcessor<Activity>>();
|
var processor = new Mock<BaseProcessor<Activity>>();
|
||||||
|
|
||||||
var parent = new Activity("parent")
|
using var parent = new Activity("parent")
|
||||||
.Start();
|
.Start();
|
||||||
|
|
||||||
using (Sdk.CreateTracerProviderBuilder()
|
using (Sdk.CreateTracerProviderBuilder()
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
Method = new HttpMethod("GET"),
|
Method = new HttpMethod("GET"),
|
||||||
};
|
};
|
||||||
|
|
||||||
var parent = new Activity("parent")
|
using var parent = new Activity("parent")
|
||||||
.SetIdFormat(ActivityIdFormat.W3C)
|
.SetIdFormat(ActivityIdFormat.W3C)
|
||||||
.Start();
|
.Start();
|
||||||
parent.TraceStateString = "k1=v1,k2=v2";
|
parent.TraceStateString = "k1=v1,k2=v2";
|
||||||
|
|
@ -207,13 +207,13 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
|
|
||||||
var processor = new Mock<BaseProcessor<Activity>>();
|
var processor = new Mock<BaseProcessor<Activity>>();
|
||||||
|
|
||||||
var request = new HttpRequestMessage
|
using var request = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
RequestUri = new Uri(this.url),
|
RequestUri = new Uri(this.url),
|
||||||
Method = new HttpMethod("GET"),
|
Method = new HttpMethod("GET"),
|
||||||
};
|
};
|
||||||
|
|
||||||
var parent = new Activity("parent")
|
using var parent = new Activity("parent")
|
||||||
.SetIdFormat(ActivityIdFormat.W3C)
|
.SetIdFormat(ActivityIdFormat.W3C)
|
||||||
.Start();
|
.Start();
|
||||||
parent.TraceStateString = "k1=v1,k2=v2";
|
parent.TraceStateString = "k1=v1,k2=v2";
|
||||||
|
|
@ -275,13 +275,13 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
|
|
||||||
var processor = new Mock<BaseProcessor<Activity>>();
|
var processor = new Mock<BaseProcessor<Activity>>();
|
||||||
|
|
||||||
var request = new HttpRequestMessage
|
using var request = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
RequestUri = new Uri(this.url),
|
RequestUri = new Uri(this.url),
|
||||||
Method = new HttpMethod("GET"),
|
Method = new HttpMethod("GET"),
|
||||||
};
|
};
|
||||||
|
|
||||||
var parent = new Activity("parent")
|
using var parent = new Activity("parent")
|
||||||
.SetIdFormat(ActivityIdFormat.W3C)
|
.SetIdFormat(ActivityIdFormat.W3C)
|
||||||
.Start();
|
.Start();
|
||||||
parent.TraceStateString = "k1=v1,k2=v2";
|
parent.TraceStateString = "k1=v1,k2=v2";
|
||||||
|
|
@ -321,7 +321,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
public async Task ExportsSpansCreatedForRetries()
|
public async Task ExportsSpansCreatedForRetries()
|
||||||
{
|
{
|
||||||
var exportedItems = new List<Activity>();
|
var exportedItems = new List<Activity>();
|
||||||
var request = new HttpRequestMessage
|
using var request = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
RequestUri = new Uri(this.url),
|
RequestUri = new Uri(this.url),
|
||||||
Method = new HttpMethod("GET"),
|
Method = new HttpMethod("GET"),
|
||||||
|
|
@ -333,8 +333,10 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
int maxRetries = 3;
|
int maxRetries = 3;
|
||||||
using var c = new HttpClient(new RetryHandler(new HttpClientHandler(), maxRetries));
|
using var clientHandler = new HttpClientHandler();
|
||||||
await c.SendAsync(request).ConfigureAwait(false);
|
using var retryHandler = new RetryHandler(clientHandler, maxRetries);
|
||||||
|
using var httpClient = new HttpClient(retryHandler);
|
||||||
|
await httpClient.SendAsync(request).ConfigureAwait(false);
|
||||||
|
|
||||||
// number of exported spans should be 3(maxRetries)
|
// number of exported spans should be 3(maxRetries)
|
||||||
Assert.Equal(maxRetries, exportedItems.Count());
|
Assert.Equal(maxRetries, exportedItems.Count());
|
||||||
|
|
@ -505,7 +507,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
{
|
{
|
||||||
var exportedItems = new List<Activity>();
|
var exportedItems = new List<Activity>();
|
||||||
bool exceptionThrown = false;
|
bool exceptionThrown = false;
|
||||||
var request = new HttpRequestMessage
|
using var request = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
RequestUri = new Uri($"{this.url}500"),
|
RequestUri = new Uri($"{this.url}500"),
|
||||||
Method = new HttpMethod("GET"),
|
Method = new HttpMethod("GET"),
|
||||||
|
|
@ -587,7 +589,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
parentContext = parent.Context;
|
parentContext = parent.Context;
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = new HttpRequestMessage
|
using var request = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
RequestUri = new Uri(this.url),
|
RequestUri = new Uri(this.url),
|
||||||
Method = new HttpMethod("GET"),
|
Method = new HttpMethod("GET"),
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var c = new HttpClient();
|
using var c = new HttpClient();
|
||||||
var request = new HttpRequestMessage
|
using var request = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
RequestUri = new Uri(tc.Url),
|
RequestUri = new Uri(tc.Url),
|
||||||
Method = new HttpMethod(tc.Method),
|
Method = new HttpMethod(tc.Method),
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
{
|
{
|
||||||
using var eventRecords = new ActivitySourceRecorder();
|
using var eventRecords = new ActivitySourceRecorder();
|
||||||
|
|
||||||
var parent = new Activity("w3c activity");
|
using var parent = new Activity("w3c activity");
|
||||||
parent.SetParentId(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom());
|
parent.SetParentId(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom());
|
||||||
parent.TraceStateString = "some=state";
|
parent.TraceStateString = "some=state";
|
||||||
parent.Start();
|
parent.Start();
|
||||||
|
|
@ -712,7 +712,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
public void TestMultipleConcurrentRequests()
|
public void TestMultipleConcurrentRequests()
|
||||||
{
|
{
|
||||||
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
|
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
|
||||||
var parentActivity = new Activity("parent").Start();
|
using var parentActivity = new Activity("parent").Start();
|
||||||
using var eventRecords = new ActivitySourceRecorder();
|
using var eventRecords = new ActivitySourceRecorder();
|
||||||
|
|
||||||
Dictionary<Uri, Tuple<WebRequest, WebResponse>> requestData = new Dictionary<Uri, Tuple<WebRequest, WebResponse>>();
|
Dictionary<Uri, Tuple<WebRequest, WebResponse>> requestData = new Dictionary<Uri, Tuple<WebRequest, WebResponse>>();
|
||||||
|
|
@ -724,7 +724,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue all requests simultaneously
|
// Issue all requests simultaneously
|
||||||
HttpClient httpClient = new HttpClient();
|
using var httpClient = new HttpClient();
|
||||||
Dictionary<Uri, Task<HttpResponseMessage>> tasks = new Dictionary<Uri, Task<HttpResponseMessage>>();
|
Dictionary<Uri, Task<HttpResponseMessage>> tasks = new Dictionary<Uri, Task<HttpResponseMessage>>();
|
||||||
|
|
||||||
CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
||||||
|
|
||||||
request.Method = "GET";
|
request.Method = "GET";
|
||||||
|
|
||||||
var parent = new Activity("parent")
|
using var parent = new Activity("parent")
|
||||||
.SetIdFormat(ActivityIdFormat.W3C)
|
.SetIdFormat(ActivityIdFormat.W3C)
|
||||||
.Start();
|
.Start();
|
||||||
parent.TraceStateString = "k1=v1,k2=v2";
|
parent.TraceStateString = "k1=v1,k2=v2";
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
|
||||||
|
|
||||||
private static string RunCommand(string command, string args)
|
private static string RunCommand(string command, string args)
|
||||||
{
|
{
|
||||||
var proc = new Process
|
using var proc = new Process
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo
|
StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||||
public void Start_ActivityOperationRootSpanChecks()
|
public void Start_ActivityOperationRootSpanChecks()
|
||||||
{
|
{
|
||||||
// Create an activity
|
// Create an activity
|
||||||
_ = new Activity("foo")
|
using var activity = new Activity("foo")
|
||||||
.SetIdFormat(ActivityIdFormat.W3C)
|
.SetIdFormat(ActivityIdFormat.W3C)
|
||||||
.Start();
|
.Start();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ namespace OpenTelemetry.Instrumentation.Tests
|
||||||
[InlineData("TestActivitySource", "1.0.0")]
|
[InlineData("TestActivitySource", "1.0.0")]
|
||||||
public void SetActivitySource(string name, string version)
|
public void SetActivitySource(string name, string version)
|
||||||
{
|
{
|
||||||
var activity = new Activity("Test");
|
using var activity = new Activity("Test");
|
||||||
var activitySource = new ActivitySource(name, version);
|
using var activitySource = new ActivitySource(name, version);
|
||||||
|
|
||||||
activity.Start();
|
activity.Start();
|
||||||
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, activitySource);
|
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, activitySource);
|
||||||
|
|
@ -44,7 +44,7 @@ namespace OpenTelemetry.Instrumentation.Tests
|
||||||
[InlineData(ActivityKind.Server)]
|
[InlineData(ActivityKind.Server)]
|
||||||
public void SetActivityKind(ActivityKind activityKind)
|
public void SetActivityKind(ActivityKind activityKind)
|
||||||
{
|
{
|
||||||
var activity = new Activity("Test");
|
using var activity = new Activity("Test");
|
||||||
activity.Start();
|
activity.Start();
|
||||||
ActivityInstrumentationHelper.SetKindProperty(activity, activityKind);
|
ActivityInstrumentationHelper.SetKindProperty(activity, activityKind);
|
||||||
Assert.Equal(activityKind, activity.Kind);
|
Assert.Equal(activityKind, activity.Kind);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace OpenTelemetry.Instrumentation.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FetchValidProperty()
|
public void FetchValidProperty()
|
||||||
{
|
{
|
||||||
var activity = new Activity("test");
|
using var activity = new Activity("test");
|
||||||
var fetch = new PropertyFetcher<string>("DisplayName");
|
var fetch = new PropertyFetcher<string>("DisplayName");
|
||||||
Assert.True(fetch.TryFetch(activity, out string result));
|
Assert.True(fetch.TryFetch(activity, out string result));
|
||||||
Assert.Equal(activity.DisplayName, result);
|
Assert.Equal(activity.DisplayName, result);
|
||||||
|
|
@ -33,7 +33,7 @@ namespace OpenTelemetry.Instrumentation.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FetchInvalidProperty()
|
public void FetchInvalidProperty()
|
||||||
{
|
{
|
||||||
var activity = new Activity("test");
|
using var activity = new Activity("test");
|
||||||
var fetch = new PropertyFetcher<string>("DisplayName2");
|
var fetch = new PropertyFetcher<string>("DisplayName2");
|
||||||
Assert.False(fetch.TryFetch(activity, out string result));
|
Assert.False(fetch.TryFetch(activity, out string result));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -389,7 +389,7 @@ namespace OpenTelemetry.Logs.Tests
|
||||||
var sampler = new RecordOnlySampler();
|
var sampler = new RecordOnlySampler();
|
||||||
var exportedActivityList = new List<Activity>();
|
var exportedActivityList = new List<Activity>();
|
||||||
var activitySourceName = "LogRecordTest";
|
var activitySourceName = "LogRecordTest";
|
||||||
var activitySource = new ActivitySource(activitySourceName);
|
using var activitySource = new ActivitySource(activitySourceName);
|
||||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||||
.AddSource(activitySourceName)
|
.AddSource(activitySourceName)
|
||||||
.SetSampler(sampler)
|
.SetSampler(sampler)
|
||||||
|
|
@ -417,7 +417,7 @@ namespace OpenTelemetry.Logs.Tests
|
||||||
var sampler = new AlwaysOnSampler();
|
var sampler = new AlwaysOnSampler();
|
||||||
var exportedActivityList = new List<Activity>();
|
var exportedActivityList = new List<Activity>();
|
||||||
var activitySourceName = "LogRecordTest";
|
var activitySourceName = "LogRecordTest";
|
||||||
var activitySource = new ActivitySource(activitySourceName);
|
using var activitySource = new ActivitySource(activitySourceName);
|
||||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||||
.AddSource(activitySourceName)
|
.AddSource(activitySourceName)
|
||||||
.SetSampler(sampler)
|
.SetSampler(sampler)
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
{
|
{
|
||||||
var message = "message";
|
var message = "message";
|
||||||
var exception = new ArgumentNullException(message, new Exception(message));
|
var exception = new ArgumentNullException(message, new Exception(message));
|
||||||
var activity = new Activity("test-activity");
|
using var activity = new Activity("test-activity");
|
||||||
activity.RecordException(exception);
|
activity.RecordException(exception);
|
||||||
|
|
||||||
var @event = activity.Events.FirstOrDefault(e => e.Name == SemanticConventions.AttributeExceptionEventName);
|
var @event = activity.Events.FirstOrDefault(e => e.Name == SemanticConventions.AttributeExceptionEventName);
|
||||||
|
|
@ -154,7 +154,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
{
|
{
|
||||||
var message = "message";
|
var message = "message";
|
||||||
var exception = new ArgumentNullException(message, new Exception(message));
|
var exception = new ArgumentNullException(message, new Exception(message));
|
||||||
var activity = new Activity("test-activity");
|
using var activity = new Activity("test-activity");
|
||||||
|
|
||||||
var tags = new TagList
|
var tags = new TagList
|
||||||
{
|
{
|
||||||
|
|
@ -189,7 +189,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetTagValueEmpty()
|
public void GetTagValueEmpty()
|
||||||
{
|
{
|
||||||
Activity activity = new Activity("Test");
|
using var activity = new Activity("Test");
|
||||||
|
|
||||||
Assert.Null(activity.GetTagValue("Tag1"));
|
Assert.Null(activity.GetTagValue("Tag1"));
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +197,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetTagValue()
|
public void GetTagValue()
|
||||||
{
|
{
|
||||||
Activity activity = new Activity("Test");
|
using var activity = new Activity("Test");
|
||||||
activity.SetTag("Tag1", "Value1");
|
activity.SetTag("Tag1", "Value1");
|
||||||
|
|
||||||
Assert.Equal("Value1", activity.GetTagValue("Tag1"));
|
Assert.Equal("Value1", activity.GetTagValue("Tag1"));
|
||||||
|
|
@ -210,7 +210,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
[InlineData("CustomTag", null, false)]
|
[InlineData("CustomTag", null, false)]
|
||||||
public void TryCheckFirstTag(string tagName, object expectedTagValue, bool expectedResult)
|
public void TryCheckFirstTag(string tagName, object expectedTagValue, bool expectedResult)
|
||||||
{
|
{
|
||||||
Activity activity = new Activity("Test");
|
using var activity = new Activity("Test");
|
||||||
activity.SetTag("Key", "Value");
|
activity.SetTag("Key", "Value");
|
||||||
|
|
||||||
var result = activity.TryCheckFirstTag(tagName, out var tagValue);
|
var result = activity.TryCheckFirstTag(tagName, out var tagValue);
|
||||||
|
|
@ -221,7 +221,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TryCheckFirstTagReturnsFalseForActivityWithNoTags()
|
public void TryCheckFirstTagReturnsFalseForActivityWithNoTags()
|
||||||
{
|
{
|
||||||
Activity activity = new Activity("Test");
|
using var activity = new Activity("Test");
|
||||||
|
|
||||||
var result = activity.TryCheckFirstTag("Key", out var tagValue);
|
var result = activity.TryCheckFirstTag("Key", out var tagValue);
|
||||||
Assert.False(result);
|
Assert.False(result);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
maxExportBatchSize: 1,
|
maxExportBatchSize: 1,
|
||||||
scheduledDelayMilliseconds: 100_000);
|
scheduledDelayMilliseconds: 100_000);
|
||||||
|
|
||||||
var activity = new Activity("start")
|
using var activity = new Activity("start")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
@ -92,12 +92,12 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
maxExportBatchSize: 3,
|
maxExportBatchSize: 3,
|
||||||
exporterTimeoutMilliseconds: 30000);
|
exporterTimeoutMilliseconds: 30000);
|
||||||
|
|
||||||
var activity1 = new Activity("start1")
|
using var activity1 = new Activity("start1")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
||||||
var activity2 = new Activity("start2")
|
using var activity2 = new Activity("start2")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
@ -141,7 +141,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
maxExportBatchSize: 3,
|
maxExportBatchSize: 3,
|
||||||
exporterTimeoutMilliseconds: 30000);
|
exporterTimeoutMilliseconds: 30000);
|
||||||
|
|
||||||
var activity = new Activity("start")
|
using var activity = new Activity("start")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
@ -172,7 +172,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
maxQueueSize: 1,
|
maxQueueSize: 1,
|
||||||
maxExportBatchSize: 1);
|
maxExportBatchSize: 1);
|
||||||
|
|
||||||
var activity = new Activity("start")
|
using var activity = new Activity("start")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.None,
|
ActivityTraceFlags = ActivityTraceFlags.None,
|
||||||
};
|
};
|
||||||
|
|
@ -192,7 +192,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
maxQueueSize: 3,
|
maxQueueSize: 3,
|
||||||
maxExportBatchSize: 3);
|
maxExportBatchSize: 3);
|
||||||
|
|
||||||
var activity = new Activity("start")
|
using var activity = new Activity("start")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
activity => { result += "2"; },
|
activity => { result += "2"; },
|
||||||
activity => { result += "4"; });
|
activity => { result += "4"; });
|
||||||
|
|
||||||
var activity = new Activity("test");
|
using var activity = new Activity("test");
|
||||||
|
|
||||||
using (var processor = new CompositeProcessor<Activity>(new[] { p1, p2 }))
|
using (var processor = new CompositeProcessor<Activity>(new[] { p1, p2 }))
|
||||||
{
|
{
|
||||||
|
|
@ -63,7 +63,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
activity => { throw new Exception("Start exception"); },
|
activity => { throw new Exception("Start exception"); },
|
||||||
activity => { throw new Exception("End exception"); });
|
activity => { throw new Exception("End exception"); });
|
||||||
|
|
||||||
var activity = new Activity("test");
|
using var activity = new Activity("test");
|
||||||
|
|
||||||
using var processor = new CompositeProcessor<Activity>(new[] { p1 });
|
using var processor = new CompositeProcessor<Activity>(new[] { p1 });
|
||||||
Assert.Throws<Exception>(() => { processor.OnStart(activity); });
|
Assert.Throws<Exception>(() => { processor.OnStart(activity); });
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CurrentSpan_WhenActivityExists()
|
public void CurrentSpan_WhenActivityExists()
|
||||||
{
|
{
|
||||||
_ = new Activity("foo").Start();
|
using var activity = new Activity("foo").Start();
|
||||||
Assert.True(Tracer.CurrentSpan.Context.IsValid);
|
Assert.True(Tracer.CurrentSpan.Context.IsValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace OpenTelemetry.Context.Propagation.Tests
|
||||||
var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null);
|
var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null);
|
||||||
PropagationContext propagationContext = new PropagationContext(activityContext, default);
|
PropagationContext propagationContext = new PropagationContext(activityContext, default);
|
||||||
var carrier = new Dictionary<string, string>();
|
var carrier = new Dictionary<string, string>();
|
||||||
var activity = new Activity("test");
|
using var activity = new Activity("test");
|
||||||
|
|
||||||
compositePropagator.Inject(propagationContext, carrier, Setter);
|
compositePropagator.Inject(propagationContext, carrier, Setter);
|
||||||
Assert.Contains(carrier, kv => kv.Key == "custom-traceparent-1");
|
Assert.Contains(carrier, kv => kv.Key == "custom-traceparent-1");
|
||||||
|
|
|
||||||
|
|
@ -130,11 +130,11 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
.AddLegacySource(operationNameForLegacyActivity)
|
.AddLegacySource(operationNameForLegacyActivity)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Activity parentActivity = new Activity("Foo");
|
using var parentActivity = new Activity("Foo");
|
||||||
parentActivity.TraceStateString = existingTraceState;
|
parentActivity.TraceStateString = existingTraceState;
|
||||||
parentActivity.Start();
|
parentActivity.Start();
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
Assert.NotNull(activity);
|
Assert.NotNull(activity);
|
||||||
if (samplingDecision != SamplingDecision.Drop)
|
if (samplingDecision != SamplingDecision.Drop)
|
||||||
|
|
@ -168,11 +168,11 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
.AddLegacySource(operationNameForLegacyActivity)
|
.AddLegacySource(operationNameForLegacyActivity)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Activity parentActivity = new Activity("Foo");
|
using var parentActivity = new Activity("Foo");
|
||||||
parentActivity.TraceStateString = existingTraceState;
|
parentActivity.TraceStateString = existingTraceState;
|
||||||
parentActivity.Start();
|
parentActivity.Start();
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
Assert.NotNull(activity);
|
Assert.NotNull(activity);
|
||||||
if (samplingDecision != SamplingDecision.Drop)
|
if (samplingDecision != SamplingDecision.Drop)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
||||||
using var processor = new SimpleActivityExportProcessor(exporter);
|
using var processor = new SimpleActivityExportProcessor(exporter);
|
||||||
|
|
||||||
var activity1 = new Activity("start1")
|
using var activity1 = new Activity("start1")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
@ -43,7 +43,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
processor.OnEnd(activity1);
|
processor.OnEnd(activity1);
|
||||||
Assert.Single(exportedItems);
|
Assert.Single(exportedItems);
|
||||||
|
|
||||||
var activity2 = new Activity("start2")
|
using var activity2 = new Activity("start2")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
@ -62,12 +62,12 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
||||||
using var processor = new SimpleActivityExportProcessor(exporter);
|
using var processor = new SimpleActivityExportProcessor(exporter);
|
||||||
|
|
||||||
var activity1 = new Activity("start1")
|
using var activity1 = new Activity("start1")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
||||||
var activity2 = new Activity("start2")
|
using var activity2 = new Activity("start2")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
@ -93,7 +93,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
||||||
using var processor = new SimpleActivityExportProcessor(exporter);
|
using var processor = new SimpleActivityExportProcessor(exporter);
|
||||||
|
|
||||||
var activity = new Activity("start")
|
using var activity = new Activity("start")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
ActivityTraceFlags = ActivityTraceFlags.Recorded,
|
||||||
};
|
};
|
||||||
|
|
@ -114,7 +114,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
using var exporter = new InMemoryExporter<Activity>(exportedItems);
|
||||||
using var processor = new SimpleActivityExportProcessor(exporter);
|
using var processor = new SimpleActivityExportProcessor(exporter);
|
||||||
|
|
||||||
var activity = new Activity("start")
|
using var activity = new Activity("start")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = ActivityTraceFlags.None,
|
ActivityTraceFlags = ActivityTraceFlags.None,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
// Validate that when StartActivity is called using Parent as string,
|
// Validate that when StartActivity is called using Parent as string,
|
||||||
// Sampling is called correctly.
|
// Sampling is called correctly.
|
||||||
var act = new Activity("anything").Start();
|
using var act = new Activity("anything").Start();
|
||||||
act.Stop();
|
act.Stop();
|
||||||
var customContextAsString = act.Id;
|
var customContextAsString = act.Id;
|
||||||
var expectedTraceId = act.TraceId;
|
var expectedTraceId = act.TraceId;
|
||||||
|
|
@ -459,7 +459,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
endCalled = true;
|
endCalled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var emptyActivitySource = new ActivitySource(string.Empty);
|
using var emptyActivitySource = new ActivitySource(string.Empty);
|
||||||
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
||||||
|
|
||||||
// No AddLegacyOperationName chained to TracerProviderBuilder
|
// No AddLegacyOperationName chained to TracerProviderBuilder
|
||||||
|
|
@ -469,7 +469,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
Assert.False(emptyActivitySource.HasListeners()); // No listener for empty ActivitySource even after build
|
Assert.False(emptyActivitySource.HasListeners()); // No listener for empty ActivitySource even after build
|
||||||
|
|
||||||
Activity activity = new Activity("Test");
|
using var activity = new Activity("Test");
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
||||||
|
|
@ -516,7 +516,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
endCalled = true;
|
endCalled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var emptyActivitySource = new ActivitySource(string.Empty);
|
using var emptyActivitySource = new ActivitySource(string.Empty);
|
||||||
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
||||||
|
|
||||||
var operationNameForLegacyActivity = "TestOperationName";
|
var operationNameForLegacyActivity = "TestOperationName";
|
||||||
|
|
@ -530,7 +530,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
||||||
|
|
@ -577,7 +577,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
endCalled = true;
|
endCalled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var emptyActivitySource = new ActivitySource(string.Empty);
|
using var emptyActivitySource = new ActivitySource(string.Empty);
|
||||||
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
||||||
|
|
||||||
var operationNameForLegacyActivity = "TestOperationName";
|
var operationNameForLegacyActivity = "TestOperationName";
|
||||||
|
|
@ -592,7 +592,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
||||||
|
|
@ -626,11 +626,11 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
endCalled = true;
|
endCalled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var emptyActivitySource = new ActivitySource(string.Empty);
|
using var emptyActivitySource = new ActivitySource(string.Empty);
|
||||||
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
||||||
|
|
||||||
var operationNameForLegacyActivity = "TestOperationName";
|
var operationNameForLegacyActivity = "TestOperationName";
|
||||||
var activitySourceForLegacyActivity = new ActivitySource("TestActivitySource", "1.0.0");
|
using var activitySourceForLegacyActivity = new ActivitySource("TestActivitySource", "1.0.0");
|
||||||
|
|
||||||
// AddLegacyOperationName chained to TracerProviderBuilder
|
// AddLegacyOperationName chained to TracerProviderBuilder
|
||||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||||
|
|
@ -640,7 +640,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, activitySourceForLegacyActivity);
|
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, activitySourceForLegacyActivity);
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
@ -675,7 +675,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
endCalled = true;
|
endCalled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var emptyActivitySource = new ActivitySource(string.Empty);
|
using var emptyActivitySource = new ActivitySource(string.Empty);
|
||||||
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
Assert.False(emptyActivitySource.HasListeners()); // No ActivityListener for empty ActivitySource added yet
|
||||||
|
|
||||||
var operationNameForLegacyActivity = "TestOperationName";
|
var operationNameForLegacyActivity = "TestOperationName";
|
||||||
|
|
@ -690,7 +690,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
Assert.True(emptyActivitySource.HasListeners()); // Listener for empty ActivitySource added after TracerProvider build
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, activitySourceForLegacyActivity);
|
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, activitySourceForLegacyActivity);
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
@ -734,7 +734,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
Assert.Equal(tracerProvider, testActivityProcessor.ParentProvider);
|
Assert.Equal(tracerProvider, testActivityProcessor.ParentProvider);
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
|
|
||||||
|
|
@ -743,7 +743,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
// As Processors can be added anytime after Provider construction, the following validates
|
// As Processors can be added anytime after Provider construction, the following validates
|
||||||
// the following validates that updated processors are processing the legacy activities created from here on.
|
// the following validates that updated processors are processing the legacy activities created from here on.
|
||||||
TestActivityProcessor testActivityProcessorNew = new TestActivityProcessor();
|
using var testActivityProcessorNew = new TestActivityProcessor();
|
||||||
|
|
||||||
bool startCalledNew = false;
|
bool startCalledNew = false;
|
||||||
bool endCalledNew = false;
|
bool endCalledNew = false;
|
||||||
|
|
@ -772,7 +772,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
Assert.Equal(tracerProvider, sdkProvider.Processor.ParentProvider);
|
Assert.Equal(tracerProvider, sdkProvider.Processor.ParentProvider);
|
||||||
Assert.Equal(tracerProvider, testActivityProcessorNew.ParentProvider);
|
Assert.Equal(tracerProvider, testActivityProcessorNew.ParentProvider);
|
||||||
|
|
||||||
Activity activityNew = new Activity(operationNameForLegacyActivity); // Create a new Activity with the same operation name
|
using var activityNew = new Activity(operationNameForLegacyActivity); // Create a new Activity with the same operation name
|
||||||
activityNew.Start();
|
activityNew.Start();
|
||||||
activityNew.Stop();
|
activityNew.Stop();
|
||||||
|
|
||||||
|
|
@ -789,7 +789,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
.AddLegacySource(operationNameForLegacyActivity)
|
.AddLegacySource(operationNameForLegacyActivity)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
|
|
||||||
Assert.True(activity.IsAllDataRequested);
|
Assert.True(activity.IsAllDataRequested);
|
||||||
|
|
@ -812,7 +812,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
.AddLegacySource(operationNameForLegacyActivity)
|
.AddLegacySource(operationNameForLegacyActivity)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
|
|
||||||
Assert.False(activity.IsAllDataRequested);
|
Assert.False(activity.IsAllDataRequested);
|
||||||
|
|
@ -840,7 +840,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
.AddLegacySource(operationNameForLegacyActivity)
|
.AddLegacySource(operationNameForLegacyActivity)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
|
|
||||||
Assert.Equal(isAllDataRequested, activity.IsAllDataRequested);
|
Assert.Equal(isAllDataRequested, activity.IsAllDataRequested);
|
||||||
|
|
@ -874,7 +874,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
|
|
||||||
// Start activity without setting parent. i.e it'll have null parent
|
// Start activity without setting parent. i.e it'll have null parent
|
||||||
// and becomes root activity
|
// and becomes root activity
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
}
|
}
|
||||||
|
|
@ -917,7 +917,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
// The sampling parameters are expected to be that of the
|
// The sampling parameters are expected to be that of the
|
||||||
// parent context i.e the remote parent.
|
// parent context i.e the remote parent.
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity).SetParentId(remoteParentId);
|
using var activity = new Activity(operationNameForLegacyActivity).SetParentId(remoteParentId);
|
||||||
activity.TraceStateString = tracestate;
|
activity.TraceStateString = tracestate;
|
||||||
|
|
||||||
// At this point SetParentId has set the ActivityTraceFlags to that of the parent activity. The activity is now passed to the sampler.
|
// At this point SetParentId has set the ActivityTraceFlags to that of the parent activity. The activity is now passed to the sampler.
|
||||||
|
|
@ -953,7 +953,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
// The sampling parameters are expected to be that of the
|
// The sampling parameters are expected to be that of the
|
||||||
// parent context i.e the remote parent.
|
// parent context i.e the remote parent.
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity).SetParentId(remoteParentId);
|
using var activity = new Activity(operationNameForLegacyActivity).SetParentId(remoteParentId);
|
||||||
|
|
||||||
// At this point SetParentId has set the ActivityTraceFlags to that of the parent activity. The activity is now passed to the sampler.
|
// At this point SetParentId has set the ActivityTraceFlags to that of the parent activity. The activity is now passed to the sampler.
|
||||||
activity.Start();
|
activity.Start();
|
||||||
|
|
@ -988,7 +988,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
// The sampling parameters are expected to be that of the
|
// The sampling parameters are expected to be that of the
|
||||||
// parent context i.e the remote parent.
|
// parent context i.e the remote parent.
|
||||||
|
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity).SetParentId(remoteParentId);
|
using var activity = new Activity(operationNameForLegacyActivity).SetParentId(remoteParentId);
|
||||||
|
|
||||||
// At this point SetParentId has set the ActivityTraceFlags to that of the parent activity. The activity is now passed to the sampler.
|
// At this point SetParentId has set the ActivityTraceFlags to that of the parent activity. The activity is now passed to the sampler.
|
||||||
activity.Start();
|
activity.Start();
|
||||||
|
|
@ -1009,7 +1009,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
{
|
{
|
||||||
// Create some parent activity.
|
// Create some parent activity.
|
||||||
string tracestate = "a=b;c=d";
|
string tracestate = "a=b;c=d";
|
||||||
var activityLocalParent = new Activity("TestParent")
|
using var activityLocalParent = new Activity("TestParent")
|
||||||
{
|
{
|
||||||
ActivityTraceFlags = traceFlags,
|
ActivityTraceFlags = traceFlags,
|
||||||
TraceStateString = tracestate,
|
TraceStateString = tracestate,
|
||||||
|
|
@ -1038,7 +1038,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
// activity.Parent will be equal to the activity created at the beginning of this test.
|
// activity.Parent will be equal to the activity created at the beginning of this test.
|
||||||
// Sampling parameters are expected to be that of the parentContext.
|
// Sampling parameters are expected to be that of the parentContext.
|
||||||
// i.e of the parent Activity
|
// i.e of the parent Activity
|
||||||
Activity activity = new Activity(operationNameForLegacyActivity);
|
using var activity = new Activity(operationNameForLegacyActivity);
|
||||||
activity.Start();
|
activity.Start();
|
||||||
activity.Stop();
|
activity.Stop();
|
||||||
}
|
}
|
||||||
|
|
@ -1087,7 +1087,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void AddLegacyOperationNameAddsActivityListenerForEmptyActivitySource()
|
public void AddLegacyOperationNameAddsActivityListenerForEmptyActivitySource()
|
||||||
{
|
{
|
||||||
var emptyActivitySource = new ActivitySource(string.Empty);
|
using var emptyActivitySource = new ActivitySource(string.Empty);
|
||||||
var builder = Sdk.CreateTracerProviderBuilder();
|
var builder = Sdk.CreateTracerProviderBuilder();
|
||||||
builder.AddLegacySource("TestOperationName");
|
builder.AddLegacySource("TestOperationName");
|
||||||
|
|
||||||
|
|
@ -1181,7 +1181,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
foreach (var ns in legacySourceNamespaces)
|
foreach (var ns in legacySourceNamespaces)
|
||||||
{
|
{
|
||||||
var startOpName = ns.Replace("*", "Start");
|
var startOpName = ns.Replace("*", "Start");
|
||||||
Activity startOperation = new Activity(startOpName);
|
using var startOperation = new Activity(startOpName);
|
||||||
startOperation.Start();
|
startOperation.Start();
|
||||||
startOperation.Stop();
|
startOperation.Stop();
|
||||||
|
|
||||||
|
|
@ -1189,7 +1189,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
Assert.Contains(startOpName, onStopProcessedActivities); // Processor.OnEnd is called since we added a legacy OperationName
|
Assert.Contains(startOpName, onStopProcessedActivities); // Processor.OnEnd is called since we added a legacy OperationName
|
||||||
|
|
||||||
var stopOpName = ns.Replace("*", "Stop");
|
var stopOpName = ns.Replace("*", "Stop");
|
||||||
Activity stopOperation = new Activity(stopOpName);
|
using var stopOperation = new Activity(stopOpName);
|
||||||
stopOperation.Start();
|
stopOperation.Start();
|
||||||
stopOperation.Stop();
|
stopOperation.Stop();
|
||||||
|
|
||||||
|
|
@ -1198,7 +1198,7 @@ namespace OpenTelemetry.Trace.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we can still process "normal" activities when in legacy wildcard mode.
|
// Ensure we can still process "normal" activities when in legacy wildcard mode.
|
||||||
Activity nonLegacyActivity = activitySource.StartActivity("TestActivity");
|
using var nonLegacyActivity = activitySource.StartActivity("TestActivity");
|
||||||
nonLegacyActivity.Start();
|
nonLegacyActivity.Start();
|
||||||
nonLegacyActivity.Stop();
|
nonLegacyActivity.Stop();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue