Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor exporter - step 9 #1129

Merged
merged 4 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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: 3 additions & 3 deletions docs/trace/building-your-own-exporter/MyExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
using OpenTelemetry;
using OpenTelemetry.Trace;

internal class MyExporter : ActivityExporterSync
internal class MyExporter : ActivityExporter
{
public override ExportResultSync Export(in Batch<Activity> batch)
public override ExportResult Export(in Batch<Activity> batch)
{
// Exporter code which can generate further
// telemetry should do so inside SuppressInstrumentation
Expand All @@ -34,6 +34,6 @@ public override ExportResultSync Export(in Batch<Activity> batch)
Console.WriteLine($"{activity.DisplayName}");
}

return ExportResultSync.Success;
return ExportResult.Success;
}
}
6 changes: 3 additions & 3 deletions src/OpenTelemetry.Exporter.Console/ConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace OpenTelemetry.Exporter.Console
{
public class ConsoleExporter : ActivityExporterSync
public class ConsoleExporter : ActivityExporter
{
private readonly JsonSerializerOptions serializerOptions;
private readonly bool displayAsJson;
Expand All @@ -43,7 +43,7 @@ public ConsoleExporter(ConsoleExporterOptions options)
this.serializerOptions.Converters.Add(new ActivityTraceIdConverter());
}

public override ExportResultSync Export(in Batch<Activity> batch)
public override ExportResult Export(in Batch<Activity> batch)
{
foreach (var activity in batch)
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public override ExportResultSync Export(in Batch<Activity> batch)
}
}

