Adding files with blank space (#600)
This commit is contained in:
parent
48dbba3304
commit
fbcd1a0244
|
|
@ -69,7 +69,7 @@ namespace Benchmarks.Tracing
|
|||
public static TelemetrySpan CreateSpan_Active_GetCurrent(Tracer tracer)
|
||||
{
|
||||
TelemetrySpan span;
|
||||
|
||||
|
||||
using (tracer.StartActiveSpan("span", out _))
|
||||
{
|
||||
span = tracer.CurrentSpan;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace LoggingTracer
|
|||
AppendIndentedLine(sb, 5, $"{a.Key}' : {a.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Logger.Log(sb.ToString());
|
||||
|
||||
return Task.FromResult(ExportResult.Success);
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ namespace OpenTelemetry.Context.Propagation
|
|||
private static void LogTooManyItemsInTracestate()
|
||||
{
|
||||
#if API
|
||||
OpenTelemetryApiEventSource.Log.TooManyItemsInTracestate();
|
||||
OpenTelemetryApiEventSource.Log.TooManyItemsInTracestate();
|
||||
#else
|
||||
OpenTelemetrySdkEventSource.Log.TooManyItemsInTracestate();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ namespace OpenTelemetry.Exporter.LightStep.Implementation
|
|||
var sc = new SpanContext { SpanId = data.ParentSpanId.ToLSSpanId() };
|
||||
span.References.Add(new Reference
|
||||
{
|
||||
Relationship = "CHILD_OF", SpanContext = sc,
|
||||
Relationship = "CHILD_OF",
|
||||
SpanContext = sc,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +42,8 @@ namespace OpenTelemetry.Exporter.LightStep.Implementation
|
|||
|
||||
span.SpanContext = new SpanContext
|
||||
{
|
||||
SpanId = spanId, TraceId = traceId,
|
||||
SpanId = spanId,
|
||||
TraceId = traceId,
|
||||
};
|
||||
span.StartTimestamp = data.StartTimestamp.UtcDateTime;
|
||||
span.DurationMicros = Convert.ToUInt64(Math.Abs(duration.Ticks) / 10);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ namespace OpenTelemetry.Exporter.Stackdriver
|
|||
public override async Task<ExportResult> ExportAsync(IEnumerable<SpanData> spanDataList, CancellationToken cancellationToken)
|
||||
{
|
||||
var traceWriter = TraceServiceClient.Create(settings: this.traceServiceSettings);
|
||||
|
||||
|
||||
var batchSpansRequest = new BatchWriteSpansRequest
|
||||
{
|
||||
ProjectName = this.googleCloudProjectId,
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (span == null)
|
||||
{
|
||||
span = this.tracer.StartSpan(this.spanName, null, this.spanKind, options);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="DiagnosticSourceListener.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="DiagnosticSourceListener.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace OpenTelemetry.Internal
|
|||
internal class NoopDisposable : IDisposable
|
||||
{
|
||||
internal static readonly IDisposable Instance = new NoopDisposable();
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ namespace OpenTelemetry.Metrics.Export
|
|||
/// <param name="metricName">the name of the instrument.</param>
|
||||
/// <param name="labelSet">the labelSet associated with the instrument.</param>
|
||||
/// <param name="aggregator">the aggregator used.</param>
|
||||
public abstract void Process(string meterName, string metricName, LabelSet labelSet, Aggregator<double> aggregator);
|
||||
public abstract void Process(string meterName, string metricName, LabelSet labelSet, Aggregator<double> aggregator);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,6 @@ namespace OpenTelemetry.Metrics
|
|||
internal IDictionary<LabelSet, Int64ObserverMetricHandleSdk> GetAllHandles()
|
||||
{
|
||||
return this.observerHandles;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace OpenTelemetry.Metrics
|
|||
// NoPendingUpdate, to CandidateForRemoval, to physical removal.
|
||||
// i.e UpdatePending->NoPendingUpdate->CandidateForRemoval->removal
|
||||
if (handle.Value.Status == RecordStatus.CandidateForRemoval)
|
||||
{
|
||||
{
|
||||
// The actual removal doesn't occur here as we are still
|
||||
// iterating the dictionary.
|
||||
boundInstrumentsToRemove.Add(labelSet);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ namespace OpenTelemetry.Trace.Configuration
|
|||
|
||||
this.CollectorFactories.Add(
|
||||
new CollectorFactory(
|
||||
typeof(TCollector).Name,
|
||||
typeof(TCollector).Name,
|
||||
"semver:" + typeof(TCollector).Assembly.GetName().Version,
|
||||
collectorFactory));
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace OpenTelemetry.Trace.Export
|
|||
/// Batch export failed. Caller must not retry.
|
||||
/// </summary>
|
||||
FailedNotRetryable = 1,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Batch export failed transiently. Caller should record error and may retry.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace OpenTelemetry.Trace.Export
|
|||
/// </summary>
|
||||
/// <param name="span">Instance of span to process.</param>
|
||||
public abstract void OnStart(SpanData span);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Span end hook.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ namespace OpenTelemetry.Trace
|
|||
spanCreationOptions = new SpanCreationOptions
|
||||
{
|
||||
Attributes = activity.Tags.ToDictionary(k => k.Key, v => (object)v.Value),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var span = new SpanSdk(
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ namespace OpenTelemetry.Collector.Dependencies.Tests
|
|||
parent.TraceStateString = "k1=v1,k2=v2";
|
||||
parent.ActivityTraceFlags = ActivityTraceFlags.Recorded;
|
||||
|
||||
using (new HttpClientCollector(tracer, new HttpClientCollectorOptions {TextFormat = textFormat.Object}))
|
||||
using (new HttpClientCollector(tracer, new HttpClientCollectorOptions { TextFormat = textFormat.Object }))
|
||||
{
|
||||
using var c = new HttpClient();
|
||||
await c.SendAsync(request);
|
||||
|
|
|
|||
|
|
@ -1478,7 +1478,7 @@ namespace OpenTelemetry.Exporter.ApplicationInsights.Tests
|
|||
});
|
||||
|
||||
var span = CreateSpanData(name, traceId, parentSpanId, traceOptions,
|
||||
tracestate, kind, status, new SpanCreationOptions { Links = new [] { parentLink }});
|
||||
tracestate, kind, status, new SpanCreationOptions { Links = new[] { parentLink } });
|
||||
|
||||
var sentItems = ConvertSpan(span);
|
||||
|
||||
|
|
@ -1738,7 +1738,7 @@ namespace OpenTelemetry.Exporter.ApplicationInsights.Tests
|
|||
};
|
||||
|
||||
var span = CreateSpanData(name, traceId, parentSpanId, traceOptions,
|
||||
tracestate, spanKind, status, null, default, new[] {new Event("test message1")},
|
||||
tracestate, spanKind, status, null, default, new[] { new Event("test message1") },
|
||||
new Resource(resource));
|
||||
var sentItems = ConvertSpan(span);
|
||||
|
||||
|
|
@ -1866,14 +1866,14 @@ namespace OpenTelemetry.Exporter.ApplicationInsights.Tests
|
|||
var link1Enqueued = startTimestamp.AddMilliseconds(-200).ToUnixTimeMilliseconds();
|
||||
var link2Enqueued = startTimestamp.AddMilliseconds(-300).ToUnixTimeMilliseconds();
|
||||
|
||||
var link0 = new Link(RandomContext(), new Dictionary<string, object> {["enqueuedTime"] = link0Enqueued });
|
||||
var link0 = new Link(RandomContext(), new Dictionary<string, object> { ["enqueuedTime"] = link0Enqueued });
|
||||
var link1 = new Link(RandomContext(), new Dictionary<string, object> { ["enqueuedTime"] = link1Enqueued });
|
||||
var link2 = new Link(RandomContext(), new Dictionary<string, object> {["enqueuedTime"] = link2Enqueued });
|
||||
var link2 = new Link(RandomContext(), new Dictionary<string, object> { ["enqueuedTime"] = link2Enqueued });
|
||||
|
||||
var options = new SpanCreationOptions
|
||||
{
|
||||
StartTimestamp = startTimestamp,
|
||||
Links = new List<Link> {link0, link1, link2},
|
||||
Links = new List<Link> { link0, link1, link2 },
|
||||
Attributes = new Dictionary<string, object>
|
||||
{
|
||||
["az.namespace"] = "Microsoft.EventHub",
|
||||
|
|
@ -2278,7 +2278,7 @@ namespace OpenTelemetry.Exporter.ApplicationInsights.Tests
|
|||
|
||||
processor.Setup(p => p.OnEnd(It.IsAny<SpanData>()));
|
||||
|
||||
var tracer = TracerFactory.Create(b =>b
|
||||
var tracer = TracerFactory.Create(b => b
|
||||
.SetResource(resource)
|
||||
.AddProcessorPipeline(p => p.AddProcessor(_ => processor.Object)))
|
||||
.GetTracer(null);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace OpenTelemetry.Exporter.ApplicationInsights.Tests
|
|||
public void UseApplicationInsights_ConfiguresExporter()
|
||||
{
|
||||
var sentItems = new ConcurrentQueue<ITelemetry>();
|
||||
|
||||
|
||||
ITelemetryChannel channel = new StubTelemetryChannel
|
||||
{
|
||||
OnSend = t => sentItems.Enqueue(t),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ using Xunit;
|
|||
|
||||
namespace OpenTelemetry.Exporter.Jaeger.Tests.Implementation
|
||||
{
|
||||
public class ThriftUdpClientTransportTests: IDisposable
|
||||
public class ThriftUdpClientTransportTests : IDisposable
|
||||
{
|
||||
private MemoryStream testingMemoryStream = new MemoryStream();
|
||||
private readonly Mock<IJaegerClient> mockClient = new Mock<IJaegerClient>();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace OpenTelemetry.Exporter.Prometheus.Tests
|
|||
var promOptions = new PrometheusExporterOptions() { Url = "http://localhost:9184/metrics/" };
|
||||
var promExporter = new PrometheusExporter(promOptions);
|
||||
var simpleProcessor = new UngroupedBatcher(promExporter);
|
||||
|
||||
|
||||
var metricsHttpServer = new PrometheusExporterMetricsHttpServer(promExporter);
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,56 +1,57 @@
|
|||
// <copyright file="SpanContextShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System.Diagnostics;
|
||||
using Moq;
|
||||
using OpenTelemetry.Trace;
|
||||
// <copyright file="SpanContextShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of static helper methods for creating some default test setup objects.
|
||||
/// </summary>
|
||||
internal static class Defaults
|
||||
{
|
||||
public static SpanContext GetOpenTelemetrySpanContext()
|
||||
{
|
||||
return new SpanContext(
|
||||
ActivityTraceId.CreateRandom(),
|
||||
ActivitySpanId.CreateRandom(),
|
||||
ActivityTraceFlags.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of SpanMock from this test project. This is a basic implementation used to verify calls to add events, links, and attributes.
|
||||
/// </summary>
|
||||
/// <returns>an instance of Span.</returns>
|
||||
public static SpanMock GetOpenTelemetrySpanMock()
|
||||
{
|
||||
return new SpanMock(GetOpenTelemetrySpanContext());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a mock implementation of OpenTelemetry TelemetrySpan suitable for certain kinds of unit tests.
|
||||
/// </summary>
|
||||
/// <returns>a mock of the OpenTelemetry ISpan.</returns>
|
||||
public static Mock<TelemetrySpan> GetOpenTelemetryMockSpan()
|
||||
{
|
||||
var spanContext = GetOpenTelemetrySpanContext();
|
||||
var mock = new Mock<TelemetrySpan>();
|
||||
mock.Setup(o => o.Context).Returns(spanContext);
|
||||
return mock;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Diagnostics;
|
||||
using Moq;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of static helper methods for creating some default test setup objects.
|
||||
/// </summary>
|
||||
internal static class Defaults
|
||||
{
|
||||
public static SpanContext GetOpenTelemetrySpanContext()
|
||||
{
|
||||
return new SpanContext(
|
||||
ActivityTraceId.CreateRandom(),
|
||||
ActivitySpanId.CreateRandom(),
|
||||
ActivityTraceFlags.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an instance of SpanMock from this test project. This is a basic implementation used to verify calls to add events, links, and attributes.
|
||||
/// </summary>
|
||||
/// <returns>an instance of Span.</returns>
|
||||
public static SpanMock GetOpenTelemetrySpanMock()
|
||||
{
|
||||
return new SpanMock(GetOpenTelemetrySpanContext());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a mock implementation of OpenTelemetry TelemetrySpan suitable for certain kinds of unit tests.
|
||||
/// </summary>
|
||||
/// <returns>a mock of the OpenTelemetry ISpan.</returns>
|
||||
public static Mock<TelemetrySpan> GetOpenTelemetryMockSpan()
|
||||
{
|
||||
var spanContext = GetOpenTelemetrySpanContext();
|
||||
var mock = new Mock<TelemetrySpan>();
|
||||
mock.Setup(o => o.Context).Returns(spanContext);
|
||||
return mock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,92 +1,93 @@
|
|||
// <copyright file="ScopeManagerShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using Moq;
|
||||
using OpenTelemetry.Trace;
|
||||
using Xunit;
|
||||
// <copyright file="ScopeManagerShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
public class ScopeManagerShimTests
|
||||
{
|
||||
[Fact]
|
||||
public void CtorArgumentValidation()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ScopeManagerShim(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Active_IsNull()
|
||||
{
|
||||
var tracer = TracerFactoryBase.Default.GetTracer(null);
|
||||
var shim = new ScopeManagerShim(tracer);
|
||||
|
||||
Assert.False(tracer.CurrentSpan.Context.IsValid);
|
||||
Assert.Null(shim.Active);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Active_IsNotNull()
|
||||
{
|
||||
var tracerMock = new Mock<Tracer>();
|
||||
var shim = new ScopeManagerShim(tracerMock.Object);
|
||||
var openTracingSpan = new SpanShim(Defaults.GetOpenTelemetrySpanMock());
|
||||
var scopeMock = new Mock<IDisposable>();
|
||||
|
||||
tracerMock.Setup(x => x.WithSpan(openTracingSpan.Span, It.IsAny<bool>())).Returns(scopeMock.Object);
|
||||
tracerMock.Setup(x => x.CurrentSpan).Returns(openTracingSpan.Span);
|
||||
|
||||
var scope = shim.Activate(openTracingSpan, true);
|
||||
Assert.NotNull(scope);
|
||||
|
||||
var activeScope = shim.Active;
|
||||
Assert.Equal(scope, activeScope);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Activate_SpanMustBeShim()
|
||||
{
|
||||
var tracerMock = new Mock<Tracer>();
|
||||
var shim = new ScopeManagerShim(tracerMock.Object);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => shim.Activate(new Mock<global::OpenTracing.ISpan>().Object, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Activate()
|
||||
{
|
||||
var tracerMock = new Mock<Tracer>();
|
||||
var shim = new ScopeManagerShim(tracerMock.Object);
|
||||
var scopeMock = new Mock<IDisposable>();
|
||||
var spanShim = new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object);
|
||||
|
||||
tracerMock.Setup(x => x.WithSpan(spanShim.Span, It.IsAny<bool>())).Returns(scopeMock.Object);
|
||||
|
||||
using (shim.Activate(spanShim, true))
|
||||
{
|
||||
#if DEBUG
|
||||
Assert.Equal(1, shim.SpanScopeTableCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
Assert.Equal(0, shim.SpanScopeTableCount);
|
||||
#endif
|
||||
tracerMock.Verify(x => x.WithSpan(spanShim.Span, It.IsAny<bool>()), Times.Once);
|
||||
scopeMock.Verify(x => x.Dispose(), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Moq;
|
||||
using OpenTelemetry.Trace;
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
public class ScopeManagerShimTests
|
||||
{
|
||||
[Fact]
|
||||
public void CtorArgumentValidation()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ScopeManagerShim(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Active_IsNull()
|
||||
{
|
||||
var tracer = TracerFactoryBase.Default.GetTracer(null);
|
||||
var shim = new ScopeManagerShim(tracer);
|
||||
|
||||
Assert.False(tracer.CurrentSpan.Context.IsValid);
|
||||
Assert.Null(shim.Active);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Active_IsNotNull()
|
||||
{
|
||||
var tracerMock = new Mock<Tracer>();
|
||||
var shim = new ScopeManagerShim(tracerMock.Object);
|
||||
var openTracingSpan = new SpanShim(Defaults.GetOpenTelemetrySpanMock());
|
||||
var scopeMock = new Mock<IDisposable>();
|
||||
|
||||
tracerMock.Setup(x => x.WithSpan(openTracingSpan.Span, It.IsAny<bool>())).Returns(scopeMock.Object);
|
||||
tracerMock.Setup(x => x.CurrentSpan).Returns(openTracingSpan.Span);
|
||||
|
||||
var scope = shim.Activate(openTracingSpan, true);
|
||||
Assert.NotNull(scope);
|
||||
|
||||
var activeScope = shim.Active;
|
||||
Assert.Equal(scope, activeScope);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Activate_SpanMustBeShim()
|
||||
{
|
||||
var tracerMock = new Mock<Tracer>();
|
||||
var shim = new ScopeManagerShim(tracerMock.Object);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => shim.Activate(new Mock<global::OpenTracing.ISpan>().Object, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Activate()
|
||||
{
|
||||
var tracerMock = new Mock<Tracer>();
|
||||
var shim = new ScopeManagerShim(tracerMock.Object);
|
||||
var scopeMock = new Mock<IDisposable>();
|
||||
var spanShim = new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object);
|
||||
|
||||
tracerMock.Setup(x => x.WithSpan(spanShim.Span, It.IsAny<bool>())).Returns(scopeMock.Object);
|
||||
|
||||
using (shim.Activate(spanShim, true))
|
||||
{
|
||||
#if DEBUG
|
||||
Assert.Equal(1, shim.SpanScopeTableCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
Assert.Equal(0, shim.SpanScopeTableCount);
|
||||
#endif
|
||||
tracerMock.Verify(x => x.WithSpan(spanShim.Span, It.IsAny<bool>()), Times.Once);
|
||||
scopeMock.Verify(x => x.Dispose(), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,60 +1,61 @@
|
|||
// <copyright file="SpanContextShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry.Trace;
|
||||
using Xunit;
|
||||
// <copyright file="SpanContextShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
public class SpanContextShimTests
|
||||
{
|
||||
[Fact]
|
||||
public void CtorArgumentValidation()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new SpanContextShim(default));
|
||||
Assert.Throws<ArgumentException>(() => new SpanContextShim(new SpanContext(default, default, ActivityTraceFlags.None)));
|
||||
Assert.Throws<ArgumentException>(() => new SpanContextShim(new SpanContext(default, default, ActivityTraceFlags.None, true)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetTraceId()
|
||||
{
|
||||
var shim = GetSpanContextShim();
|
||||
|
||||
Assert.Equal(shim.SpanContext.TraceId.ToString(), shim.TraceId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSpanId()
|
||||
{
|
||||
var shim = GetSpanContextShim();
|
||||
|
||||
Assert.Equal(shim.SpanContext.SpanId.ToString(), shim.SpanId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBaggage()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
internal static SpanContextShim GetSpanContextShim()
|
||||
{
|
||||
return new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry.Trace;
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
public class SpanContextShimTests
|
||||
{
|
||||
[Fact]
|
||||
public void CtorArgumentValidation()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new SpanContextShim(default));
|
||||
Assert.Throws<ArgumentException>(() => new SpanContextShim(new SpanContext(default, default, ActivityTraceFlags.None)));
|
||||
Assert.Throws<ArgumentException>(() => new SpanContextShim(new SpanContext(default, default, ActivityTraceFlags.None, true)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetTraceId()
|
||||
{
|
||||
var shim = GetSpanContextShim();
|
||||
|
||||
Assert.Equal(shim.SpanContext.TraceId.ToString(), shim.TraceId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSpanId()
|
||||
{
|
||||
var shim = GetSpanContextShim();
|
||||
|
||||
Assert.Equal(shim.SpanContext.SpanId.ToString(), shim.SpanId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBaggage()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
internal static SpanContextShim GetSpanContextShim()
|
||||
{
|
||||
return new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,323 +1,324 @@
|
|||
// <copyright file="SpanShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using global::OpenTracing.Tag;
|
||||
using Moq;
|
||||
using OpenTelemetry.Trace;
|
||||
using Xunit;
|
||||
// <copyright file="SpanShimTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
public class SpanShimTests
|
||||
{
|
||||
[Fact]
|
||||
public void CtorArgumentValidation()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new SpanShim(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SpanContextIsNotNull()
|
||||
{
|
||||
var shim = new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object);
|
||||
|
||||
// ISpanContext validation handled in a separate test class
|
||||
Assert.NotNull(shim.Context);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FinishSpan()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
shim.Finish();
|
||||
|
||||
spanMock.Verify(o => o.End(), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FinishSpanUsingSpecificTimestamp()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
var endTime = DateTimeOffset.UtcNow;
|
||||
shim.Finish(endTime);
|
||||
|
||||
spanMock.Verify(o => o.End(endTime), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetOperationName()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
// parameter validation
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetOperationName(null));
|
||||
|
||||
shim.SetOperationName("bar");
|
||||
|
||||
spanMock.Verify(o => o.UpdateName("bar"), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBaggageItem()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
// parameter validation
|
||||
Assert.Throws<ArgumentNullException>(() => shim.GetBaggageItem(null));
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Log()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
shim.Log("foo");
|
||||
|
||||
Assert.Single(spanMock.Events);
|
||||
var first = spanMock.Events.First();
|
||||
Assert.Equal("foo", first.Name);
|
||||
Assert.False(first.Attributes.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogWithExplicitTimestamp()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
shim.Log(now, "foo");
|
||||
|
||||
Assert.Single(spanMock.Events);
|
||||
var first = spanMock.Events.First();
|
||||
Assert.Equal("foo", first.Name);
|
||||
Assert.Equal(now, first.Timestamp);
|
||||
Assert.False(first.Attributes.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogUsingFields()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.Log((IEnumerable<KeyValuePair<string, object>>)null));
|
||||
|
||||
shim.Log(new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("foo", "bar"),
|
||||
});
|
||||
|
||||
// "event" is a special event name
|
||||
shim.Log(new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("event", "foo"),
|
||||
});
|
||||
|
||||
var first = spanMock.Events.FirstOrDefault();
|
||||
var last = spanMock.Events.LastOrDefault();
|
||||
|
||||
Assert.Equal(2, spanMock.Events.Count);
|
||||
|
||||
Assert.Equal(SpanShim.DefaultEventName, first.Name);
|
||||
Assert.True(first.Attributes.Any());
|
||||
|
||||
Assert.Equal("foo", last.Name);
|
||||
Assert.False(last.Attributes.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogUsingFieldsWithExplicitTimestamp()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.Log((IEnumerable<KeyValuePair<string, object>>)null));
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
|
||||
shim.Log(now, new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("foo", "bar"),
|
||||
});
|
||||
|
||||
// "event" is a special event name
|
||||
shim.Log(now, new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("event", "foo"),
|
||||
});
|
||||
|
||||
Assert.Equal(2, spanMock.Events.Count);
|
||||
var first = spanMock.Events.First();
|
||||
var last = spanMock.Events.Last();
|
||||
|
||||
Assert.Equal(SpanShim.DefaultEventName, first.Name);
|
||||
Assert.True(first.Attributes.Any());
|
||||
Assert.Equal(now, first.Timestamp);
|
||||
|
||||
Assert.Equal("foo", last.Name);
|
||||
Assert.False(last.Attributes.Any());
|
||||
Assert.Equal(now, last.Timestamp);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagStringValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((string)null, "foo"));
|
||||
|
||||
shim.SetTag("foo", "bar");
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal("bar", spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagBoolValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((string)null, true));
|
||||
|
||||
shim.SetTag("foo", true);
|
||||
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, true);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.True((bool)spanMock.Attributes.First().Value);
|
||||
|
||||
// A boolean tag named "error" is a special case that must be checked
|
||||
Assert.Equal(Status.Unknown, spanMock.GetStatus());
|
||||
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
|
||||
Assert.Equal(Status.Ok, spanMock.GetStatus());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagIntValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((string)null, 1));
|
||||
|
||||
shim.SetTag("foo", 1);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1L, spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagDoubleValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag(null, 1D));
|
||||
|
||||
shim.SetTag("foo", 1D);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1, (double)spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagBooleanTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((BooleanTag)null, true));
|
||||
|
||||
shim.SetTag(new BooleanTag("foo"), true);
|
||||
shim.SetTag(new BooleanTag(global::OpenTracing.Tag.Tags.Error.Key), true);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.True((bool)spanMock.Attributes.First().Value);
|
||||
|
||||
// A boolean tag named "error" is a special case that must be checked
|
||||
Assert.Equal(Status.Unknown, spanMock.GetStatus());
|
||||
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
|
||||
Assert.Equal(Status.Ok, spanMock.GetStatus());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagStringTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((StringTag)null, "foo"));
|
||||
|
||||
shim.SetTag(new StringTag("foo"), "bar");
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal("bar", (string)spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagIntTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((IntTag)null, 1));
|
||||
|
||||
shim.SetTag(new IntTag("foo"), 1);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1L, spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagIntOrStringTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((IntOrStringTag)null, "foo"));
|
||||
|
||||
shim.SetTag(new IntOrStringTag("foo"), 1);
|
||||
shim.SetTag(new IntOrStringTag("bar"), "baz");
|
||||
|
||||
Assert.Equal(2, spanMock.Attributes.Count);
|
||||
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1L, spanMock.Attributes.First().Value);
|
||||
|
||||
Assert.Equal("bar", spanMock.Attributes.Last().Key);
|
||||
Assert.Equal("baz", (string)spanMock.Attributes.Last().Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using global::OpenTracing.Tag;
|
||||
using Moq;
|
||||
using OpenTelemetry.Trace;
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing.Tests
|
||||
{
|
||||
public class SpanShimTests
|
||||
{
|
||||
[Fact]
|
||||
public void CtorArgumentValidation()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new SpanShim(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SpanContextIsNotNull()
|
||||
{
|
||||
var shim = new SpanShim(Defaults.GetOpenTelemetryMockSpan().Object);
|
||||
|
||||
// ISpanContext validation handled in a separate test class
|
||||
Assert.NotNull(shim.Context);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FinishSpan()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
shim.Finish();
|
||||
|
||||
spanMock.Verify(o => o.End(), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FinishSpanUsingSpecificTimestamp()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
var endTime = DateTimeOffset.UtcNow;
|
||||
shim.Finish(endTime);
|
||||
|
||||
spanMock.Verify(o => o.End(endTime), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetOperationName()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
// parameter validation
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetOperationName(null));
|
||||
|
||||
shim.SetOperationName("bar");
|
||||
|
||||
spanMock.Verify(o => o.UpdateName("bar"), Times.Once());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBaggageItem()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetryMockSpan();
|
||||
var shim = new SpanShim(spanMock.Object);
|
||||
|
||||
// parameter validation
|
||||
Assert.Throws<ArgumentNullException>(() => shim.GetBaggageItem(null));
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Log()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
shim.Log("foo");
|
||||
|
||||
Assert.Single(spanMock.Events);
|
||||
var first = spanMock.Events.First();
|
||||
Assert.Equal("foo", first.Name);
|
||||
Assert.False(first.Attributes.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogWithExplicitTimestamp()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
shim.Log(now, "foo");
|
||||
|
||||
Assert.Single(spanMock.Events);
|
||||
var first = spanMock.Events.First();
|
||||
Assert.Equal("foo", first.Name);
|
||||
Assert.Equal(now, first.Timestamp);
|
||||
Assert.False(first.Attributes.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogUsingFields()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.Log((IEnumerable<KeyValuePair<string, object>>)null));
|
||||
|
||||
shim.Log(new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("foo", "bar"),
|
||||
});
|
||||
|
||||
// "event" is a special event name
|
||||
shim.Log(new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("event", "foo"),
|
||||
});
|
||||
|
||||
var first = spanMock.Events.FirstOrDefault();
|
||||
var last = spanMock.Events.LastOrDefault();
|
||||
|
||||
Assert.Equal(2, spanMock.Events.Count);
|
||||
|
||||
Assert.Equal(SpanShim.DefaultEventName, first.Name);
|
||||
Assert.True(first.Attributes.Any());
|
||||
|
||||
Assert.Equal("foo", last.Name);
|
||||
Assert.False(last.Attributes.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogUsingFieldsWithExplicitTimestamp()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.Log((IEnumerable<KeyValuePair<string, object>>)null));
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
|
||||
shim.Log(now, new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("foo", "bar"),
|
||||
});
|
||||
|
||||
// "event" is a special event name
|
||||
shim.Log(now, new List<KeyValuePair<string, object>>
|
||||
{
|
||||
new KeyValuePair<string, object>("event", "foo"),
|
||||
});
|
||||
|
||||
Assert.Equal(2, spanMock.Events.Count);
|
||||
var first = spanMock.Events.First();
|
||||
var last = spanMock.Events.Last();
|
||||
|
||||
Assert.Equal(SpanShim.DefaultEventName, first.Name);
|
||||
Assert.True(first.Attributes.Any());
|
||||
Assert.Equal(now, first.Timestamp);
|
||||
|
||||
Assert.Equal("foo", last.Name);
|
||||
Assert.False(last.Attributes.Any());
|
||||
Assert.Equal(now, last.Timestamp);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagStringValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((string)null, "foo"));
|
||||
|
||||
shim.SetTag("foo", "bar");
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal("bar", spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagBoolValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((string)null, true));
|
||||
|
||||
shim.SetTag("foo", true);
|
||||
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, true);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.True((bool)spanMock.Attributes.First().Value);
|
||||
|
||||
// A boolean tag named "error" is a special case that must be checked
|
||||
Assert.Equal(Status.Unknown, spanMock.GetStatus());
|
||||
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
|
||||
Assert.Equal(Status.Ok, spanMock.GetStatus());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagIntValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((string)null, 1));
|
||||
|
||||
shim.SetTag("foo", 1);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1L, spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagDoubleValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag(null, 1D));
|
||||
|
||||
shim.SetTag("foo", 1D);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1, (double)spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagBooleanTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((BooleanTag)null, true));
|
||||
|
||||
shim.SetTag(new BooleanTag("foo"), true);
|
||||
shim.SetTag(new BooleanTag(global::OpenTracing.Tag.Tags.Error.Key), true);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.True((bool)spanMock.Attributes.First().Value);
|
||||
|
||||
// A boolean tag named "error" is a special case that must be checked
|
||||
Assert.Equal(Status.Unknown, spanMock.GetStatus());
|
||||
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
|
||||
Assert.Equal(Status.Ok, spanMock.GetStatus());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagStringTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((StringTag)null, "foo"));
|
||||
|
||||
shim.SetTag(new StringTag("foo"), "bar");
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal("bar", (string)spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagIntTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((IntTag)null, 1));
|
||||
|
||||
shim.SetTag(new IntTag("foo"), 1);
|
||||
|
||||
Assert.Single(spanMock.Attributes);
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1L, spanMock.Attributes.First().Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTagIntOrStringTagValue()
|
||||
{
|
||||
var spanMock = Defaults.GetOpenTelemetrySpanMock();
|
||||
var shim = new SpanShim(spanMock);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.SetTag((IntOrStringTag)null, "foo"));
|
||||
|
||||
shim.SetTag(new IntOrStringTag("foo"), 1);
|
||||
shim.SetTag(new IntOrStringTag("bar"), "baz");
|
||||
|
||||
Assert.Equal(2, spanMock.Attributes.Count);
|
||||
|
||||
Assert.Equal("foo", spanMock.Attributes.First().Key);
|
||||
Assert.Equal(1L, spanMock.Attributes.First().Value);
|
||||
|
||||
Assert.Equal("bar", spanMock.Attributes.Last().Key);
|
||||
Assert.Equal("baz", (string)spanMock.Attributes.Last().Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace OpenTelemetry.Tests
|
|||
[Fact]
|
||||
public void NoEviction()
|
||||
{
|
||||
var eq = new EvictingQueue<int>(4) {0, 1, 2};
|
||||
var eq = new EvictingQueue<int>(4) { 0, 1, 2 };
|
||||
|
||||
var items = eq.ToArray();
|
||||
Assert.Equal(3, items.Length);
|
||||
|
|
@ -65,7 +65,7 @@ namespace OpenTelemetry.Tests
|
|||
[Fact]
|
||||
public void Eviction()
|
||||
{
|
||||
var eq = new EvictingQueue<int>(4) {0, 1, 2, 3, 4};
|
||||
var eq = new EvictingQueue<int>(4) { 0, 1, 2, 3, 4 };
|
||||
Assert.Equal(4, eq.Count);
|
||||
Assert.Equal(1, eq.DroppedItems);
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ namespace OpenTelemetry.Tests
|
|||
[Fact]
|
||||
public void MaxItems0()
|
||||
{
|
||||
var eq = new EvictingQueue<int>(0) {0};
|
||||
var eq = new EvictingQueue<int>(0) { 0 };
|
||||
Assert.Equal(0, eq.Count);
|
||||
Assert.Equal(1, eq.DroppedItems);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ namespace OpenTelemetry.Context.Test
|
|||
public async void TestContextInheritance()
|
||||
{
|
||||
DistributedContext.Carrier = AsyncLocalDistributedContextCarrier.Instance;
|
||||
var list1 = new List<CorrelationContextEntry>(1) {new CorrelationContextEntry(KEY_1, VALUE_1)};
|
||||
var list2 = new List<CorrelationContextEntry>(2) {new CorrelationContextEntry(KEY_1, VALUE_1), new CorrelationContextEntry(KEY_2, VALUE_2)};
|
||||
var list1 = new List<CorrelationContextEntry>(1) { new CorrelationContextEntry(KEY_1, VALUE_1) };
|
||||
var list2 = new List<CorrelationContextEntry>(2) { new CorrelationContextEntry(KEY_1, VALUE_1), new CorrelationContextEntry(KEY_2, VALUE_2) };
|
||||
|
||||
DistributedContext.SetCurrent(DistributedContext.Empty);
|
||||
await Task.Run(() => Assert.Equal(DistributedContext.Empty, DistributedContext.Current));
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
var dc = serializer.FromByteArray(serializer.ToByteArray(DistributedContext.Empty));
|
||||
Assert.Empty(dc.CorrelationContext.Entries);
|
||||
|
||||
dc = serializer.FromByteArray(new byte[] {SerializationUtils.VersionId}); // One byte that represents Version ID.
|
||||
dc = serializer.FromByteArray(new byte[] { SerializationUtils.VersionId }); // One byte that represents Version ID.
|
||||
Assert.Empty(dc.CorrelationContext.Entries);
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
EncodeTagToOutPut("Key2", "Value2", output);
|
||||
|
||||
var expected = DistributedContextBuilder.CreateContext(
|
||||
new List<CorrelationContextEntry>(2) {new CorrelationContextEntry("Key1", "Value1"), new CorrelationContextEntry("Key2", "Value2")}
|
||||
new List<CorrelationContextEntry>(2) { new CorrelationContextEntry("Key1", "Value1"), new CorrelationContextEntry("Key2", "Value2") }
|
||||
);
|
||||
Assert.Equal(expected, serializer.FromByteArray(output.ToArray()));
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
|
||||
// Write unknown field ID 1.
|
||||
output.WriteByte(1);
|
||||
output.Write(new byte[] {1, 2, 3, 4}, 0, 4);
|
||||
output.Write(new byte[] { 1, 2, 3, 4 }, 0, 4);
|
||||
|
||||
EncodeTagToOutPut("Key3", "Value3", output);
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
|
||||
// Write unknown field ID 1.
|
||||
output.WriteByte(1);
|
||||
output.Write(new byte[] {1, 2, 3, 4}, 0, 4);
|
||||
output.Write(new byte[] { 1, 2, 3, 4 }, 0, 4);
|
||||
|
||||
EncodeTagToOutPut("Key", "Value", output);
|
||||
Assert.Equal(DistributedContext.Empty, serializer.FromByteArray(output.ToArray()));
|
||||
|
|
@ -242,13 +242,13 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
[Fact]
|
||||
public void TestDeserializeWrongVersionId()
|
||||
{
|
||||
Assert.Equal(DistributedContext.Empty, serializer.FromByteArray(new byte[] {SerializationUtils.VersionId + 1}));
|
||||
Assert.Equal(DistributedContext.Empty, serializer.FromByteArray(new byte[] { SerializationUtils.VersionId + 1 }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDeserializeNegativeVersionId()
|
||||
{
|
||||
Assert.Equal(DistributedContext.Empty, serializer.FromByteArray(new byte[] {0xff}));
|
||||
Assert.Equal(DistributedContext.Empty, serializer.FromByteArray(new byte[] { 0xff }));
|
||||
}
|
||||
|
||||
// <tag_encoding> ==
|
||||
|
|
@ -270,7 +270,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
var bytes = new byte[VarInt.VarIntSize(length)];
|
||||
VarInt.PutVarInt(length, bytes, 0);
|
||||
output.Write(bytes, 0, bytes.Length);
|
||||
var inPutBytes= Encoding.UTF8.GetBytes(input);
|
||||
var inPutBytes = Encoding.UTF8.GetBytes(input);
|
||||
output.Write(inPutBytes, 0, inPutBytes.Length);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,12 +94,12 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
|
||||
var actual = serializer.ToByteArray(DistributedContextBuilder.CreateContext(list));
|
||||
var tagsList = tags.ToList();
|
||||
var tagPermutation= Permutate(tagsList, tagsList.Count);
|
||||
var tagPermutation = Permutate(tagsList, tagsList.Count);
|
||||
ISet<string> possibleOutPuts = new HashSet<string>();
|
||||
|
||||
foreach (var distributedContextEntries in tagPermutation)
|
||||
{
|
||||
var l = (List<CorrelationContextEntry>) distributedContextEntries;
|
||||
var l = (List<CorrelationContextEntry>)distributedContextEntries;
|
||||
var expected = new MemoryStream();
|
||||
expected.WriteByte(SerializationUtils.VersionId);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ namespace OpenTelemetry.Internal.Test
|
|||
{
|
||||
Assert.True(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace OpenTelemetry.Metrics.Test
|
|||
{
|
||||
public class CounterAggregatorTest
|
||||
{
|
||||
private class UpdateThreadArguments<T> where T: struct
|
||||
private class UpdateThreadArguments<T> where T : struct
|
||||
{
|
||||
public ManualResetEvent mreToBlockUpdateThread;
|
||||
public ManualResetEvent mreToEnsureAllThreadsStart;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace OpenTelemetry.Metrics.Test
|
|||
{
|
||||
public class MinMaxSumCountAggregatorTest
|
||||
{
|
||||
private class UpdateThreadArguments<T> where T: struct
|
||||
private class UpdateThreadArguments<T> where T : struct
|
||||
{
|
||||
public ManualResetEvent mreToBlockUpdateThread;
|
||||
public ManualResetEvent mreToEnsureAllThreadsStart;
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ namespace OpenTelemetry.Metrics.Test
|
|||
Assert.Equal(3, testProcessor.longMetrics.Count);
|
||||
Assert.Equal(3, testProcessor.longMetrics.Count(m => m.MetricName == "testCounter"));
|
||||
|
||||
Assert.Single(testProcessor.longMetrics.Where(m => (m.Data as SumData<long>).Sum == 110 ));
|
||||
Assert.Single(testProcessor.longMetrics.Where(m => (m.Data as SumData<long>).Sum == 110));
|
||||
Assert.Single(testProcessor.longMetrics.Where(m => (m.Data as SumData<long>).Sum == 200));
|
||||
Assert.Single(testProcessor.longMetrics.Where(m => (m.Data as SumData<long>).Sum == 210));
|
||||
Assert.Single(testProcessor.longMetrics.Where(m => (m.Data as SumData<long>).Sum == 210));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -136,7 +136,7 @@ namespace OpenTelemetry.Metrics.Test
|
|||
|
||||
var labels2 = new List<KeyValuePair<string, string>>();
|
||||
labels2.Add(new KeyValuePair<string, string>("dim1", "value2"));
|
||||
|
||||
|
||||
observerMetric.Observe(10, labels1);
|
||||
observerMetric.Observe(20, labels1);
|
||||
observerMetric.Observe(30, labels1);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace OpenTelemetry.Impl.Resources
|
|||
public void CreateResource_EmptyAttributeValue()
|
||||
{
|
||||
// Arrange
|
||||
var attributes = new Dictionary<string, object> {{"EmptyValue", string.Empty}};
|
||||
var attributes = new Dictionary<string, object> { { "EmptyValue", string.Empty } };
|
||||
|
||||
// does not throw
|
||||
var resource = new Resource(attributes);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace OpenTelemetry.Tests.Impl.Resources
|
|||
{
|
||||
var resource = OpenTelemetry.Resources.Resources.CreateServiceResource("my-service");
|
||||
Assert.Equal(2, resource.Attributes.Count());
|
||||
Assert.Contains(new KeyValuePair<string ,object>(Resource.ServiceNameKey, "my-service"), resource.Attributes);
|
||||
Assert.Contains(new KeyValuePair<string, object>(Resource.ServiceNameKey, "my-service"), resource.Attributes);
|
||||
Assert.Single(resource.Attributes.Where(kvp => kvp.Key == Resource.ServiceNameKey));
|
||||
Assert.True(Guid.TryParse((string)resource.Attributes.Single(kvp => kvp.Key == Resource.ServiceInstanceIdKey).Value, out _));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace OpenTelemetry.Tests.Impl.Trace.Config
|
|||
|
||||
});
|
||||
|
||||
var broadcastProcessor = new BroadcastProcessor(new []{ processor1, processor2 });
|
||||
var broadcastProcessor = new BroadcastProcessor(new[] { processor1, processor2 });
|
||||
|
||||
var tracer = TracerFactory.Create(_ => { }).GetTracer(null);
|
||||
var span = (SpanSdk)tracer.StartSpan("foo");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace OpenTelemetry.Trace.Config.Test
|
|||
[Fact]
|
||||
public void UpdateTraceParams_NonPositiveMaxNumberOfAttributes()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new TracerConfiguration(0 ,1, 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new TracerConfiguration(0, 1, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
Assert.True(collectorFactoryCalled);
|
||||
}
|
||||
|
||||
private class TestCollector
|
||||
private class TestCollector
|
||||
{
|
||||
private readonly Tracer tracer;
|
||||
public TestCollector(Tracer tracer)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
|
||||
var testExporter = new TestExporter(spans =>
|
||||
{
|
||||
exporterCalledCount ++;
|
||||
exporterCalledCount++;
|
||||
Assert.Single(spans);
|
||||
Assert.IsType<SpanData>(spans.Single());
|
||||
});
|
||||
|
|
@ -136,8 +136,8 @@ namespace OpenTelemetry.Trace.Test
|
|||
var processCalledCount = 0;
|
||||
|
||||
TestProcessor testProcessor1 = null;
|
||||
var testProcessor2 = new TestProcessor(_ => processCalledCount ++);
|
||||
|
||||
var testProcessor2 = new TestProcessor(_ => processCalledCount++);
|
||||
|
||||
var tracerFactory = TracerFactory.Create(b => b
|
||||
.AddProcessorPipeline(p => p
|
||||
.SetExporter(testExporter)
|
||||
|
|
@ -160,7 +160,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
Assert.True(testProcessor1.IsDisposed);
|
||||
Assert.True(testProcessor2.IsDisposed);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void GetTracer_NoName_NoVersion()
|
||||
{
|
||||
|
|
@ -210,9 +210,11 @@ namespace OpenTelemetry.Trace.Test
|
|||
[Fact]
|
||||
public void GetTracerReturnsTracerWithResourceOverriddenBySetResource()
|
||||
{
|
||||
var tracerFactory = TracerFactory.Create(b => {
|
||||
var tracerFactory = TracerFactory.Create(b =>
|
||||
{
|
||||
b.SetResource(new Resource(new Dictionary<string, object>() { { "a", "b" } }))
|
||||
.SetResource(new Resource(new Dictionary<string, object>() { { "a", "c" } })); });
|
||||
.SetResource(new Resource(new Dictionary<string, object>() { { "a", "c" } }));
|
||||
});
|
||||
var tracer = (TracerSdk)tracerFactory.GetTracer("foo", "semver:1.2.3");
|
||||
Assert.Equal("c", tracer.LibraryResource.Attributes.Single(kvp => kvp.Key == "a").Value);
|
||||
}
|
||||
|
|
@ -270,7 +272,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
public override void OnEnd(SpanData span)
|
||||
{
|
||||
this.onEnd?.Invoke(span);
|
||||
exporter?.ExportAsync(new[] {span}, default);
|
||||
exporter?.ExportAsync(new[] { span }, default);
|
||||
}
|
||||
|
||||
public override Task ShutdownAsync(CancellationToken cancellationToken)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ using Xunit;
|
|||
|
||||
namespace OpenTelemetry.Trace.Test
|
||||
{
|
||||
public class CurrentSpanTests: IDisposable
|
||||
public class CurrentSpanTests : IDisposable
|
||||
{
|
||||
private readonly Tracer tracer;
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
{
|
||||
var span = (SpanSdk)tracer.StartRootSpan("foo");
|
||||
|
||||
using(var scope1 = this.tracer.WithSpan(span))
|
||||
using (var scope1 = this.tracer.WithSpan(span))
|
||||
{
|
||||
using var scope2 = this.tracer.WithSpan(span);
|
||||
Assert.IsNotType<NoopDisposable>(scope1);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ namespace OpenTelemetry.Trace.Export.Test
|
|||
|
||||
[Fact]
|
||||
public void ProcessorDoesNotBlockOnExporter()
|
||||
{
|
||||
{
|
||||
var resetEvent = new ManualResetEvent(false);
|
||||
var spanExporter = new TestExporter(_ => resetEvent.WaitOne(TimeSpan.FromSeconds(10)));
|
||||
using var factory = TracerFactory.Create(b => b
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ namespace OpenTelemetry.Trace.Export.Test
|
|||
[Fact]
|
||||
public void ProcessorDoesNotBlockOnExporter()
|
||||
{
|
||||
spanExporter = new TestExporter( async _ => await Task.Delay(500));
|
||||
spanExporter = new TestExporter(async _ => await Task.Delay(500));
|
||||
tracer = TracerFactory.Create(b => b
|
||||
.AddProcessorPipeline(p => p
|
||||
.SetExporter(spanExporter)
|
||||
|
|
@ -104,7 +104,7 @@ namespace OpenTelemetry.Trace.Export.Test
|
|||
|
||||
Assert.InRange(sw.Elapsed, TimeSpan.Zero, TimeSpan.FromMilliseconds(100));
|
||||
|
||||
var exported = WaitForSpans(spanExporter, 1, TimeSpan.FromMilliseconds(600));
|
||||
var exported = WaitForSpans(spanExporter, 1, TimeSpan.FromMilliseconds(600));
|
||||
|
||||
Assert.Single(exported);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
Assert.NotEqual(link1, link2);
|
||||
Assert.True(link1 != link2);
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Activity.Current = null;
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
[Fact]
|
||||
public void ParseMissingTraceId()
|
||||
{
|
||||
var invalidHeaders = new Dictionary<string, string> {{B3Format.XB3SpanId, SpanIdBase16},};
|
||||
var invalidHeaders = new Dictionary<string, string> { { B3Format.XB3SpanId, SpanIdBase16 }, };
|
||||
Assert.Equal(SpanContext.BlankRemote, b3Format.Extract(invalidHeaders, Getter));
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
[Fact]
|
||||
public void ParseMissingSpanId()
|
||||
{
|
||||
var invalidHeaders = new Dictionary<string, string> {{B3Format.XB3TraceId, TraceIdBase16}};
|
||||
var invalidHeaders = new Dictionary<string, string> { { B3Format.XB3TraceId, TraceIdBase16 } };
|
||||
Assert.Equal(SpanContext.BlankRemote, b3Format.Extract(invalidHeaders, Getter));
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
[Fact]
|
||||
public void ParseMissingTraceId_SingleHeader()
|
||||
{
|
||||
var invalidHeaders = new Dictionary<string, string> {{B3Format.XB3Combined, $"-{SpanIdBase16}"}};
|
||||
var invalidHeaders = new Dictionary<string, string> { { B3Format.XB3Combined, $"-{SpanIdBase16}" } };
|
||||
Assert.Equal(SpanContext.BlankRemote, b3FormatSingleHeader.Extract(invalidHeaders, Getter));
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ namespace OpenTelemetry.Context.Propagation.Test
|
|||
[Fact]
|
||||
public void ParseMissingSpanId_SingleHeader()
|
||||
{
|
||||
var invalidHeaders = new Dictionary<string, string> {{B3Format.XB3Combined, $"{TraceIdBase16}-"}};
|
||||
var invalidHeaders = new Dictionary<string, string> { { B3Format.XB3Combined, $"{TraceIdBase16}-" } };
|
||||
Assert.Equal(SpanContext.BlankRemote, b3FormatSingleHeader.Extract(invalidHeaders, Getter));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace OpenTelemetry.Impl.Trace.Propagation
|
|||
{
|
||||
if (headers.TryGetValue(name, out var value))
|
||||
{
|
||||
return new [] { value };
|
||||
return new[] { value };
|
||||
}
|
||||
|
||||
return Empty;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
public void ProxyTracer_CreateSpan_BadArgs_DoesNotThrow()
|
||||
{
|
||||
var proxyTracer = new ProxyTracer();
|
||||
|
||||
|
||||
proxyTracer.StartRootSpan(null);
|
||||
proxyTracer.StartRootSpan(null, SpanKind.Client);
|
||||
proxyTracer.StartRootSpan(null, SpanKind.Client, default);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
var startTime = DateTimeOffset.UtcNow.AddSeconds(-2);
|
||||
var endTime = DateTimeOffset.UtcNow.AddSeconds(-1);
|
||||
var span = tracer.StartSpan("name", parentContext, SpanKind.Producer,
|
||||
new SpanCreationOptions {Attributes = attributes, Links = new[] { link }, StartTimestamp = startTime,});
|
||||
new SpanCreationOptions { Attributes = attributes, Links = new[] { link }, StartTimestamp = startTime, });
|
||||
|
||||
span.AddEvent(evnt);
|
||||
span.Status = Status.FailedPrecondition;
|
||||
|
|
@ -135,8 +135,8 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
ActivityTraceFlags.Recorded, true, tracestate);
|
||||
|
||||
var attributes = new Dictionary<string, object> { ["key"] = "value", };
|
||||
var links = new [] { new Link(context) };
|
||||
var events = new [] { new Event("event") };
|
||||
var links = new[] { new Link(context) };
|
||||
var events = new[] { new Event("event") };
|
||||
|
||||
var startTime = DateTimeOffset.UtcNow.AddSeconds(-2);
|
||||
var endTime = DateTimeOffset.UtcNow.AddSeconds(-1);
|
||||
|
|
@ -220,7 +220,7 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
|
||||
var spanData1 = new SpanData("name", context, parentSpanId, SpanKind.Client, startTime, attributes, events, links, resource, Status.DataLoss, endTime);
|
||||
var spanData2 = new SpanData("name1", context, parentSpanId, SpanKind.Client, startTime, attributes, events, links, resource, Status.DataLoss, endTime);
|
||||
var spanData3 = new SpanData("name", otherContext, parentSpanId, SpanKind.Client, startTime, attributes, events, links, resource, Status.DataLoss, endTime);
|
||||
var spanData3 = new SpanData("name", otherContext, parentSpanId, SpanKind.Client, startTime, attributes, events, links, resource, Status.DataLoss, endTime);
|
||||
var spanData4 = new SpanData("name", context, default, SpanKind.Client, startTime, attributes, events, links, resource, Status.DataLoss, endTime);
|
||||
var spanData5 = new SpanData("name", context, parentSpanId, SpanKind.Server, startTime, attributes, events, links, resource, Status.DataLoss, endTime);
|
||||
var spanData6 = new SpanData("name", context, parentSpanId, SpanKind.Client, otherStartTime, attributes, events, links, resource, Status.DataLoss, endTime);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
{
|
||||
var tracer = (TracerSdk)tracerFactory.GetTracer("foo", "semver:1.0.0");
|
||||
|
||||
var traceState = new List<KeyValuePair<string, string>> {new KeyValuePair<string, string>("k1", "v1")};
|
||||
var traceState = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("k1", "v1") };
|
||||
var grandParentContext = new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded, false, traceState);
|
||||
var parentSpan = (SpanSdk)tracer.StartSpan(SpanName, grandParentContext);
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var parentContext = new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded);
|
||||
|
||||
var startTimestamp = DateTimeOffset.Now.AddSeconds(-1);
|
||||
var span = (SpanSdk)tracer.StartSpan(SpanName, parentContext, SpanKind.Server, new SpanCreationOptions { StartTimestamp = startTimestamp } );
|
||||
var span = (SpanSdk)tracer.StartSpan(SpanName, parentContext, SpanKind.Server, new SpanCreationOptions { StartTimestamp = startTimestamp });
|
||||
|
||||
Assert.True(span.IsRecording);
|
||||
Assert.Equal(SpanKind.Server, span.Kind);
|
||||
|
|
@ -361,7 +361,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var linkContext = new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded);
|
||||
|
||||
var startTimestamp = PreciseTimestamp.GetUtcNow();
|
||||
var span = (SpanSdk)tracer.StartSpan(SpanName, parentContext, SpanKind.Server, new SpanCreationOptions { LinksFactory = () => new[] { new Link(linkContext) }} );
|
||||
var span = (SpanSdk)tracer.StartSpan(SpanName, parentContext, SpanKind.Server, new SpanCreationOptions { LinksFactory = () => new[] { new Link(linkContext) } });
|
||||
|
||||
Assert.True(span.IsRecording);
|
||||
Assert.Equal(SpanKind.Server, span.Kind);
|
||||
|
|
@ -490,7 +490,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var firstLinkContext = new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded);
|
||||
var secondLinkContext = new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None);
|
||||
|
||||
var span = (SpanSdk)tracer.StartSpanFromActivity(SpanName, activity, SpanKind.Server, new[] { new Link(firstLinkContext), new Link(secondLinkContext), });
|
||||
var span = (SpanSdk)tracer.StartSpanFromActivity(SpanName, activity, SpanKind.Server, new[] { new Link(firstLinkContext), new Link(secondLinkContext), });
|
||||
|
||||
Assert.True(span.IsRecording);
|
||||
Assert.Equal(SpanKind.Server, span.Kind);
|
||||
|
|
@ -874,7 +874,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var link = new Link(contextLink);
|
||||
var tracer = tracerFactory.GetTracer(null);
|
||||
var startTime = DateTimeOffset.UtcNow.AddSeconds(-1);
|
||||
var span = (SpanSdk)tracer.StartRootSpan(SpanName, SpanKind.Client, new SpanCreationOptions { StartTimestamp = startTime, LinksFactory = () => new[] { link }});
|
||||
var span = (SpanSdk)tracer.StartRootSpan(SpanName, SpanKind.Client, new SpanCreationOptions { StartTimestamp = startTime, LinksFactory = () => new[] { link } });
|
||||
span.SetAttribute(
|
||||
"MySingleStringAttributeKey",
|
||||
"MySingleStringAttributeValue");
|
||||
|
|
@ -1019,17 +1019,17 @@ namespace OpenTelemetry.Trace.Test
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(new[] {true, false, true})]
|
||||
[InlineData(new[] {1L, 2L, 3L})]
|
||||
[InlineData(new[] {1UL, 2UL, 3UL})]
|
||||
[InlineData(new[] {1U, 2U, 3U})]
|
||||
[InlineData(new[] {1, 2, 3})]
|
||||
[InlineData(new sbyte[] {1, 2, 3})]
|
||||
[InlineData(new byte[] {1, 2, 3})]
|
||||
[InlineData(new short[] {1, 2, 3})]
|
||||
[InlineData(new ushort[] {1, 2, 3})]
|
||||
[InlineData(new[] {1.1d,2.2d,3.3d})]
|
||||
[InlineData(new[] {1.1f,2.2f,3.3f})]
|
||||
[InlineData(new[] { true, false, true })]
|
||||
[InlineData(new[] { 1L, 2L, 3L })]
|
||||
[InlineData(new[] { 1UL, 2UL, 3UL })]
|
||||
[InlineData(new[] { 1U, 2U, 3U })]
|
||||
[InlineData(new[] { 1, 2, 3 })]
|
||||
[InlineData(new sbyte[] { 1, 2, 3 })]
|
||||
[InlineData(new byte[] { 1, 2, 3 })]
|
||||
[InlineData(new short[] { 1, 2, 3 })]
|
||||
[InlineData(new ushort[] { 1, 2, 3 })]
|
||||
[InlineData(new[] { 1.1d, 2.2d, 3.3d })]
|
||||
[InlineData(new[] { 1.1f, 2.2f, 3.3f })]
|
||||
public void SetAttribute_Array(object array)
|
||||
{
|
||||
var tracer = tracerFactory.GetTracer(null);
|
||||
|
|
@ -1049,7 +1049,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var tracer = tracerFactory.GetTracer(null);
|
||||
var span = (SpanSdk)tracer.StartRootSpan(SpanName);
|
||||
|
||||
var array = new[] {"1","2","3"};
|
||||
var array = new[] { "1", "2", "3" };
|
||||
span.SetAttribute("array", array);
|
||||
|
||||
Assert.Single(span.Attributes);
|
||||
|
|
@ -1065,7 +1065,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var tracer = tracerFactory.GetTracer(null);
|
||||
var span = (SpanSdk)tracer.StartRootSpan(SpanName);
|
||||
|
||||
var array = new[] {1.1M, 2.2M, 3.3M};
|
||||
var array = new[] { 1.1M, 2.2M, 3.3M };
|
||||
span.SetAttribute("array", array);
|
||||
|
||||
Assert.Single(span.Attributes);
|
||||
|
|
@ -1080,7 +1080,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var tracer = tracerFactory.GetTracer(null);
|
||||
var span = (SpanSdk)tracer.StartRootSpan(SpanName);
|
||||
|
||||
IEnumerable<int> array = new List<int> {1,2,3};
|
||||
IEnumerable<int> array = new List<int> { 1, 2, 3 };
|
||||
span.SetAttribute("array", array);
|
||||
|
||||
Assert.Single(span.Attributes);
|
||||
|
|
@ -1095,7 +1095,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
var tracer = tracerFactory.GetTracer(null);
|
||||
var span = (SpanSdk)tracer.StartRootSpan(SpanName);
|
||||
|
||||
var array = new object[] {1, "2", false};
|
||||
var array = new object[] { 1, "2", false };
|
||||
span.SetAttribute("array", array);
|
||||
|
||||
Assert.Single(span.Attributes);
|
||||
|
|
@ -1259,7 +1259,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
Assert.Same(ispan, span);
|
||||
Assert.NotNull(span);
|
||||
Assert.True(span.Context.IsValid);
|
||||
Assert.Equal(parentSpan.Context.SpanId,((SpanSdk)span).ParentSpanId);
|
||||
Assert.Equal(parentSpan.Context.SpanId, ((SpanSdk)span).ParentSpanId);
|
||||
}
|
||||
|
||||
Assert.False(tracer.CurrentSpan.Context.IsValid);
|
||||
|
|
@ -1579,7 +1579,7 @@ namespace OpenTelemetry.Trace.Test
|
|||
|
||||
var linkContext = new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded);
|
||||
var activity = new Activity(SpanName).SetIdFormat(ActivityIdFormat.W3C).Start();
|
||||
using (var scope = tracer.StartActiveSpanFromActivity(SpanName, activity, SpanKind.Consumer, new [] { new Link(linkContext), }, out var ispan))
|
||||
using (var scope = tracer.StartActiveSpanFromActivity(SpanName, activity, SpanKind.Consumer, new[] { new Link(linkContext), }, out var ispan))
|
||||
{
|
||||
Assert.NotNull(scope);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace TestApp.AspNetCore._3._1
|
|||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
if (_impl== null || await _impl.ProcessAsync(context))
|
||||
if (_impl == null || await _impl.ProcessAsync(context))
|
||||
{
|
||||
await _next(context);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue