Skip to content

Commit

Permalink
Applied the dependency injection pattern to OtlpExporter (#1942)
Browse files Browse the repository at this point in the history
* Applied the dependency injection pattern to OtlpExporter.

* Changelog update.
  • Loading branch information
CodeBlanch authored Mar 29, 2021
1 parent 5bf2b42 commit efe2d96
Show file tree
Hide file tree
Showing 5 changed files with 31 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
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ please check the latest changes
[spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md).
([#1919](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1919))

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

## 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 efe2d96

Please sign in to comment.