Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// <copyright file="JaegerExporterEventSource.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.Diagnostics.Tracing;
using System.Globalization;
using System.Threading;

namespace OpenTelemetry.Exporter.Jaeger.Implementation
{
/// <summary>
/// EventSource events emitted from the project.
/// </summary>
[EventSource(Name = "OpenTelemetry-Exporter-Jaeger")]
internal class JaegerExporterEventSource : EventSource
{
public static JaegerExporterEventSource Log = new JaegerExporterEventSource();

[NonEvent]
public void FailedToSend(Exception ex)
{
if (this.IsEnabled(EventLevel.Error, EventKeywords.All))
{
this.FailedToSend(ToInvariantString(ex));
}
}

[Event(1, Message = "Failed to send spans: '{0}'", Level = EventLevel.Error)]
public void FailedToSend(string exception)
{
this.WriteEvent(1, exception);
}

/// <summary>
/// Returns a culture-independent string representation of the given <paramref name="exception"/> object,
/// appropriate for diagnostics tracing.
/// </summary>
private static string ToInvariantString(Exception exception)
{
var originalUICulture = Thread.CurrentThread.CurrentUICulture;

try
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
return exception.ToString();
}
finally
{
Thread.CurrentThread.CurrentUICulture = originalUICulture;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ public JaegerUdpBatcher(JaegerExporterOptions options, TTransport clientTranspor

this.maxFlushIntervalTimer.Elapsed += async (sender, args) =>
{
await this.FlushAsyncInternal(false, CancellationToken.None).ConfigureAwait(false);
};
try
{
await this.FlushAsyncInternal(false, CancellationToken.None).ConfigureAwait(false);
}
catch (Exception ex)
{
JaegerExporterEventSource.Log.FailedToSend(ex);
}
};
}

public Process Process { get; internal set; }
Expand Down