Skip to content

Add OpenTelemetry forwarder infrastructure#9136

Open
rajkumar-rangaraj wants to merge 4 commits intomainfrom
rajrang/otel-infrastructure
Open

Add OpenTelemetry forwarder infrastructure#9136
rajkumar-rangaraj wants to merge 4 commits intomainfrom
rajrang/otel-infrastructure

Conversation

@rajkumar-rangaraj
Copy link
Copy Markdown

Summary

Adds the infrastructure for OpenTelemetry out-of-process forwarder integration. This is PR 1 of 6 see #9135 for the full feature overview.

Changes

  • Directory.Packages.props Added OpenTelemetry.OutOfProcess.Forwarder.Configuration 0.1.0-beta.1 package version
  • dotnet-monitor.csproj Conditional package reference and BUILDING_OTEL preprocessor define, both gated on ENABLE_OTEL MSBuild property
  • generate-dev-sln.ps1 Set ENABLE_OTEL=true for dev builds; fix missing newline at EOF

How it works

When ENABLE_OTEL is set (to any non-empty value), the build:

  1. Adds a PackageReference to OpenTelemetry.OutOfProcess.Forwarder.Configuration
  2. Defines the BUILDING_OTEL constant for conditional compilation

All subsequent OTel code will be guarded with #if BUILDING_OTEL, ensuring zero impact on the default build.

Testing

  • Build without ENABLE_OTEL: no change in behavior, package not referenced
  • Build with ENABLE_OTEL=true: package restored, BUILDING_OTEL defined

- Add OpenTelemetry.OutOfProcess.Forwarder.Configuration 0.1.0-beta.1 package version
- Add ENABLE_OTEL conditional compilation: when set, adds package reference and
  defines BUILDING_OTEL preprocessor symbol
- Set ENABLE_OTEL in generate-dev-sln.ps1 for dev builds
- Fix missing newline at end of generate-dev-sln.ps1
</ItemGroup>

<ItemGroup Condition="'$(ENABLE_OTEL)' != ''">
<PackageReference Include="OpenTelemetry.OutOfProcess.Forwarder.Configuration" />
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.

How large is this package and its dependencies? If it's not very big, maybe we can reference it unconditionally.

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.

image

Both the current and dependent packages together are small, < 100KB.

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.

Let's just add these unconditionally then. Otherwise, we'll have to have two builds. We may need to add this package to the central feed.

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.

Updated the PR to reference the package unconditionally and removed the ENABLE_OTEL gating.

Regarding the central feed, I may not have access to add the package there. Could you help with that, or point me to who can?

<PackageReference Include="OpenTelemetry.OutOfProcess.Forwarder.Configuration" />
</ItemGroup>

<ItemGroup Condition="'$(DIAGNOSTICS_REPO_ROOT)' == ''">
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.

I want to confirm the target branch of .NET 10+. You will not need this in 8 or 9 correct?

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.

That's right. Please note that OpenTelemetry.OutOfProcess.Forwarder.Configuration is currently built with net9.0. In the upcoming beta, it will be updated to net10.

image

Address review feedback: remove ENABLE_OTEL gating so the package
is always referenced and BUILDING_OTEL is always defined, avoiding
the need for two separate builds.
@rajkumar-rangaraj rajkumar-rangaraj force-pushed the rajrang/otel-infrastructure branch from 9fe18aa to f52f7cd Compare April 3, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants