-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
113 changed files
with
488 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 1 addition & 21 deletions
22
src/OpenTelemetry.Exporter.Geneva/Internal/ReentrantExportProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,18 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
|
||
namespace OpenTelemetry.Exporter.Geneva; | ||
|
||
// This export processor exports without synchronization. | ||
// Once OpenTelemetry .NET officially support this, | ||
// we can get rid of this class. | ||
// This is currently only used in ETW export, where we know | ||
// that the underlying system is safe under concurrent calls. | ||
internal class ReentrantExportProcessor<T> : BaseExportProcessor<T> | ||
where T : class | ||
{ | ||
private static readonly Func<T, Batch<T>> CreateBatch = BuildCreateBatchDelegate(); | ||
|
||
public ReentrantExportProcessor(BaseExporter<T> exporter) | ||
: base(exporter) | ||
{ | ||
} | ||
|
||
protected override void OnExport(T data) | ||
{ | ||
this.exporter.Export(CreateBatch(data)); | ||
} | ||
|
||
private static Func<T, Batch<T>> BuildCreateBatchDelegate() | ||
{ | ||
var flags = BindingFlags.Instance | BindingFlags.NonPublic; | ||
var ctor = typeof(Batch<T>).GetConstructor(flags, null, new Type[] { typeof(T) }, null) | ||
?? throw new InvalidOperationException("Batch ctor accepting a single item could not be found reflectively"); | ||
var value = Expression.Parameter(typeof(T), null); | ||
var lambda = Expression.Lambda<Func<T, Batch<T>>>(Expression.New(ctor, value), value); | ||
return lambda.Compile(); | ||
this.exporter.Export(new(data)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.