Skip to content

Commit

Permalink
Applied the dependency injection pattern to OtlpExporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Mar 27, 2021
1 parent 5bf2b42 commit e5cf486
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

* When using OpenTelemetry.Extensions.Hosting you can now bind
`JaegerExporterOptions` to `IConfiguration` using the `Configure` extension
(ex:
`services.Configure<JaegerExporterOptions>(this.Configuration.GetSection("Jaeger"));`).
([#1889](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1889))

## 1.1.0-beta1

Released 2021-Mar-19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PooledList.cs" Link="Includes\PooledList.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ServiceProviderExtensions.cs" Link="Includes\ServiceProviderExtensions.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ public static TracerProviderBuilder AddOtlpExporter(this TracerProviderBuilder b
throw new ArgumentNullException(nameof(builder));
}

var exporterOptions = new OtlpExporterOptions();
if (builder is IDeferredTracerProviderBuilder deferredTracerProviderBuilder)
{
return deferredTracerProviderBuilder.Configure((sp, builder) =>
{
AddOtlpExporter(builder, sp.GetOptions<OtlpExporterOptions>(), configure);
});
}

return AddOtlpExporter(builder, new OtlpExporterOptions(), configure);
}

private static TracerProviderBuilder AddOtlpExporter(TracerProviderBuilder builder, OtlpExporterOptions exporterOptions, Action<OtlpExporterOptions> configure = null)
{
configure?.Invoke(exporterOptions);
var otlpExporter = new OtlpTraceExporter(exporterOptions);

Expand Down
6 changes: 6 additions & 0 deletions src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

* When using OpenTelemetry.Extensions.Hosting you can now bind
`JaegerExporterOptions` to `IConfiguration` using the `Configure` extension
(ex:
`services.Configure<ZipkinExporterOptions>(this.Configuration.GetSection("Zipkin"));`).
([#1889](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1889))

## 1.1.0-beta1

Released 2021-Mar-19
Expand Down

0 comments on commit e5cf486

Please sign in to comment.