Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ public void OpenTelemetryLoggerProviderForceFlushInvoked(int timeoutMilliseconds
this.WriteEvent(45, timeoutMilliseconds);
}

[Event(46, Message = "TracerProviderSdk event: '{0}'", Level = EventLevel.Verbose)]
public void TracerProviderSdkEvent(string message)
{
this.WriteEvent(46, message);
}

#if DEBUG
public class OpenTelemetryEventListener : EventListener
{
Expand Down
23 changes: 23 additions & 0 deletions src/OpenTelemetry/Trace/TracerProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using OpenTelemetry.Internal;
using OpenTelemetry.Resources;

Expand Down Expand Up @@ -49,12 +50,17 @@ internal TracerProviderSdk(
Debug.Assert(this.OwnedServiceProvider != null, "serviceProvider was not IDisposable");
}

OpenTelemetrySdkEventSource.Log.TracerProviderSdkEvent("Building TracerProvider.");

var state = new TracerProviderBuilderState(serviceProvider);

TracerProviderBuilderServiceCollectionHelper.InvokeRegisteredConfigureStateCallbacks(
serviceProvider,
state);

StringBuilder processorsAdded = new StringBuilder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also include sampler, as it is often the most critical information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cijothomas sure, will raise another PR for this

StringBuilder instrumentationFactoriesAdded = new StringBuilder();

if (state.SetErrorStatusOnException)
{
state.EnableErrorStatusOnException();
Expand All @@ -79,11 +85,27 @@ internal TracerProviderSdk(
foreach (var processor in state.Processors)
{
this.AddProcessor(processor);
processorsAdded.Append(processor.GetType());
processorsAdded.Append(';');
}

foreach (var instrumentation in state.Instrumentation)
{
this.instrumentations.Add(instrumentation.Instance);
instrumentationFactoriesAdded.Append(instrumentation.Name);
instrumentationFactoriesAdded.Append(';');
}

if (processorsAdded.Length != 0)
{
processorsAdded.Remove(processorsAdded.Length - 1, 1);
OpenTelemetrySdkEventSource.Log.TracerProviderSdkEvent($"Processors added = \"{processorsAdded}\".");
}

if (instrumentationFactoriesAdded.Length != 0)
{
instrumentationFactoriesAdded.Remove(instrumentationFactoriesAdded.Length - 1, 1);
OpenTelemetrySdkEventSource.Log.TracerProviderSdkEvent($"Instrumentations added = \"{instrumentationFactoriesAdded}\".");
}

var listener = new ActivityListener();
Expand Down Expand Up @@ -264,6 +286,7 @@ internal TracerProviderSdk(

ActivitySource.AddActivityListener(listener);
this.listener = listener;
OpenTelemetrySdkEventSource.Log.TracerProviderSdkEvent("TracerProvider built successfully.");
}

internal Resource Resource { get; }
Expand Down