diff --git a/.github/workflows/dotnet-core-linux.yml b/.github/workflows/dotnet-core-linux.yml
index ca9d4a22270..ba128f31aeb 100644
--- a/.github/workflows/dotnet-core-linux.yml
+++ b/.github/workflows/dotnet-core-linux.yml
@@ -20,12 +20,12 @@ jobs:
- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 2.1.807
+ dotnet-version: 2.1.x
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 3.1.301
+ dotnet-version: 3.1.x
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
diff --git a/build/Common.prod.props b/build/Common.prod.props
index cff03f9845c..d089a05ee77 100644
--- a/build/Common.prod.props
+++ b/build/Common.prod.props
@@ -63,6 +63,8 @@
+
+
diff --git a/src/OpenTelemetry.Api/.publicApi/net452/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/net452/PublicAPI.Unshipped.txt
index 3e01f92b9c9..89cf41e71eb 100644
--- a/src/OpenTelemetry.Api/.publicApi/net452/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Api/.publicApi/net452/PublicAPI.Unshipped.txt
@@ -14,6 +14,10 @@ OpenTelemetry.Baggage.RemoveBaggage(string name) -> OpenTelemetry.Baggage
OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems) -> OpenTelemetry.Baggage
OpenTelemetry.Baggage.SetBaggage(params System.Collections.Generic.KeyValuePair[] baggageItems) -> OpenTelemetry.Baggage
OpenTelemetry.Baggage.SetBaggage(string name, string value) -> OpenTelemetry.Baggage
+OpenTelemetry.BaseProvider
+OpenTelemetry.BaseProvider.BaseProvider() -> void
+OpenTelemetry.BaseProvider.Dispose() -> void
+OpenTelemetry.BaseProvider.~BaseProvider() -> void
OpenTelemetry.Context.Propagation.B3Propagator
OpenTelemetry.Context.Propagation.B3Propagator.B3Propagator() -> void
OpenTelemetry.Context.Propagation.B3Propagator.B3Propagator(bool singleHeader) -> void
@@ -70,7 +74,6 @@ OpenTelemetry.Metrics.Meter.Meter() -> void
OpenTelemetry.Metrics.MeterFactoryBase
OpenTelemetry.Metrics.MeterFactoryBase.MeterFactoryBase() -> void
OpenTelemetry.Metrics.MeterProvider
-OpenTelemetry.Metrics.MeterProvider.Dispose() -> void
OpenTelemetry.Metrics.MeterProvider.MeterProvider() -> void
OpenTelemetry.Metrics.NoopBoundCounterMetric
OpenTelemetry.Metrics.NoopBoundCounterMetric.NoopBoundCounterMetric() -> void
@@ -166,7 +169,6 @@ OpenTelemetry.Trace.Tracer.StartRootSpan(string name, OpenTelemetry.Trace.SpanKi
OpenTelemetry.Trace.Tracer.StartSpan(string name, OpenTelemetry.Trace.SpanKind kind = OpenTelemetry.Trace.SpanKind.Internal, in OpenTelemetry.Trace.SpanContext parentContext = default(OpenTelemetry.Trace.SpanContext), OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan
OpenTelemetry.Trace.Tracer.StartSpan(string name, OpenTelemetry.Trace.SpanKind kind, in OpenTelemetry.Trace.TelemetrySpan parentSpan, OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan
OpenTelemetry.Trace.TracerProvider
-OpenTelemetry.Trace.TracerProvider.Dispose() -> void
OpenTelemetry.Trace.TracerProvider.GetTracer(string name, string version = null) -> OpenTelemetry.Trace.Tracer
OpenTelemetry.Trace.TracerProvider.TracerProvider() -> void
abstract OpenTelemetry.Context.RuntimeContextSlot.Get() -> T
@@ -300,10 +302,9 @@ static readonly OpenTelemetry.Metrics.NoopMeasureMetric.Instance -> OpenTelem
static readonly OpenTelemetry.Trace.Status.Error -> OpenTelemetry.Trace.Status
static readonly OpenTelemetry.Trace.Status.Ok -> OpenTelemetry.Trace.Status
static readonly OpenTelemetry.Trace.Status.Unset -> OpenTelemetry.Trace.Status
+virtual OpenTelemetry.BaseProvider.Dispose(bool disposing) -> void
virtual OpenTelemetry.Context.RuntimeContextSlot.Dispose(bool disposing) -> void
virtual OpenTelemetry.Metrics.LabelSet.Labels.get -> System.Collections.Generic.IEnumerable>
virtual OpenTelemetry.Metrics.LabelSet.Labels.set -> void
virtual OpenTelemetry.Metrics.MeterFactoryBase.GetMeter(string name, string version = null) -> OpenTelemetry.Metrics.Meter
-virtual OpenTelemetry.Metrics.MeterProvider.Dispose(bool disposing) -> void
virtual OpenTelemetry.Metrics.MeterProvider.GetMeter(string name, string version = null) -> OpenTelemetry.Metrics.Meter
-virtual OpenTelemetry.Trace.TracerProvider.Dispose(bool disposing) -> void
diff --git a/src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
index 6247afb3bdb..ac7d5c0cc7c 100644
--- a/src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
@@ -14,6 +14,10 @@ OpenTelemetry.Baggage.RemoveBaggage(string name) -> OpenTelemetry.Baggage
OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems) -> OpenTelemetry.Baggage
OpenTelemetry.Baggage.SetBaggage(params System.Collections.Generic.KeyValuePair[] baggageItems) -> OpenTelemetry.Baggage
OpenTelemetry.Baggage.SetBaggage(string name, string value) -> OpenTelemetry.Baggage
+OpenTelemetry.BaseProvider
+OpenTelemetry.BaseProvider.BaseProvider() -> void
+OpenTelemetry.BaseProvider.Dispose() -> void
+OpenTelemetry.BaseProvider.~BaseProvider() -> void
OpenTelemetry.Context.AsyncLocalRuntimeContextSlot
OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.AsyncLocalRuntimeContextSlot(string name) -> void
OpenTelemetry.Context.Propagation.B3Propagator
@@ -70,7 +74,6 @@ OpenTelemetry.Metrics.Meter.Meter() -> void
OpenTelemetry.Metrics.MeterFactoryBase
OpenTelemetry.Metrics.MeterFactoryBase.MeterFactoryBase() -> void
OpenTelemetry.Metrics.MeterProvider
-OpenTelemetry.Metrics.MeterProvider.Dispose() -> void
OpenTelemetry.Metrics.MeterProvider.MeterProvider() -> void
OpenTelemetry.Metrics.NoopBoundCounterMetric
OpenTelemetry.Metrics.NoopBoundCounterMetric.NoopBoundCounterMetric() -> void
@@ -166,7 +169,6 @@ OpenTelemetry.Trace.Tracer.StartRootSpan(string name, OpenTelemetry.Trace.SpanKi
OpenTelemetry.Trace.Tracer.StartSpan(string name, OpenTelemetry.Trace.SpanKind kind = OpenTelemetry.Trace.SpanKind.Internal, in OpenTelemetry.Trace.SpanContext parentContext = default(OpenTelemetry.Trace.SpanContext), OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan
OpenTelemetry.Trace.Tracer.StartSpan(string name, OpenTelemetry.Trace.SpanKind kind, in OpenTelemetry.Trace.TelemetrySpan parentSpan, OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan
OpenTelemetry.Trace.TracerProvider
-OpenTelemetry.Trace.TracerProvider.Dispose() -> void
OpenTelemetry.Trace.TracerProvider.GetTracer(string name, string version = null) -> OpenTelemetry.Trace.Tracer
OpenTelemetry.Trace.TracerProvider.TracerProvider() -> void
abstract OpenTelemetry.Context.RuntimeContextSlot.Get() -> T
@@ -300,10 +302,9 @@ static readonly OpenTelemetry.Metrics.NoopMeasureMetric.Instance -> OpenTelem
static readonly OpenTelemetry.Trace.Status.Error -> OpenTelemetry.Trace.Status
static readonly OpenTelemetry.Trace.Status.Ok -> OpenTelemetry.Trace.Status
static readonly OpenTelemetry.Trace.Status.Unset -> OpenTelemetry.Trace.Status
+virtual OpenTelemetry.BaseProvider.Dispose(bool disposing) -> void
virtual OpenTelemetry.Context.RuntimeContextSlot.Dispose(bool disposing) -> void
virtual OpenTelemetry.Metrics.LabelSet.Labels.get -> System.Collections.Generic.IEnumerable>
virtual OpenTelemetry.Metrics.LabelSet.Labels.set -> void
virtual OpenTelemetry.Metrics.MeterFactoryBase.GetMeter(string name, string version = null) -> OpenTelemetry.Metrics.Meter
-virtual OpenTelemetry.Metrics.MeterProvider.Dispose(bool disposing) -> void
virtual OpenTelemetry.Metrics.MeterProvider.GetMeter(string name, string version = null) -> OpenTelemetry.Metrics.Meter
-virtual OpenTelemetry.Trace.TracerProvider.Dispose(bool disposing) -> void
diff --git a/src/OpenTelemetry.Api/BaseProvider.cs b/src/OpenTelemetry.Api/BaseProvider.cs
new file mode 100644
index 00000000000..4aabc8cd119
--- /dev/null
+++ b/src/OpenTelemetry.Api/BaseProvider.cs
@@ -0,0 +1,49 @@
+//
+// 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.
+//
+
+using System;
+
+namespace OpenTelemetry
+{
+ ///
+ /// Contains logic shared by all OpenTelemetry providers.
+ ///
+ public abstract class BaseProvider : IDisposable
+ {
+ ///
+ /// Finalizes an instance of the class.
+ ///
+ ~BaseProvider()
+ {
+ this.Dispose(false);
+ }
+
+ ///
+ public void Dispose()
+ {
+ this.Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases the unmanaged resources used by this class and optionally releases the managed resources.
+ ///
+ /// to release both managed and unmanaged resources; to release only unmanaged resources.
+ protected virtual void Dispose(bool disposing)
+ {
+ }
+ }
+}
diff --git a/src/OpenTelemetry.Api/Metrics/MeterProvider.cs b/src/OpenTelemetry.Api/Metrics/MeterProvider.cs
index b9c2f1ae97b..6b574aef1a1 100644
--- a/src/OpenTelemetry.Api/Metrics/MeterProvider.cs
+++ b/src/OpenTelemetry.Api/Metrics/MeterProvider.cs
@@ -21,7 +21,7 @@ namespace OpenTelemetry.Metrics
///
/// MeterProvider is the entry point of the OpenTelemetry Metrics API. It provides access to Meters.
///
- public class MeterProvider : IDisposable
+ public class MeterProvider : BaseProvider
{
private static ProxyMeter proxyMeter = new ProxyMeter();
private static bool isInitialized;
@@ -71,13 +71,6 @@ public static void SetDefault(MeterProvider meterProvider)
isInitialized = true;
}
- ///
- public void Dispose()
- {
- this.Dispose(true);
- GC.SuppressFinalize(this);
- }
-
///
/// Returns a Meter for a given name and version.
///
@@ -96,13 +89,5 @@ internal static void Reset()
isInitialized = false;
defaultProvider = new MeterProvider();
}
-
- ///
- /// Releases the unmanaged resources used by this class and optionally releases the managed resources.
- ///
- /// to release both managed and unmanaged resources; to release only unmanaged resources.
- protected virtual void Dispose(bool disposing)
- {
- }
}
}
diff --git a/src/OpenTelemetry.Api/Trace/TracerProvider.cs b/src/OpenTelemetry.Api/Trace/TracerProvider.cs
index e66f65cf12a..58f0fba55df 100644
--- a/src/OpenTelemetry.Api/Trace/TracerProvider.cs
+++ b/src/OpenTelemetry.Api/Trace/TracerProvider.cs
@@ -14,7 +14,6 @@
// limitations under the License.
//
-using System;
using System.Diagnostics;
namespace OpenTelemetry.Trace
@@ -22,7 +21,7 @@ namespace OpenTelemetry.Trace
///
/// TracerProvider is the entry point of the OpenTelemetry API. It provides access to .
///
- public class TracerProvider : IDisposable
+ public class TracerProvider : BaseProvider
{
///
/// Initializes a new instance of the class.
@@ -51,20 +50,5 @@ public Tracer GetTracer(string name, string version = null)
return new Tracer(new ActivitySource(name, version));
}
-
- ///
- public void Dispose()
- {
- this.Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Releases the unmanaged resources used by this class and optionally releases the managed resources.
- ///
- /// to release both managed and unmanaged resources; to release only unmanaged resources.
- protected virtual void Dispose(bool disposing)
- {
- }
}
}
diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleExporter.cs b/src/OpenTelemetry.Exporter.Console/ConsoleExporter.cs
index 413c44b29d6..1fa13774da8 100644
--- a/src/OpenTelemetry.Exporter.Console/ConsoleExporter.cs
+++ b/src/OpenTelemetry.Exporter.Console/ConsoleExporter.cs
@@ -21,7 +21,6 @@
using OpenTelemetry.Logs;
#endif
using OpenTelemetry.Resources;
-using OpenTelemetry.Trace;
namespace OpenTelemetry.Exporter
{
@@ -99,7 +98,7 @@ public override ExportResult Export(in Batch batch)
}
}
- var resource = activity.GetResource();
+ var resource = this.ParentProvider.GetResource();
if (resource != Resource.Empty)
{
this.WriteLine("Resource associated with Activity:");
diff --git a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs
index 4f89a3e8e6b..52611fd6734 100644
--- a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs
+++ b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs
@@ -20,7 +20,6 @@
using System.Runtime.CompilerServices;
using OpenTelemetry.Exporter.Jaeger.Implementation;
using OpenTelemetry.Resources;
-using OpenTelemetry.Trace;
using Thrift.Protocol;
using Thrift.Transport;
using Process = OpenTelemetry.Exporter.Jaeger.Implementation.Process;
@@ -65,13 +64,13 @@ public override ExportResult Export(in Batch activityBatch)
{
try
{
- foreach (var activity in activityBatch)
+ if (this.processCache == null)
{
- if (this.processCache == null)
- {
- this.ApplyLibraryResource(activity.GetResource());
- }
+ this.SetResource(this.ParentProvider.GetResource());
+ }
+ foreach (var activity in activityBatch)
+ {
this.AppendSpan(activity.ToJaegerSpan());
}
@@ -87,18 +86,18 @@ public override ExportResult Export(in Batch activityBatch)
}
}
- internal void ApplyLibraryResource(Resource libraryResource)
+ internal void SetResource(Resource resource)
{
- if (libraryResource is null)
+ if (resource is null)
{
- throw new ArgumentNullException(nameof(libraryResource));
+ throw new ArgumentNullException(nameof(resource));
}
var process = this.Process;
string serviceName = null;
string serviceNamespace = null;
- foreach (var label in libraryResource.Attributes)
+ foreach (var label in resource.Attributes)
{
string key = label.Key;
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs
index 7039abdee0a..b08805b8d87 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs
@@ -28,6 +28,7 @@
using OpenTelemetry.Trace;
using OtlpCollector = Opentelemetry.Proto.Collector.Trace.V1;
using OtlpCommon = Opentelemetry.Proto.Common.V1;
+using OtlpResource = Opentelemetry.Proto.Resource.V1;
using OtlpTrace = Opentelemetry.Proto.Trace.V1;
namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation
@@ -40,23 +41,18 @@ internal static class ActivityExtensions
internal static void AddBatch(
this OtlpCollector.ExportTraceServiceRequest request,
- OtlpExporter otlpExporter,
+ OtlpResource.Resource processResource,
in Batch activityBatch)
{
Dictionary spansByLibrary = new Dictionary();
- OtlpTrace.ResourceSpans resourceSpans = null;
+ OtlpTrace.ResourceSpans resourceSpans = new OtlpTrace.ResourceSpans
+ {
+ Resource = processResource,
+ };
+ request.ResourceSpans.Add(resourceSpans);
foreach (var activity in activityBatch)
{
- if (resourceSpans == null)
- {
- resourceSpans = new OtlpTrace.ResourceSpans
- {
- Resource = otlpExporter.EnsureProcessResource(activity),
- };
- request.ResourceSpans.Add(resourceSpans);
- }
-
OtlpTrace.Span span = activity.ToOtlpSpan();
if (span == null)
{
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporter.cs
index 8bdcaa0dc4f..68641b26da1 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporter.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporter.cs
@@ -18,12 +18,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Grpc.Core;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetry.Resources;
-using OpenTelemetry.Trace;
using OtlpCollector = Opentelemetry.Proto.Collector.Trace.V1;
using OtlpCommon = Opentelemetry.Proto.Common.V1;
using OtlpResource = Opentelemetry.Proto.Resource.V1;
@@ -40,7 +38,6 @@ public class OtlpExporter : BaseExporter
private readonly Channel channel;
private readonly OtlpCollector.TraceService.ITraceServiceClient traceClient;
private readonly Metadata headers;
- private OtlpResource.Resource processResource;
///
/// Initializes a new instance of the class.
@@ -62,12 +59,19 @@ internal OtlpExporter(OtlpExporterOptions options, OtlpCollector.TraceService.IT
}
}
+ internal OtlpResource.Resource ProcessResource { get; private set; }
+
///
public override ExportResult Export(in Batch activityBatch)
{
+ if (this.ProcessResource == null)
+ {
+ this.SetResource(this.ParentProvider.GetResource());
+ }
+
OtlpCollector.ExportTraceServiceRequest request = new OtlpCollector.ExportTraceServiceRequest();
- request.AddBatch(this, activityBatch);
+ request.AddBatch(this.ProcessResource, activityBatch);
try
{
@@ -87,17 +91,11 @@ public override ExportResult Export(in Batch activityBatch)
return ExportResult.Success;
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal OtlpResource.Resource EnsureProcessResource(Activity activity)
+ internal void SetResource(Resource resource)
{
- if (this.processResource != null)
- {
- return this.processResource;
- }
-
OtlpResource.Resource processResource = new OtlpResource.Resource();
- foreach (KeyValuePair attribute in activity.GetResource().Attributes)
+ foreach (KeyValuePair attribute in resource.Attributes)
{
var oltpAttribute = attribute.ToOtlpAttribute();
if (oltpAttribute != null)
@@ -121,7 +119,7 @@ internal OtlpResource.Resource EnsureProcessResource(Activity activity)
});
}
- return this.processResource = processResource;
+ this.ProcessResource = processResource;
}
///
diff --git a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs
index 73ba3b283f3..4c878af9b90 100644
--- a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs
+++ b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs
@@ -27,12 +27,10 @@
#else
using System.Text.Json;
#endif
-using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using OpenTelemetry.Exporter.Zipkin.Implementation;
using OpenTelemetry.Resources;
-using OpenTelemetry.Trace;
namespace OpenTelemetry.Exporter.Zipkin
{
@@ -66,6 +64,11 @@ internal ZipkinExporter(ZipkinExporterOptions options, HttpClient client = null)
///
public override ExportResult Export(in Batch batch)
{
+ if (this.LocalEndpoint == null)
+ {
+ this.SetResource(this.ParentProvider.GetResource());
+ }
+
// Prevent Zipkin's HTTP operations from being instrumented.
using var scope = SuppressInstrumentationScope.Begin();
@@ -92,14 +95,8 @@ public override ExportResult Export(in Batch batch)
}
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal ZipkinEndpoint EnsureLocalEndpoint(Activity activity)
+ internal void SetResource(Resource resource)
{
- if (this.LocalEndpoint != null)
- {
- return this.LocalEndpoint;
- }
-
var hostName = ResolveHostName();
string ipv4 = null;
@@ -113,7 +110,7 @@ internal ZipkinEndpoint EnsureLocalEndpoint(Activity activity)
string serviceName = null;
string serviceNamespace = null;
Dictionary tags = null;
- foreach (var label in activity.GetResource().Attributes)
+ foreach (var label in resource.Attributes)
{
string key = label.Key;
@@ -149,7 +146,7 @@ internal ZipkinEndpoint EnsureLocalEndpoint(Activity activity)
serviceName = this.options.ServiceName;
}
- return this.LocalEndpoint = new ZipkinEndpoint(
+ this.LocalEndpoint = new ZipkinEndpoint(
serviceName,
ipv4,
ipv6,
@@ -257,9 +254,7 @@ protected override Task SerializeToStreamAsync(Stream stream, TransportContext c
foreach (var activity in this.batch)
{
- var localEndpoint = this.exporter.EnsureLocalEndpoint(activity);
-
- var zipkinSpan = activity.ToZipkinSpan(localEndpoint, this.exporter.options.UseShortTraceIds);
+ var zipkinSpan = activity.ToZipkinSpan(this.exporter.LocalEndpoint, this.exporter.options.UseShortTraceIds);
zipkinSpan.Write(this.writer);
diff --git a/src/OpenTelemetry/.publicApi/net452/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net452/PublicAPI.Unshipped.txt
index 8fa6eec76fe..9161a0e61ec 100644
--- a/src/OpenTelemetry/.publicApi/net452/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry/.publicApi/net452/PublicAPI.Unshipped.txt
@@ -1,3 +1,4 @@
+OpenTelemetry.BaseExporter.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseExportProcessor
OpenTelemetry.BaseExportProcessor.BaseExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.BaseExporter
@@ -8,6 +9,7 @@ OpenTelemetry.BaseProcessor
OpenTelemetry.BaseProcessor.BaseProcessor() -> void
OpenTelemetry.BaseProcessor.Dispose() -> void
OpenTelemetry.BaseProcessor.ForceFlush(int timeoutMilliseconds = -1) -> bool
+OpenTelemetry.BaseProcessor.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseProcessor.Shutdown(int timeoutMilliseconds = -1) -> bool
OpenTelemetry.Batch
OpenTelemetry.Batch.Batch() -> void
@@ -106,6 +108,7 @@ OpenTelemetry.Metrics.MeterProviderBuilder.Build() -> OpenTelemetry.Metrics.Mete
OpenTelemetry.Metrics.MeterProviderBuilder.SetExporter(OpenTelemetry.Metrics.Export.MetricExporter exporter) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetProcessor(OpenTelemetry.Metrics.Export.MetricProcessor processor) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetPushInterval(System.TimeSpan pushInterval) -> OpenTelemetry.Metrics.MeterProviderBuilder
+OpenTelemetry.ProviderExtensions
OpenTelemetry.ReentrantExportProcessor
OpenTelemetry.ReentrantExportProcessor.ReentrantExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.Resources.Resource
@@ -118,7 +121,6 @@ OpenTelemetry.SimpleExportProcessor
OpenTelemetry.SimpleExportProcessor.SimpleExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.SuppressInstrumentationScope
OpenTelemetry.SuppressInstrumentationScope.Dispose() -> void
-OpenTelemetry.Trace.ActivityExtensions
OpenTelemetry.Trace.AlwaysOffSampler
OpenTelemetry.Trace.AlwaysOffSampler.AlwaysOffSampler() -> void
OpenTelemetry.Trace.AlwaysOnSampler
@@ -222,6 +224,7 @@ override OpenTelemetry.Trace.TraceIdRatioBasedSampler.ShouldSample(in OpenTeleme
override abstract OpenTelemetry.BaseExportProcessor.OnEnd(T data) -> void
override sealed OpenTelemetry.BaseExportProcessor.OnStart(T data) -> void
readonly OpenTelemetry.BaseExportProcessor.exporter -> OpenTelemetry.BaseExporter
+static OpenTelemetry.ProviderExtensions.GetResource(this OpenTelemetry.BaseProvider baseProvider) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resource.Empty.get -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resources.CreateServiceResource(string serviceName, string serviceInstanceId = null, string serviceNamespace = null, string serviceVersion = null) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Sdk.CreateMeterProviderBuilder() -> OpenTelemetry.Metrics.MeterProviderBuilder
@@ -230,8 +233,6 @@ static OpenTelemetry.Sdk.SetDefaultTextMapPropagator(OpenTelemetry.Context.Propa
static OpenTelemetry.Sdk.SuppressInstrumentation.get -> bool
static OpenTelemetry.SuppressInstrumentationScope.Begin(bool value = true) -> System.IDisposable
static OpenTelemetry.SuppressInstrumentationScope.Enter() -> int
-static OpenTelemetry.Trace.ActivityExtensions.GetResource(this System.Diagnostics.Activity activity) -> OpenTelemetry.Resources.Resource
-static OpenTelemetry.Trace.ActivityExtensions.SetResource(this System.Diagnostics.Activity activity, OpenTelemetry.Resources.Resource resource) -> void
static OpenTelemetry.Trace.SamplingResult.operator !=(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.SamplingResult.operator ==(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.TracerProviderExtensions.AddProcessor(this OpenTelemetry.Trace.TracerProvider provider, OpenTelemetry.BaseProcessor processor) -> OpenTelemetry.Trace.TracerProvider
diff --git a/src/OpenTelemetry/.publicApi/net46/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net46/PublicAPI.Unshipped.txt
index 8fa6eec76fe..9161a0e61ec 100644
--- a/src/OpenTelemetry/.publicApi/net46/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry/.publicApi/net46/PublicAPI.Unshipped.txt
@@ -1,3 +1,4 @@
+OpenTelemetry.BaseExporter.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseExportProcessor
OpenTelemetry.BaseExportProcessor.BaseExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.BaseExporter
@@ -8,6 +9,7 @@ OpenTelemetry.BaseProcessor
OpenTelemetry.BaseProcessor.BaseProcessor() -> void
OpenTelemetry.BaseProcessor.Dispose() -> void
OpenTelemetry.BaseProcessor.ForceFlush(int timeoutMilliseconds = -1) -> bool
+OpenTelemetry.BaseProcessor.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseProcessor.Shutdown(int timeoutMilliseconds = -1) -> bool
OpenTelemetry.Batch
OpenTelemetry.Batch.Batch() -> void
@@ -106,6 +108,7 @@ OpenTelemetry.Metrics.MeterProviderBuilder.Build() -> OpenTelemetry.Metrics.Mete
OpenTelemetry.Metrics.MeterProviderBuilder.SetExporter(OpenTelemetry.Metrics.Export.MetricExporter exporter) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetProcessor(OpenTelemetry.Metrics.Export.MetricProcessor processor) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetPushInterval(System.TimeSpan pushInterval) -> OpenTelemetry.Metrics.MeterProviderBuilder
+OpenTelemetry.ProviderExtensions
OpenTelemetry.ReentrantExportProcessor
OpenTelemetry.ReentrantExportProcessor.ReentrantExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.Resources.Resource
@@ -118,7 +121,6 @@ OpenTelemetry.SimpleExportProcessor
OpenTelemetry.SimpleExportProcessor.SimpleExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.SuppressInstrumentationScope
OpenTelemetry.SuppressInstrumentationScope.Dispose() -> void
-OpenTelemetry.Trace.ActivityExtensions
OpenTelemetry.Trace.AlwaysOffSampler
OpenTelemetry.Trace.AlwaysOffSampler.AlwaysOffSampler() -> void
OpenTelemetry.Trace.AlwaysOnSampler
@@ -222,6 +224,7 @@ override OpenTelemetry.Trace.TraceIdRatioBasedSampler.ShouldSample(in OpenTeleme
override abstract OpenTelemetry.BaseExportProcessor.OnEnd(T data) -> void
override sealed OpenTelemetry.BaseExportProcessor.OnStart(T data) -> void
readonly OpenTelemetry.BaseExportProcessor.exporter -> OpenTelemetry.BaseExporter
+static OpenTelemetry.ProviderExtensions.GetResource(this OpenTelemetry.BaseProvider baseProvider) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resource.Empty.get -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resources.CreateServiceResource(string serviceName, string serviceInstanceId = null, string serviceNamespace = null, string serviceVersion = null) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Sdk.CreateMeterProviderBuilder() -> OpenTelemetry.Metrics.MeterProviderBuilder
@@ -230,8 +233,6 @@ static OpenTelemetry.Sdk.SetDefaultTextMapPropagator(OpenTelemetry.Context.Propa
static OpenTelemetry.Sdk.SuppressInstrumentation.get -> bool
static OpenTelemetry.SuppressInstrumentationScope.Begin(bool value = true) -> System.IDisposable
static OpenTelemetry.SuppressInstrumentationScope.Enter() -> int
-static OpenTelemetry.Trace.ActivityExtensions.GetResource(this System.Diagnostics.Activity activity) -> OpenTelemetry.Resources.Resource
-static OpenTelemetry.Trace.ActivityExtensions.SetResource(this System.Diagnostics.Activity activity, OpenTelemetry.Resources.Resource resource) -> void
static OpenTelemetry.Trace.SamplingResult.operator !=(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.SamplingResult.operator ==(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.TracerProviderExtensions.AddProcessor(this OpenTelemetry.Trace.TracerProvider provider, OpenTelemetry.BaseProcessor processor) -> OpenTelemetry.Trace.TracerProvider
diff --git a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt
index fcb0d703375..028dee03d98 100644
--- a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt
@@ -1,4 +1,5 @@
Microsoft.Extensions.Logging.OpenTelemetryLoggingExtensions
+OpenTelemetry.BaseExporter.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseExportProcessor
OpenTelemetry.BaseExportProcessor.BaseExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.BaseExporter
@@ -9,6 +10,7 @@ OpenTelemetry.BaseProcessor
OpenTelemetry.BaseProcessor.BaseProcessor() -> void
OpenTelemetry.BaseProcessor.Dispose() -> void
OpenTelemetry.BaseProcessor.ForceFlush(int timeoutMilliseconds = -1) -> bool
+OpenTelemetry.BaseProcessor.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseProcessor.Shutdown(int timeoutMilliseconds = -1) -> bool
OpenTelemetry.Batch
OpenTelemetry.Batch.Batch() -> void
@@ -125,6 +127,7 @@ OpenTelemetry.Metrics.MeterProviderBuilder.Build() -> OpenTelemetry.Metrics.Mete
OpenTelemetry.Metrics.MeterProviderBuilder.SetExporter(OpenTelemetry.Metrics.Export.MetricExporter exporter) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetProcessor(OpenTelemetry.Metrics.Export.MetricProcessor processor) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetPushInterval(System.TimeSpan pushInterval) -> OpenTelemetry.Metrics.MeterProviderBuilder
+OpenTelemetry.ProviderExtensions
OpenTelemetry.ReentrantExportProcessor
OpenTelemetry.ReentrantExportProcessor.ReentrantExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.Resources.Resource
@@ -137,7 +140,6 @@ OpenTelemetry.SimpleExportProcessor
OpenTelemetry.SimpleExportProcessor.SimpleExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.SuppressInstrumentationScope
OpenTelemetry.SuppressInstrumentationScope.Dispose() -> void
-OpenTelemetry.Trace.ActivityExtensions
OpenTelemetry.Trace.AlwaysOffSampler
OpenTelemetry.Trace.AlwaysOffSampler.AlwaysOffSampler() -> void
OpenTelemetry.Trace.AlwaysOnSampler
@@ -242,6 +244,7 @@ override abstract OpenTelemetry.BaseExportProcessor.OnEnd(T data) -> void
override sealed OpenTelemetry.BaseExportProcessor.OnStart(T data) -> void
readonly OpenTelemetry.BaseExportProcessor.exporter -> OpenTelemetry.BaseExporter
static Microsoft.Extensions.Logging.OpenTelemetryLoggingExtensions.AddOpenTelemetry(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Action configure = null) -> Microsoft.Extensions.Logging.ILoggingBuilder
+static OpenTelemetry.ProviderExtensions.GetResource(this OpenTelemetry.BaseProvider baseProvider) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resource.Empty.get -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resources.CreateServiceResource(string serviceName, string serviceInstanceId = null, string serviceNamespace = null, string serviceVersion = null) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Sdk.CreateMeterProviderBuilder() -> OpenTelemetry.Metrics.MeterProviderBuilder
@@ -250,8 +253,6 @@ static OpenTelemetry.Sdk.SetDefaultTextMapPropagator(OpenTelemetry.Context.Propa
static OpenTelemetry.Sdk.SuppressInstrumentation.get -> bool
static OpenTelemetry.SuppressInstrumentationScope.Begin(bool value = true) -> System.IDisposable
static OpenTelemetry.SuppressInstrumentationScope.Enter() -> int
-static OpenTelemetry.Trace.ActivityExtensions.GetResource(this System.Diagnostics.Activity activity) -> OpenTelemetry.Resources.Resource
-static OpenTelemetry.Trace.ActivityExtensions.SetResource(this System.Diagnostics.Activity activity, OpenTelemetry.Resources.Resource resource) -> void
static OpenTelemetry.Trace.SamplingResult.operator !=(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.SamplingResult.operator ==(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.TracerProviderExtensions.AddProcessor(this OpenTelemetry.Trace.TracerProvider provider, OpenTelemetry.BaseProcessor processor) -> OpenTelemetry.Trace.TracerProvider
diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
index fcb0d703375..028dee03d98 100644
--- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
@@ -1,4 +1,5 @@
Microsoft.Extensions.Logging.OpenTelemetryLoggingExtensions
+OpenTelemetry.BaseExporter.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseExportProcessor
OpenTelemetry.BaseExportProcessor.BaseExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.BaseExporter
@@ -9,6 +10,7 @@ OpenTelemetry.BaseProcessor
OpenTelemetry.BaseProcessor.BaseProcessor() -> void
OpenTelemetry.BaseProcessor.Dispose() -> void
OpenTelemetry.BaseProcessor.ForceFlush(int timeoutMilliseconds = -1) -> bool
+OpenTelemetry.BaseProcessor.ParentProvider.get -> OpenTelemetry.BaseProvider
OpenTelemetry.BaseProcessor.Shutdown(int timeoutMilliseconds = -1) -> bool
OpenTelemetry.Batch
OpenTelemetry.Batch.Batch() -> void
@@ -125,6 +127,7 @@ OpenTelemetry.Metrics.MeterProviderBuilder.Build() -> OpenTelemetry.Metrics.Mete
OpenTelemetry.Metrics.MeterProviderBuilder.SetExporter(OpenTelemetry.Metrics.Export.MetricExporter exporter) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetProcessor(OpenTelemetry.Metrics.Export.MetricProcessor processor) -> OpenTelemetry.Metrics.MeterProviderBuilder
OpenTelemetry.Metrics.MeterProviderBuilder.SetPushInterval(System.TimeSpan pushInterval) -> OpenTelemetry.Metrics.MeterProviderBuilder
+OpenTelemetry.ProviderExtensions
OpenTelemetry.ReentrantExportProcessor
OpenTelemetry.ReentrantExportProcessor.ReentrantExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.Resources.Resource
@@ -137,7 +140,6 @@ OpenTelemetry.SimpleExportProcessor
OpenTelemetry.SimpleExportProcessor.SimpleExportProcessor(OpenTelemetry.BaseExporter exporter) -> void
OpenTelemetry.SuppressInstrumentationScope
OpenTelemetry.SuppressInstrumentationScope.Dispose() -> void
-OpenTelemetry.Trace.ActivityExtensions
OpenTelemetry.Trace.AlwaysOffSampler
OpenTelemetry.Trace.AlwaysOffSampler.AlwaysOffSampler() -> void
OpenTelemetry.Trace.AlwaysOnSampler
@@ -242,6 +244,7 @@ override abstract OpenTelemetry.BaseExportProcessor.OnEnd(T data) -> void
override sealed OpenTelemetry.BaseExportProcessor.OnStart(T data) -> void
readonly OpenTelemetry.BaseExportProcessor.exporter -> OpenTelemetry.BaseExporter
static Microsoft.Extensions.Logging.OpenTelemetryLoggingExtensions.AddOpenTelemetry(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Action configure = null) -> Microsoft.Extensions.Logging.ILoggingBuilder
+static OpenTelemetry.ProviderExtensions.GetResource(this OpenTelemetry.BaseProvider baseProvider) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resource.Empty.get -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resources.CreateServiceResource(string serviceName, string serviceInstanceId = null, string serviceNamespace = null, string serviceVersion = null) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Sdk.CreateMeterProviderBuilder() -> OpenTelemetry.Metrics.MeterProviderBuilder
@@ -250,8 +253,6 @@ static OpenTelemetry.Sdk.SetDefaultTextMapPropagator(OpenTelemetry.Context.Propa
static OpenTelemetry.Sdk.SuppressInstrumentation.get -> bool
static OpenTelemetry.SuppressInstrumentationScope.Begin(bool value = true) -> System.IDisposable
static OpenTelemetry.SuppressInstrumentationScope.Enter() -> int
-static OpenTelemetry.Trace.ActivityExtensions.GetResource(this System.Diagnostics.Activity activity) -> OpenTelemetry.Resources.Resource
-static OpenTelemetry.Trace.ActivityExtensions.SetResource(this System.Diagnostics.Activity activity, OpenTelemetry.Resources.Resource resource) -> void
static OpenTelemetry.Trace.SamplingResult.operator !=(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.SamplingResult.operator ==(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.TracerProviderExtensions.AddProcessor(this OpenTelemetry.Trace.TracerProvider provider, OpenTelemetry.BaseProcessor processor) -> OpenTelemetry.Trace.TracerProvider
diff --git a/src/OpenTelemetry/BaseExportProcessor.cs b/src/OpenTelemetry/BaseExportProcessor.cs
index b9ed83bc4c3..b7a1335cef5 100644
--- a/src/OpenTelemetry/BaseExportProcessor.cs
+++ b/src/OpenTelemetry/BaseExportProcessor.cs
@@ -46,6 +46,13 @@ public sealed override void OnStart(T data)
///
public abstract override void OnEnd(T data);
+ internal override void SetParentProvider(BaseProvider parentProvider)
+ {
+ base.SetParentProvider(parentProvider);
+
+ this.exporter.ParentProvider = parentProvider;
+ }
+
///
protected override bool OnShutdown(int timeoutMilliseconds)
{
diff --git a/src/OpenTelemetry/BaseExporter.cs b/src/OpenTelemetry/BaseExporter.cs
index 1b0d0c0c6d9..9a281063225 100644
--- a/src/OpenTelemetry/BaseExporter.cs
+++ b/src/OpenTelemetry/BaseExporter.cs
@@ -45,6 +45,11 @@ public abstract class BaseExporter : IDisposable
{
private int shutdownCount;
+ ///
+ /// Gets the parent .
+ ///
+ public BaseProvider ParentProvider { get; internal set; }
+
///
/// Exports a batch of telemetry objects.
///
diff --git a/src/OpenTelemetry/BaseProcessor.cs b/src/OpenTelemetry/BaseProcessor.cs
index 5e6b5a538fa..e8cf98ae0e3 100644
--- a/src/OpenTelemetry/BaseProcessor.cs
+++ b/src/OpenTelemetry/BaseProcessor.cs
@@ -28,6 +28,11 @@ public abstract class BaseProcessor : IDisposable
{
private int shutdownCount;
+ ///
+ /// Gets the parent .
+ ///
+ public BaseProvider ParentProvider { get; private set; }
+
///
/// Called synchronously when a telemetry object is started.
///
@@ -141,6 +146,11 @@ public void Dispose()
GC.SuppressFinalize(this);
}
+ internal virtual void SetParentProvider(BaseProvider parentProvider)
+ {
+ this.ParentProvider = parentProvider;
+ }
+
///
/// Called by ForceFlush. This function should block the current
/// thread until flush completed, shutdown signaled or timed out.
diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md
index b29c0a995b3..94a57e3c9c1 100644
--- a/src/OpenTelemetry/CHANGELOG.md
+++ b/src/OpenTelemetry/CHANGELOG.md
@@ -2,6 +2,15 @@
## Unreleased
+* Removed `GetResource` and `SetResource` `Activity` extension methods. Added
+ `GetResource` extension method on `BaseProvider`
+ ([#1463](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1463))
+* Added `ParentProvider` property on `BaseProcessor` and `BaseExporter` classes.
+ ([#1463](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1463))
+* `Resource` is no longer added to observed `Activity` objects as a
+ `CustomProperty`.
+ ([#1463](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1463))
+
## 0.8.0-beta.1
Released 2020-Nov-5
diff --git a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
index c1bd65b635d..3cb12e262d9 100644
--- a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
+++ b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
@@ -295,7 +295,7 @@ protected override void OnEventSourceCreated(EventSource eventSource)
protected override void OnEventWritten(EventWrittenEventArgs e)
{
string message;
- if ((e.Payload?.Count ?? 0) > 0)
+ if (e.Message != null && (e.Payload?.Count ?? 0) > 0)
{
message = string.Format(e.Message, e.Payload.ToArray());
}
diff --git a/src/OpenTelemetry/ProviderExtensions.cs b/src/OpenTelemetry/ProviderExtensions.cs
new file mode 100644
index 00000000000..c5b231c321a
--- /dev/null
+++ b/src/OpenTelemetry/ProviderExtensions.cs
@@ -0,0 +1,42 @@
+//
+// 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.
+//
+
+using OpenTelemetry.Resources;
+using OpenTelemetry.Trace;
+
+namespace OpenTelemetry
+{
+ ///
+ /// Contains provider extension methods.
+ ///
+ public static class ProviderExtensions
+ {
+ ///
+ /// Gets the associated with the .
+ ///
+ /// .
+ /// if found otherwise .
+ public static Resource GetResource(this BaseProvider baseProvider)
+ {
+ if (baseProvider is TracerProviderSdk tracerProviderSdk)
+ {
+ return tracerProviderSdk.Resource;
+ }
+
+ return Resource.Empty;
+ }
+ }
+}
diff --git a/src/OpenTelemetry/Trace/ActivityExtensions.cs b/src/OpenTelemetry/Trace/ActivityExtensions.cs
deleted file mode 100644
index b6d339c34b4..00000000000
--- a/src/OpenTelemetry/Trace/ActivityExtensions.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// 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.
-//
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using OpenTelemetry.Resources;
-
-namespace OpenTelemetry.Trace
-{
- ///
- /// Extension methods on Activity.
- ///
- public static class ActivityExtensions
- {
- internal const string ResourcePropertyName = "OTel.Resource";
-
- ///
- /// Gets the Resource associated with the Activity.
- ///
- /// Activity instance.
- /// The resource.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Resource GetResource(this Activity activity)
- {
- return activity?.GetCustomProperty(ResourcePropertyName) is Resource res
- ? res
- : Resource.Empty;
- }
-
- ///
- /// Sets the Resource associated with the Activity.
- ///
- /// Activity instance.
- /// Resource to set to.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void SetResource(this Activity activity, Resource resource)
- {
- activity.SetCustomProperty(ResourcePropertyName, resource);
- }
- }
-}
diff --git a/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs b/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs
index 864570fa9d1..6e514d5f7e0 100644
--- a/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs
+++ b/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs
@@ -18,7 +18,6 @@
using System.Diagnostics;
using System.Linq.Expressions;
using OpenTelemetry.Internal;
-using OpenTelemetry.Resources;
namespace OpenTelemetry.Trace
{
@@ -41,14 +40,12 @@ internal class ActivitySourceAdapter
{
private static readonly Action SetKindProperty = CreateActivityKindSetter();
private readonly Sampler sampler;
- private readonly Resource resource;
private readonly Action getRequestedDataAction;
private BaseProcessor activityProcessor;
- internal ActivitySourceAdapter(Sampler sampler, BaseProcessor activityProcessor, Resource resource)
+ internal ActivitySourceAdapter(Sampler sampler, BaseProcessor activityProcessor)
{
this.sampler = sampler ?? throw new ArgumentNullException(nameof(sampler));
- this.resource = resource ?? throw new ArgumentNullException(nameof(resource));
if (this.sampler is AlwaysOnSampler)
{
this.getRequestedDataAction = this.RunGetRequestedDataAlwaysOnSampler;
@@ -83,7 +80,6 @@ public void Start(Activity activity, ActivityKind kind)
this.getRequestedDataAction(activity);
if (activity.IsAllDataRequested)
{
- activity.SetResource(this.resource);
this.activityProcessor?.OnStart(activity);
}
}
diff --git a/src/OpenTelemetry/Trace/TracerProviderSdk.cs b/src/OpenTelemetry/Trace/TracerProviderSdk.cs
index 87d3016c97e..044058a4276 100644
--- a/src/OpenTelemetry/Trace/TracerProviderSdk.cs
+++ b/src/OpenTelemetry/Trace/TracerProviderSdk.cs
@@ -29,7 +29,6 @@ internal class TracerProviderSdk : TracerProvider
{
private readonly List