Removing Todos (#1029)

* Removing Todos

renaming parameter

adding tests

updating spanbuilderShim

updating to internal

renaming to spanAttributes

solving build issue

adding spec reference

Continue Refactoring TracerProvider. (#1035)

* optimize the flow

* fix instrumenataion

* move mroe things to provider ctor

* move logic arounds

Co-authored-by: Reiley Yang <reyang@microsoft.com>

changing to class and following spec to replace value

replacing from default to null

updating package

adding xunit.runner

renaming method

* removing duplicated files

* adding some tests and updating to default constructor

* removing to be compliant to spec

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
Eddy Nakamura 2020-08-11 11:50:53 -03:00 committed by GitHub
parent f44952a610
commit a3bf19d450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 251 additions and 139 deletions

View File

@ -30,6 +30,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E
build\OpenTelemetry.prod.ruleset = build\OpenTelemetry.prod.ruleset
build\OpenTelemetry.test.ruleset = build\OpenTelemetry.test.ruleset
build\stylecop.json = build\stylecop.json
build\xunit.runner.json = build\xunit.runner.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Zipkin", "src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj", "{7EDAE7FA-B44E-42CA-80FA-7DF2FAA2C5DD}"
@ -360,6 +361,14 @@ Global
{0246BFC4-8AAF-45E1-A127-DB43D6E345BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0246BFC4-8AAF-45E1-A127-DB43D6E345BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0246BFC4-8AAF-45E1-A127-DB43D6E345BB}.Release|Any CPU.Build.0 = Release|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Release|Any CPU.Build.0 = Release|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Release|Any CPU.Build.0 = Release|Any CPU
{07336602-860B-4975-95DD-405D19C00901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07336602-860B-4975-95DD-405D19C00901}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07336602-860B-4975-95DD-405D19C00901}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -372,14 +381,6 @@ Global
{5435517C-AEC5-4182-87AE-14E13D31525F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5435517C-AEC5-4182-87AE-14E13D31525F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5435517C-AEC5-4182-87AE-14E13D31525F}.Release|Any CPU.Build.0 = Release|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1891B31-B021-4074-8E42-B4AC170CD208}.Release|Any CPU.Build.0 = Release|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Release|Any CPU.Build.0 = Release|Any CPU
{9574368D-1230-4334-AA5D-EC2C2F47AA43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9574368D-1230-4334-AA5D-EC2C2F47AA43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9574368D-1230-4334-AA5D-EC2C2F47AA43}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -403,16 +404,16 @@ Global
{FF3E6E08-E8E4-4523-B526-847CD989279F} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
{0935622B-9377-4056-8343-AE6ECDC274CF} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
{DE9130A4-F30A-49D7-8834-41DE3021218B} = {0169B149-FB8B-46F4-9EF7-8A0E69F8FAAF}
{4D492D62-5150-45F9-817F-C99562E364E2} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
{07336602-860B-4975-95DD-405D19C00901} = {4D492D62-5150-45F9-817F-C99562E364E2}
{FA7A6F67-1F2F-4855-890D-51B5829578A9} = {4D492D62-5150-45F9-817F-C99562E364E2}
{5435517C-AEC5-4182-87AE-14E13D31525F} = {4D492D62-5150-45F9-817F-C99562E364E2}
{2C7DD1DA-C229-4D9E-9AF0-BCD5CD3E4948} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
{5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818} = {7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}
{B1891B31-B021-4074-8E42-B4AC170CD208} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
{3277B1C0-BDFE-4460-9B0D-D9A661FB48DB} = {7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}
{3862190B-E2C5-418E-AFDC-DB281FB5C705} = {7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}
{4D492D62-5150-45F9-817F-C99562E364E2} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
{07336602-860B-4975-95DD-405D19C00901} = {4D492D62-5150-45F9-817F-C99562E364E2}
{FA7A6F67-1F2F-4855-890D-51B5829578A9} = {4D492D62-5150-45F9-817F-C99562E364E2}
{5435517C-AEC5-4182-87AE-14E13D31525F} = {4D492D62-5150-45F9-817F-C99562E364E2}
{CB401DF1-FF5C-4055-886E-1183E832B2D6} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
{9574368D-1230-4334-AA5D-EC2C2F47AA43} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
{D6318071-BE9F-43AF-9F28-A38894238627} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}

View File

@ -11,6 +11,12 @@
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup Condition="$(MSBuildProjectName.Contains('.Tests'))">
<Content Include="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))\build\xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup Label="Package versions used in by test projects">
<!--
Please sort alphabetically.
@ -20,7 +26,7 @@
<DotNetXUnitCliVer>[2.3.1,3.0)</DotNetXUnitCliVer>
<MicrosoftNETTestSdkPkgVer>[16.6.1,17.0)</MicrosoftNETTestSdkPkgVer>
<MoqPkgVer>[4.14.5,5.0)</MoqPkgVer>
<XUnitRunnerVisualStudioPkgVer>[2.4.2,3.0)</XUnitRunnerVisualStudioPkgVer>
<XUnitRunnerVisualStudioPkgVer>[2.4.3,3.0)</XUnitRunnerVisualStudioPkgVer>
<XUnitPkgVer>[2.4.1,3.0)</XUnitPkgVer>
</PropertyGroup>

View File

@ -0,0 +1,128 @@
// <copyright file="SpanAttributes.cs" company="OpenTelemetry Authors">
// Copyright The 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.Diagnostics;
namespace OpenTelemetry.Trace
{
/// <summary>
/// A class that represents the span attributes. Read more here https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/common/common.md#attributes.
/// </summary>
public class SpanAttributes
{
/// <summary>
/// Initializes a new instance of the <see cref="SpanAttributes"/> class.
/// </summary>
public SpanAttributes()
{
this.Attributes = new ActivityTagsCollection();
}
internal ActivityTagsCollection Attributes { get; }
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="value">Entry value.</param>
public void Add(string key, long value)
{
this.PrivateAdd(key, value);
}
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="value">Entry value.</param>
public void Add(string key, string value)
{
this.PrivateAdd(key, value);
}
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="value">Entry value.</param>
public void Add(string key, bool value)
{
this.PrivateAdd(key, value);
}
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="value">Entry value.</param>
public void Add(string key, double value)
{
this.PrivateAdd(key, value);
}
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, long[] values)
{
this.PrivateAdd(key, values);
}
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, string[] values)
{
this.PrivateAdd(key, values);
}
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, bool[] values)
{
this.PrivateAdd(key, values);
}
/// <summary>
/// Add entry to the attributes.
/// </summary>
/// <param name="key">Entry key.</param>
/// <param name="values">Entry value.</param>
public void Add(string key, double[] values)
{
this.PrivateAdd(key, values);
}
private void PrivateAdd(string key, object value)
{
if (key == null)
{
throw new ArgumentNullException(key);
}
this.Attributes[key] = value;
}
}
}

View File

@ -58,14 +58,14 @@ namespace OpenTelemetry.Trace
/// </summary>
/// <param name="name">Span name.</param>
/// <param name="kind">Kind.</param>
/// <param name="attributes">Initial attributes for the span.</param>
/// <param name="initialAttributes">Initial attributes for the span.</param>
/// <param name="links"> <see cref="Link"/> for the span.</param>
/// <param name="startTime"> Start time for the span.</param>
/// <returns>Span instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TelemetrySpan StartRootSpan(string name, SpanKind kind = SpanKind.Internal, IEnumerable<KeyValuePair<string, object>> attributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
public TelemetrySpan StartRootSpan(string name, SpanKind kind = SpanKind.Internal, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
{
return this.StartSpanHelper(false, name, kind, default, attributes, links, startTime);
return this.StartSpanHelper(false, name, kind, default, initialAttributes, links, startTime);
}
/// <summary>
@ -74,14 +74,14 @@ namespace OpenTelemetry.Trace
/// <param name="name">Span name.</param>
/// <param name="kind">Kind.</param>
/// <param name="parentSpan">Parent for new span.</param>
/// <param name="attributes">Initial attributes for the span.</param>
/// <param name="initialAttributes">Initial attributes for the span.</param>
/// <param name="links"> <see cref="Link"/> for the span.</param>
/// <param name="startTime"> Start time for the span.</param>
/// <returns>Span instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TelemetrySpan StartSpan(string name, SpanKind kind, in TelemetrySpan parentSpan, IEnumerable<KeyValuePair<string, object>> attributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
public TelemetrySpan StartSpan(string name, SpanKind kind, in TelemetrySpan parentSpan, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
{
return this.StartSpan(name, kind, parentSpan?.Context ?? default, attributes, links, startTime);
return this.StartSpan(name, kind, parentSpan?.Context ?? default, initialAttributes, links, startTime);
}
/// <summary>
@ -90,14 +90,14 @@ namespace OpenTelemetry.Trace
/// <param name="name">Span name.</param>
/// <param name="kind">Kind.</param>
/// <param name="parentContext">Parent Context for new span.</param>
/// <param name="attributes">Initial attributes for the span.</param>
/// <param name="initialAttributes">Initial attributes for the span.</param>
/// <param name="links"> <see cref="Link"/> for the span.</param>
/// <param name="startTime"> Start time for the span.</param>
/// <returns>Span instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TelemetrySpan StartSpan(string name, SpanKind kind = SpanKind.Internal, in SpanContext parentContext = default, IEnumerable<KeyValuePair<string, object>> attributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
public TelemetrySpan StartSpan(string name, SpanKind kind = SpanKind.Internal, in SpanContext parentContext = default, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
{
return this.StartSpanHelper(false, name, kind, parentContext, attributes, links, startTime);
return this.StartSpanHelper(false, name, kind, parentContext, initialAttributes, links, startTime);
}
/// <summary>
@ -106,14 +106,14 @@ namespace OpenTelemetry.Trace
/// <param name="name">Span name.</param>
/// <param name="kind">Kind.</param>
/// <param name="parentSpan">Parent for new span.</param>
/// <param name="attributes">Initial attributes for the span.</param>
/// <param name="initialAttributes">Initial attributes for the span.</param>
/// <param name="links"> <see cref="Link"/> for the span.</param>
/// <param name="startTime"> Start time for the span.</param>
/// <returns>Span instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TelemetrySpan StartActiveSpan(string name, SpanKind kind, in TelemetrySpan parentSpan, IEnumerable<KeyValuePair<string, object>> attributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
public TelemetrySpan StartActiveSpan(string name, SpanKind kind, in TelemetrySpan parentSpan, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
{
return this.StartActiveSpan(name, kind, parentSpan?.Context ?? default, attributes, links, startTime);
return this.StartActiveSpan(name, kind, parentSpan?.Context ?? default, initialAttributes, links, startTime);
}
/// <summary>
@ -122,14 +122,14 @@ namespace OpenTelemetry.Trace
/// <param name="name">Span name.</param>
/// <param name="kind">Kind.</param>
/// <param name="parentContext">Parent Context for new span.</param>
/// <param name="attributes">Initial attributes for the span.</param>
/// <param name="initialAttributes">Initial attributes for the span.</param>
/// <param name="links"> <see cref="Link"/> for the span.</param>
/// <param name="startTime"> Start time for the span.</param>
/// <returns>Span instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TelemetrySpan StartActiveSpan(string name, SpanKind kind = SpanKind.Internal, in SpanContext parentContext = default, IEnumerable<KeyValuePair<string, object>> attributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
public TelemetrySpan StartActiveSpan(string name, SpanKind kind = SpanKind.Internal, in SpanContext parentContext = default, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
{
return this.StartSpanHelper(true, name, kind, parentContext, attributes, links, startTime);
return this.StartSpanHelper(true, name, kind, parentContext, initialAttributes, links, startTime);
}
/// <summary>
@ -145,7 +145,7 @@ namespace OpenTelemetry.Trace
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private TelemetrySpan StartSpanHelper(bool isActiveSpan, string name, SpanKind kind, in SpanContext parentContext = default, IEnumerable<KeyValuePair<string, object>> attributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
private TelemetrySpan StartSpanHelper(bool isActiveSpan, string name, SpanKind kind, in SpanContext parentContext = default, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)
{
if (!this.ActivitySource.HasListeners())
{
@ -161,11 +161,7 @@ namespace OpenTelemetry.Trace
previousActivity = Activity.Current;
}
// TODO:
// Instead of converting to ActivityTagsCollection here,
// change the method signature to accept ActivityTagsCollection.
var tags = (attributes == null) ? null : new ActivityTagsCollection(attributes);
var activity = this.ActivitySource.StartActivity(name, activityKind, parentContext.ActivityContext, tags, activityLinks, startTime);
var activity = this.ActivitySource.StartActivity(name, activityKind, parentContext.ActivityContext, initialAttributes?.Attributes ?? null, activityLinks, startTime);
if (activity == null)
{
return TelemetrySpan.NoopInstance;

View File

@ -161,15 +161,15 @@ namespace OpenTelemetry.Shims.OpenTracing
// If specified, this takes precedence.
if (this.ignoreActiveSpan)
{
span = this.tracer.StartRootSpan(this.spanName, this.spanKind, null, this.links, this.explicitStartTime ?? default);
span = this.tracer.StartRootSpan(this.spanName, this.spanKind, default, this.links, this.explicitStartTime ?? default);
}
else if (this.parentSpan != null)
{
span = this.tracer.StartSpan(this.spanName, this.spanKind, this.parentSpan, null, this.links, this.explicitStartTime ?? default);
span = this.tracer.StartSpan(this.spanName, this.spanKind, this.parentSpan, default, this.links, this.explicitStartTime ?? default);
}
else if (this.parentSpanContext.IsValid)
{
span = this.tracer.StartSpan(this.spanName, this.spanKind, this.parentSpanContext, null, this.links, this.explicitStartTime ?? default);
span = this.tracer.StartSpan(this.spanName, this.spanKind, this.parentSpanContext, default, this.links, this.explicitStartTime ?? default);
}
else if (this.parentSpan == null && !this.parentSpanContext.IsValid && Activity.Current != null && Activity.Current.IdFormat == ActivityIdFormat.W3C)
{
@ -181,7 +181,7 @@ namespace OpenTelemetry.Shims.OpenTracing
if (span == null)
{
span = this.tracer.StartSpan(this.spanName, this.spanKind, default(SpanContext), null, null, this.explicitStartTime ?? default);
span = this.tracer.StartSpan(this.spanName, this.spanKind, default(SpanContext), default, null, this.explicitStartTime ?? default);
}
foreach (var kvp in this.attributes)

View File

@ -7,12 +7,6 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
<PackageReference Include="Moq" Version="$(MoqPkgVer)" />

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>

View File

@ -12,12 +12,6 @@
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\TestEventListener.cs" Link="TestEventListener.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Net.Http" Condition="'$(TargetFramework)' == 'net452'" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />

View File

@ -1,4 +0,0 @@
{
"maxParallelThreads": 1,
"parallelizeTestCollections": false
}

View File

@ -4,16 +4,6 @@
<TargetFrameworks>net452;net46</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Remove="xunit.runner.json" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
<PackageReference Include="Moq" Version="$(MoqPkgVer)" />

View File

@ -1,4 +0,0 @@
{
"maxParallelThreads": 1,
"parallelizeTestCollections": false
}

View File

@ -4,16 +4,6 @@
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Remove="xunit.runner.json" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPkgVer)" />
<PackageReference Include="Moq" Version="$(MoqPkgVer)" />

View File

@ -1,4 +0,0 @@
{
"maxParallelThreads": 1,
"parallelizeTestCollections": false
}

View File

@ -32,4 +32,5 @@
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\BaseEventSourceTest.cs" Link="BaseEventSourceTest.cs" />
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\TestEventListener.cs" Link="TestEventListener.cs" />
</ItemGroup>
</Project>

View File

@ -131,8 +131,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
foreach (var kv in normalizedAttributesTestCase)
{
// TODO: Fix this test. This is mostly broken because Status is stored in tags.
// Assert.Contains(span.Tags, i => i.Key == kv.Key && i.Value.Equals(kv.Value, StringComparison.InvariantCultureIgnoreCase));
Assert.Contains(span.TagObjects, i => i.Key == kv.Key && i.Value.ToString().Equals(kv.Value, StringComparison.InvariantCultureIgnoreCase));
}
Assert.Equal(expectedResource, span.GetResource());

View File

@ -5,16 +5,6 @@
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net452;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Remove="xunit.runner.json" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Implementation\Internal\SkipUnlessEnvVarFoundTheoryAttribute.cs" Link="SkipUnlessEnvVarFoundTheoryAttribute.cs" />
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Implementation\Internal\TestHttpServer.cs" Link="TestHttpServer.cs" />

View File

@ -1,4 +0,0 @@
{
"maxParallelThreads": 1,
"parallelizeTestCollections": false
}

View File

@ -5,16 +5,6 @@
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net452;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Remove="xunit.runner.json" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Implementation\Internal\SkipUnlessEnvVarFoundTheoryAttribute.cs" Link="SkipUnlessEnvVarFoundTheoryAttribute.cs" />
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\BaseEventSourceTest.cs" Link="BaseEventSourceTest.cs" />

View File

@ -1,4 +0,0 @@
{
"maxParallelThreads": 1,
"parallelizeTestCollections": false
}

View File

@ -49,7 +49,8 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
[Fact]
public void GetBaggage()
{
// TODO
var shim = GetSpanContextShim();
Assert.Throws<NotImplementedException>(() => shim.GetBaggageItems());
}
internal static SpanContextShim GetSpanContextShim()

View File

@ -234,9 +234,8 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
// A boolean tag named "error" is a special case that must be checked
Assert.Equal(Status.Unknown, shim.Span.Activity.GetStatus());
// TODO: Activity object does not allow Tags update. Below lines of code needs to be enabled after .NET introducing SetTag on Activity.
// shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
// Assert.Equal(Status.Ok, shim.Span.Activity.GetStatus());
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
Assert.Equal(Status.Ok, shim.Span.Activity.GetStatus());
}
[Fact]
@ -286,9 +285,8 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
// A boolean tag named "error" is a special case that must be checked
Assert.Equal(Status.Unknown, shim.Span.Activity.GetStatus());
// TODO: .NET does not allow Tags update. Below lines of code needs to be enabled after .NET introducing SetTag on Activity.
// shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
// Assert.Equal(Status.Ok, shim.Span.Activity.GetStatus());
shim.SetTag(global::OpenTracing.Tag.Tags.Error.Key, false);
Assert.Equal(Status.Ok, shim.Span.Activity.GetStatus());
}
[Fact]

View File

@ -108,9 +108,6 @@ namespace OpenTelemetry.Impl.Trace.Propagation
var ctx = f.Extract(default, headers, Getter);
Assert.False(ctx.IsValid());
// TODO: when ActivityContext supports IsRemote
// Assert.True(ctx.IsRemote);
}
[Fact]

View File

@ -0,0 +1,67 @@
// <copyright file="SpanAttributesTest.cs" company="OpenTelemetry Authors">
// Copyright The 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 Xunit;
namespace OpenTelemetry.Trace.Test
{
public class SpanAttributesTest
{
[Fact]
public void ValidateConstructor()
{
var spanAttribute = new SpanAttributes();
Assert.Empty(spanAttribute.Attributes);
}
[Fact]
public void ValidateAddMethods()
{
var spanAttribute = new SpanAttributes();
spanAttribute.Add("key_string", "string");
spanAttribute.Add("key_a_string", new string[] { "string" });
spanAttribute.Add("key_double", 1.01);
spanAttribute.Add("key_a_double", new double[] { 1.01 });
spanAttribute.Add("key_bool", true);
spanAttribute.Add("key_a_bool", new bool[] { true });
spanAttribute.Add("key_long", 1);
spanAttribute.Add("key_a_long", new long[] { 1 });
Assert.Equal(8, spanAttribute.Attributes.Count);
}
[Fact]
public void ValidateNullKey()
{
var spanAttribute = new SpanAttributes();
Assert.Throws<ArgumentNullException>(() => spanAttribute.Add(null, "null key"));
}
[Fact]
public void ValidateSameKey()
{
var spanAttribute = new SpanAttributes();
spanAttribute.Add("key", "value1");
spanAttribute.Add("key", "value2");
Assert.Equal("value2", spanAttribute.Attributes["key"]);
}
}
}

View File

@ -69,7 +69,7 @@ namespace OpenTelemetry.Trace.Test
var span2 = this.tracer.StartRootSpan(null, SpanKind.Client);
Assert.Null(span2.Activity.DisplayName);
var span3 = this.tracer.StartRootSpan(null, SpanKind.Client, null);
var span3 = this.tracer.StartRootSpan(null, SpanKind.Client, default);
Assert.Null(span3.Activity.DisplayName);
}
@ -117,7 +117,7 @@ namespace OpenTelemetry.Trace.Test
var span1 = this.tracer.StartSpan(null, SpanKind.Client, TelemetrySpan.NoopInstance);
Assert.Null(span1.Activity.DisplayName);
var span2 = this.tracer.StartSpan(null, SpanKind.Client, TelemetrySpan.NoopInstance, null);
var span2 = this.tracer.StartSpan(null, SpanKind.Client, TelemetrySpan.NoopInstance, default);
Assert.Null(span2.Activity.DisplayName);
}
@ -133,7 +133,7 @@ namespace OpenTelemetry.Trace.Test
var span1 = this.tracer.StartSpan(null, SpanKind.Client, blankContext);
Assert.Null(span1.Activity.DisplayName);
var span2 = this.tracer.StartSpan(null, SpanKind.Client, blankContext, null);
var span2 = this.tracer.StartSpan(null, SpanKind.Client, blankContext, default);
Assert.Null(span2.Activity.DisplayName);
}
@ -147,7 +147,7 @@ namespace OpenTelemetry.Trace.Test
var span1 = this.tracer.StartActiveSpan(null, SpanKind.Client, TelemetrySpan.NoopInstance);
Assert.Null(span1.Activity.DisplayName);
var span2 = this.tracer.StartActiveSpan(null, SpanKind.Client, TelemetrySpan.NoopInstance, null);
var span2 = this.tracer.StartActiveSpan(null, SpanKind.Client, TelemetrySpan.NoopInstance, default);
Assert.Null(span2.Activity.DisplayName);
}
@ -163,7 +163,7 @@ namespace OpenTelemetry.Trace.Test
var span1 = this.tracer.StartActiveSpan(null, SpanKind.Client, blankContext);
Assert.Null(span1.Activity.DisplayName);
var span2 = this.tracer.StartActiveSpan(null, SpanKind.Client, blankContext, null);
var span2 = this.tracer.StartActiveSpan(null, SpanKind.Client, blankContext, default);
Assert.Null(span2.Activity.DisplayName);
}

View File

@ -5,12 +5,6 @@
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46;net452</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>

View File

@ -1,4 +0,0 @@
{
"maxParallelThreads": 1,
"parallelizeTestCollections": false
}