Migrate JaegerExporter to BatchExportActivityProcessor (#1125)
* Updating Jaeger Exporter * updating changelog
This commit is contained in:
parent
c75d85ba6b
commit
ee5b038540
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
* Changed `JaegerExporter` to use `BatchExportActivityProcessor` by default
|
||||
([#1125](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1125))
|
||||
* Span links will now be sent as `FOLLOWS_FROM` reference type. Previously they
|
||||
were sent as `CHILD_OF`.
|
||||
([#970](https://github.com/open-telemetry/opentelemetry-dotnet/pull/970))
|
||||
|
|
|
|||
|
|
@ -13,19 +13,18 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTelemetry.Exporter.Jaeger.Implementation;
|
||||
using OpenTelemetry.Resources;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Jaeger
|
||||
{
|
||||
public class JaegerExporter : ActivityExporter
|
||||
public class JaegerExporter : ActivityExporterSync
|
||||
{
|
||||
private bool libraryResourceApplied;
|
||||
private bool disposedValue; // To detect redundant dispose calls
|
||||
|
|
@ -37,26 +36,34 @@ namespace OpenTelemetry.Exporter.Jaeger
|
|||
|
||||
internal JaegerUdpBatcher JaegerAgentUdpBatcher { get; }
|
||||
|
||||
public override async Task<ExportResult> ExportAsync(IEnumerable<Activity> activityBatch, CancellationToken cancellationToken)
|
||||
/// <inheritdoc/>
|
||||
public override ExportResultSync Export(in Batch<Activity> activityBatch)
|
||||
{
|
||||
if (!this.libraryResourceApplied && activityBatch.Any())
|
||||
var activities = new List<Activity>();
|
||||
foreach (var activity in activityBatch)
|
||||
{
|
||||
var libraryResource = activityBatch.First().GetResource();
|
||||
activities.Add(activity);
|
||||
}
|
||||
|
||||
if (!this.libraryResourceApplied && activities.Any())
|
||||
{
|
||||
var libraryResource = activities.First().GetResource();
|
||||
|
||||
this.ApplyLibraryResource(libraryResource ?? Resource.Empty);
|
||||
|
||||
this.libraryResourceApplied = true;
|
||||
}
|
||||
|
||||
await this.JaegerAgentUdpBatcher.AppendBatchAsync(activityBatch, cancellationToken).ConfigureAwait(false);
|
||||
this.JaegerAgentUdpBatcher.AppendBatchAsync(activities, default).GetAwaiter().GetResult();
|
||||
|
||||
// TODO jaeger status to ExportResult
|
||||
return ExportResult.Success;
|
||||
return ExportResultSync.Success;
|
||||
}
|
||||
|
||||
public override async Task ShutdownAsync(CancellationToken cancellationToken)
|
||||
/// <inheritdoc/>
|
||||
public override void Shutdown()
|
||||
{
|
||||
await this.JaegerAgentUdpBatcher.FlushAsync(cancellationToken).ConfigureAwait(false);
|
||||
this.JaegerAgentUdpBatcher.FlushAsync(default).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
internal void ApplyLibraryResource(Resource libraryResource)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace OpenTelemetry.Trace
|
|||
var jaegerExporter = new JaegerExporter(exporterOptions);
|
||||
|
||||
// TODO: Pick Simple vs Batching based on JaegerExporterOptions
|
||||
return builder.AddProcessor(new SimpleActivityProcessor(jaegerExporter));
|
||||
return builder.AddProcessor(new BatchExportActivityProcessor(jaegerExporter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue