Skip to content

Update exporter extension DI sample#7302

Open
omribz156 wants to merge 3 commits into
open-telemetry:mainfrom
omribz156:codex/otel-dotnet-exporter-di-docs
Open

Update exporter extension DI sample#7302
omribz156 wants to merge 3 commits into
open-telemetry:mainfrom
omribz156:codex/otel-dotnet-exporter-di-docs

Conversation

@omribz156
Copy link
Copy Markdown

Fixes #4128.

Updates the MyExporterExtensions sample so it demonstrates the dependency-injection-aware registration pattern described in the same guide.

Changes:

  • adds named options support to AddMyExporter
  • configures exporter options through TracerProviderBuilder.ConfigureServices
  • creates the processor through the AddProcessor(serviceProvider => ...) factory overload
  • references OpenTelemetry.Api.ProviderBuilderExtensions from the sample project so the DI builder extensions are available

Verification:

  • git diff --check
  • dotnet --version could not run because this checkout requires SDK 10.0.300 via global.json, and no compatible .NET SDK is installed locally.

This was implemented with Codex assistance, with the final diff reviewed manually and kept to the exporter registration docs sample.

@omribz156 omribz156 requested a review from a team as a code owner May 17, 2026 09:21
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 17, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

@github-actions github-actions Bot added the documentation Documentation related label May 17, 2026
Comment thread docs/trace/extending-the-sdk/MyExporterExtensions.cs Outdated
Comment thread docs/trace/extending-the-sdk/extending-the-sdk.csproj Outdated
@martincostello
Copy link
Copy Markdown
Member

The human behind this PR needs to sign the CLA.

internal static class MyExporterExtensions
{
public static TracerProviderBuilder AddMyExporter(this TracerProviderBuilder builder)
public static TracerProviderBuilder AddMyExporter(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider adding an overload method, so anyone who needs a simpler option can use the current implementation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes — I added a follow-up commit that keeps the simple AddMyExporter() overload on the original direct processor path, and makes the DI/options path explicit through overloads that take Action<MyExporterOptions> (optionally with a name).

Verification: git diff --check passes. Full dotnet verification is still blocked locally because this checkout pins SDK 10.0.300 in global.json, and no compatible SDK is installed here.

This follow-up was Codex-assisted, with the final diff reviewed before pushing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] Missing the DI support in Exporter registration method

3 participants