Skip to content

Commit

Permalink
Migrate JaegerExporter to BatchExportActivityProcessor (#1125)
Browse files Browse the repository at this point in the history
* Updating Jaeger Exporter

* updating changelog
  • Loading branch information
eddynaka authored Aug 21, 2020
1 parent c75d85b commit ee5b038
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
27 changes: 17 additions & 10 deletions src/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,26 +36,34 @@ public JaegerExporter(JaegerExporterOptions options)

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)
{
activities.Add(activity);
}

if (!this.libraryResourceApplied && activities.Any())
{
var libraryResource = activityBatch.First().GetResource();
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static TracerProviderBuilder AddJaegerExporter(this TracerProviderBuilder
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));
}
}
}

0 comments on commit ee5b038

Please sign in to comment.