return ExportResultSync.Success;
return ExportResult.Success;
}
}
}
6 changes: 3 additions & 3 deletions src/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace OpenTelemetry.Exporter.Jaeger
{
public class JaegerExporter : ActivityExporterSync
public class JaegerExporter : ActivityExporter
{
private bool libraryResourceApplied;
private bool disposedValue; // To detect redundant dispose calls
Expand All @@ -37,7 +37,7 @@ public JaegerExporter(JaegerExporterOptions options)
internal JaegerUdpBatcher JaegerAgentUdpBatcher { get; }

/// <inheritdoc/>
public override ExportResultSync Export(in Batch<Activity> activityBatch)
public override ExportResult Export(in Batch<Activity> activityBatch)
{
var activities = new List<Activity>();
foreach (var activity in activityBatch)
Expand All @@ -57,7 +57,7 @@ public override ExportResultSync Export(in Batch<Activity> activityBatch)
this.JaegerAgentUdpBatcher.AppendBatchAsync(activities, default).GetAwaiter().GetResult();

// TODO jaeger status to ExportResult
return ExportResultSync.Success;
return ExportResult.Success;
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol
/// Exporter consuming <see cref="Activity"/> and exporting the data using
/// the OpenTelemetry protocol (OTLP).
/// </summary>
public class OtlpExporter : ActivityExporterSync
public class OtlpExporter : ActivityExporter
{
private readonly Channel channel;
private readonly OtlpCollector.TraceService.TraceServiceClient traceClient;
Expand All @@ -45,7 +45,7 @@ public OtlpExporter(OtlpExporterOptions options)
}

/// <inheritdoc/>
public override ExportResultSync Export(in Batch<Activity> activityBatch)
public override ExportResult Export(in Batch<Activity> activityBatch)
{
var exporterRequest = new OtlpCollector.ExportTraceServiceRequest();

Expand All @@ -65,10 +65,10 @@ public override ExportResultSync Export(in Batch<Activity> activityBatch)
{
OpenTelemetryProtocolExporterEventSource.Log.FailedToReachCollector(ex);

return ExportResultSync.Failure;
return ExportResult.Failure;
}

return ExportResultSync.Success;
return ExportResult.Success;
}
}
}
6 changes: 3 additions & 3 deletions src/OpenTelemetry.Exporter.ZPages/ZPagesExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace OpenTelemetry.Exporter.ZPages
/// <summary>
/// Implements ZPages exporter.
/// </summary>
public class ZPagesExporter : ActivityExporterSync
public class ZPagesExporter : ActivityExporter
{
internal readonly ZPagesExporterOptions Options;
private readonly Timer minuteTimer;
Expand Down Expand Up @@ -53,10 +53,10 @@ public ZPagesExporter(ZPagesExporterOptions options)
}

/// <inheritdoc />
public override ExportResultSync Export(in Batch<Activity> batch)
public override ExportResult Export(in Batch<Activity> batch)
{
// var spanDatas = batch as SpanData[] ?? batch.ToArray();
return ExportResultSync.Success;
return ExportResult.Success;
}
}
}
8 changes: 4 additions & 4 deletions src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace OpenTelemetry.Exporter.Zipkin
/// <summary>
/// Zipkin exporter.
/// </summary>
public class ZipkinExporter : ActivityExporterSync
public class ZipkinExporter : ActivityExporter
{
private readonly ZipkinExporterOptions options;
private readonly HttpClient httpClient;
Expand All @@ -57,7 +57,7 @@ public ZipkinExporter(ZipkinExporterOptions options, HttpClient client = null)
internal ZipkinEndpoint LocalEndpoint { get; }

/// <inheritdoc/>
public override ExportResultSync Export(in Batch<Activity> batch)
public override ExportResult Export(in Batch<Activity> batch)
{
try
{
Expand All @@ -70,14 +70,14 @@ public override ExportResultSync Export(in Batch<Activity> batch)

this.SendBatchActivityAsync(activities, CancellationToken.None).GetAwaiter().GetResult();

return ExportResultSync.Success;
return ExportResult.Success;
}
catch (Exception ex)
{
ZipkinExporterEventSource.Log.FailedExport(ex);

// TODO distinguish retryable exceptions
return ExportResultSync.Failure;
return ExportResult.Failure;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
[#1087](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1087)
[#1094](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1094)
[#1113](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1113)
[#1127](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1127))
[#1127](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1127)
[#1129](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1129))

## 0.4.0-beta.2

Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void ShutdownEvent(int spansLeftUnprocessed)
}

[Event(3, Message = "Exporter returned error '{0}'.", Level = EventLevel.Warning)]
public void ExporterErrorResult(ExportResultSync exportResult)
public void ExporterErrorResult(ExportResult exportResult)
{
this.WriteEvent(3, exportResult.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="ActivityExporterSync.cs" company="OpenTelemetry Authors">
// <copyright file="ActivityExporter.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,7 +22,7 @@ namespace OpenTelemetry.Trace
/// <summary>
/// Enumeration used to define the result of an export operation.
/// </summary>
public enum ExportResultSync
public enum ExportResult
{
/// <summary>
/// Batch export succeeded.
Expand All @@ -36,16 +36,16 @@ public enum ExportResultSync
}

/// <summary>
/// ActivityExporterSync base class.
/// ActivityExporter base class.
/// </summary>
public abstract class ActivityExporterSync : IDisposable
public abstract class ActivityExporter : IDisposable
{
/// <summary>
/// Export a batch of <see cref="Activity"/> objects.
/// </summary>
/// <param name="batch">Batch of <see cref="Activity"/> objects to export.</param>
/// <returns>Result of export.</returns>
public abstract ExportResultSync Export(in Batch<Activity> batch);
public abstract ExportResult Export(in Batch<Activity> batch);

/// <summary>
/// Shuts down the exporter.
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Trace/BatchExportActivityProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace OpenTelemetry.Trace
/// </summary>
public class BatchExportActivityProcessor : ActivityProcessor
{
private readonly ActivityExporterSync exporter;
private readonly ActivityExporter exporter;
private readonly CircularBuffer<Activity> circularBuffer;
private readonly int scheduledDelayMillis;
private readonly int exporterTimeoutMillis;
Expand All @@ -49,7 +49,7 @@ public class BatchExportActivityProcessor : ActivityProcessor
/// <param name="exporterTimeoutMillis">How long the export can run before it is cancelled. The default value is 30000.</param>
/// <param name="maxExportBatchSize">The maximum batch size of every export. It must be smaller or equal to maxQueueSize. The default value is 512.</param>
public BatchExportActivityProcessor(
ActivityExporterSync exporter,
ActivityExporter exporter,
int maxQueueSize = 2048,
int scheduledDelayMillis = 5000,
int exporterTimeoutMillis = 30000,
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Trace/ReentrantExportActivityProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ namespace OpenTelemetry.Trace
/// </summary>
public class ReentrantExportActivityProcessor : ActivityProcessor
{
private readonly ActivityExporterSync exporter;
private readonly ActivityExporter exporter;
private bool stopped;

/// <summary>
/// Initializes a new instance of the <see cref="ReentrantExportActivityProcessor"/> class.
/// </summary>
/// <param name="exporter">Activity exporter instance.</param>
public ReentrantExportActivityProcessor(ActivityExporterSync exporter)
public ReentrantExportActivityProcessor(ActivityExporter exporter)
{
this.exporter = exporter ?? throw new ArgumentNullException(nameof(exporter));
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/Trace/SimpleExportActivityProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class SimpleExportActivityProcessor : ReentrantExportActivityProcessor
/// Initializes a new instance of the <see cref="SimpleExportActivityProcessor"/> class.
/// </summary>
/// <param name="exporter">Activity exporter instance.</param>
public SimpleExportActivityProcessor(ActivityExporterSync exporter)
public SimpleExportActivityProcessor(ActivityExporter exporter)
: base(exporter)
{
}
Expand Down