opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

Update OtlpLogExporterHelperExtensions configuration actions to accept IServiceProvider

Open brnn8r opened this issue 1 year ago • 4 comments

Changes

This extends the extensions methods in OtlpLogExporterHelperExtensions to accept an additional IServiceProvider parameter. This allows for accessing services during configuration of the Log exporter.

Specifically we want to be able to access the IServiceProvider when configuring Func<HttpClient> HttpClientFactory

Merge requirement checklist

  • [ ] CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • [ ] Unit tests added/updated
  • [ ] Appropriate CHANGELOG.md files updated for non-trivial changes
  • [ ] Changes in public API reviewed (if applicable)

brnn8r avatar Apr 18 '24 06:04 brnn8r

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: brnn8r / name: Steve (728fe9d3cc72e3973127083fbc1ce45922b11d6d, 37629412ff92731d1941357355d102b65c43a4a6, cec6c047b9ff12cab68349e576a780c6d0f70301, 6414abd923461147bc37627802ed0ec3d4f012de)

@brnn8r

Could you just do this instead?

services
    .AddOptions<OtlpExporterOptions>()
    .Configure<IServiceProvider>((o, sp) =>
    {
        o.HttpClientFactory = () => sp.GetRequiredService<IHttpClientFactory>().CreateClient("MyOtlpClient");
    });

CodeBlanch avatar Apr 18 '24 17:04 CodeBlanch

@brnn8r

Could you just do this instead?

services
    .AddOptions<OtlpExporterOptions>()
    .Configure<IServiceProvider>((o, sp) =>
    {
        o.HttpClientFactory = () => sp.GetRequiredService<IHttpClientFactory>().CreateClient("MyOtlpClient");
    });

Will give that a go. Thanks!

brnn8r avatar Apr 18 '24 19:04 brnn8r

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

github-actions[bot] avatar Apr 26 '24 03:04 github-actions[bot]

Closed as inactive. Feel free to reopen if this PR is still being worked on.

github-actions[bot] avatar May 03 '24 03:05 github-actions[bot]