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

more docs #318

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -30,18 +30,26 @@

namespace OpenTelemetry.Exporter.ApplicationInsights
{
/// <summary>
/// Applicaiton Insights trace exporter.
/// </summary>
public class ApplicationInsightsTraceExporter : SpanExporter, IDisposable
{
private readonly TelemetryClient telemetryClient;
private readonly string serviceEndpoint;

/// <summary>
/// Initializes a new instance of the <see cref="ApplicationInsightsTraceExporter"/> class.
/// </summary>
/// <param name="telemetryConfiguration">Telemetry configuration to use.</param>
public ApplicationInsightsTraceExporter(TelemetryConfiguration telemetryConfiguration)
{
this.telemetryClient = new TelemetryClient(telemetryConfiguration);
this.telemetryClient.Context.GetInternalContext().SdkVersion = "ot:" + GetAssemblyVersion();
this.serviceEndpoint = telemetryConfiguration.TelemetryChannel.EndpointAddress;
}

/// <inheritdoc/>
public override Task<ExportResult> ExportAsync(IEnumerable<Span> spanDataList, CancellationToken cancellationToken)
{
foreach (var span in spanDataList)
Expand Down Expand Up @@ -289,13 +297,15 @@ public override Task<ExportResult> ExportAsync(IEnumerable<Span> spanDataList, C
return Task.FromResult(ExportResult.Success);
}

/// <inheritdoc/>
public override Task ShutdownAsync(CancellationToken cancellationToken)
{
// TODO cancellation support
this.telemetryClient.Flush();
return Task.CompletedTask;
}

/// <inheritdoc/>
public void Dispose()
{
this.ShutdownAsync(CancellationToken.None).ContinueWith(_ => { }).Wait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<Description>Application Insights exporter for Open Telemetry.</Description>
<PackageTags>$(PackageTags);application-insights;azure;distributed-tracing</PackageTags>
</PropertyGroup>
<PropertyGroup>
<NoWarn>$(NoWarn),1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@

namespace OpenTelemetry.Trace.Configuration
{
/// <summary>
/// Extension methods to simplify registering of Application Insights exporter.
/// </summary>
public static class TracerBuilderExtensions
{
/// <summary>
/// Enables Application Insights exporter.
/// </summary>
/// <param name="builder">Trace builder to use.</param>
/// <param name="configure">Configuration options.</param>
/// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
public static TracerBuilder UseApplicationInsights(this TracerBuilder builder, Action<TelemetryConfiguration> configure)
{
if (builder == null)
Expand All @@ -42,6 +51,13 @@ public static TracerBuilder UseApplicationInsights(this TracerBuilder builder, A
.SetExportingProcessor(e => new BatchingSpanProcessor(e)));
}

/// <summary>
/// Enables Application Insights exporter.
/// </summary>
/// <param name="builder">Trace builder to use.</param>
/// <param name="applicationInsightsConfigure">Configuration options.</param>
/// <param name="processorConfigure">Span processor configuration.</param>
/// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
public static TracerBuilder UseApplicationInsights(this TracerBuilder builder, Action<TelemetryConfiguration> applicationInsightsConfigure, Action<
SpanProcessorPipelineBuilder> processorConfigure)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<IncludeSymbols>True</IncludeSymbols>
<PackageTags>$(PackageTags);Stackdriver;Google;GCP;distributed-tracing</PackageTags>
</PropertyGroup>
<PropertyGroup>
<NoWarn>$(NoWarn),1591</NoWarn>
</PropertyGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))/build/OpenTelemetry.prod.loose.ruleset</CodeAnalysisRuleSet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ static StackdriverTraceExporter()
}
}

/// <summary>
/// Initializes a new instance of <see cref="StackdriverTraceExporter"/> class.
/// </summary>
/// <param name="projectId">Project ID to send telemetry to.</param>
public StackdriverTraceExporter(string projectId)
{
this.googleCloudProjectId = new Google.Api.Gax.ResourceNames.ProjectName(projectId);
Expand All @@ -71,6 +75,7 @@ public StackdriverTraceExporter(string projectId)
this.traceServiceSettings.CallSettings = callSettings;
}

/// <inheritdoc/>
public override async Task<ExportResult> ExportAsync(IEnumerable<Trace.Span> spanDataList, CancellationToken cancellationToken)
{
var traceWriter = TraceServiceClient.Create(settings: this.traceServiceSettings);
Expand All @@ -89,6 +94,7 @@ public override async Task<ExportResult> ExportAsync(IEnumerable<Trace.Span> spa
return ExportResult.Success;
}

/// <inheritdoc/>
public override Task ShutdownAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<PackageTags>$(PackageTags);Zipkin;distributed-tracing</PackageTags>
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn),1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
Expand Down
16 changes: 16 additions & 0 deletions src/OpenTelemetry.Exporter.Zipkin/TracerBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@

namespace OpenTelemetry.Trace.Configuration
{
/// <summary>
/// Extension methods to simplify registering of Zipkin exporter.
/// </summary>
public static class TracerBuilderExtensions
{
/// <summary>
/// Registers Zipkin exporter.
/// </summary>
/// <param name="builder">Trace builder to use.</param>
/// <param name="configure">Configuration options.</param>
/// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
public static TracerBuilder UseZipkin(this TracerBuilder builder, Action<ZipkinTraceExporterOptions> configure)
{
if (builder == null)
Expand All @@ -41,6 +50,13 @@ public static TracerBuilder UseZipkin(this TracerBuilder builder, Action<ZipkinT
.SetExportingProcessor(e => new BatchingSpanProcessor(e)));
}

/// <summary>
/// Registers Zipkin exporter.
/// </summary>
/// <param name="builder">Trace builder to use.</param>
/// <param name="zipkinConfigure">Configuration options.</param>
/// <param name="processorConfigure">Span processor configuration.</param>
/// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
public static TracerBuilder UseZipkin(this TracerBuilder builder, Action<ZipkinTraceExporterOptions> zipkinConfigure, Action<
SpanProcessorPipelineBuilder> processorConfigure)
{
Expand Down
10 changes: 10 additions & 0 deletions src/OpenTelemetry.Exporter.Zipkin/ZipkinTraceExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

namespace OpenTelemetry.Exporter.Zipkin
{
/// <summary>
/// Zipkin exporter.
/// </summary>
public class ZipkinTraceExporter : SpanExporter
{
private const long MillisPerSecond = 1000L;
Expand All @@ -43,6 +46,11 @@ public class ZipkinTraceExporter : SpanExporter
private readonly HttpClient httpClient;
private readonly string serviceEndpoint;

/// <summary>
/// Initializes a new instance of the <see cref="ZipkinTraceExporter"/> class.
/// </summary>
/// <param name="options">Configuration options.</param>
/// <param name="client">Http client to use to upload telemetry.</param>
public ZipkinTraceExporter(ZipkinTraceExporterOptions options, HttpClient client = null)
{
this.options = options;
Expand All @@ -51,6 +59,7 @@ public ZipkinTraceExporter(ZipkinTraceExporterOptions options, HttpClient client
this.serviceEndpoint = options.Endpoint?.ToString();
}

/// <inheritdoc/>
public override async Task<ExportResult> ExportAsync(IEnumerable<Span> otelSpanList, CancellationToken cancellationToken)
{
var zipkinSpans = new List<ZipkinSpan>();
Expand Down Expand Up @@ -96,6 +105,7 @@ public override async Task<ExportResult> ExportAsync(IEnumerable<Span> otelSpanL
}
}

/// <inheritdoc/>
public override Task ShutdownAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
Expand Down