Skip to content

fix(collector): resolve CS9153 + CS9207 interceptor collisions (broken main) - #439

Merged
ANcpLua merged 3 commits into
mainfrom
fix/collector-build-interceptor-collision
Jun 30, 2026
Merged

fix(collector): resolve CS9153 + CS9207 interceptor collisions (broken main)#439
ANcpLua merged 3 commits into
mainfrom
fix/collector-build-interceptor-collision

Conversation

@ANcpLua

@ANcpLua ANcpLua commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

main's Backend (.NET) Release build was broken: services/qyl.collector failed to compile because the OTel auto-instrumentation generator collided with qyl's ServiceDefaults generator at Program.cs's builder.Build(). Root-causing revealed two distinct interceptor errors, both introduced by cde22004 (the bump to OTel 3.1.0), only one of which had been diagnosed:

Error Cause Fix
CS9153 — call intercepted multiple times Both ServiceDefaults and the OTel generator intercept WebApplicationBuilder.Build() ServiceDefaults owns Build() and composes QylInterceptedAspNetCore.Build; OTel opted out via QylAutoInstrumentationInterceptWebApplicationBuilderBuild=false
CS9207 — cannot intercept a non-ordinary member The OTel generator emitted a RequestDelegate.Invoke interceptor for middleware next(context) hops, which are delegate invocations the C# interceptors feature cannot intercept OTel generator now guards the matcher on MethodKind.Ordinary

Both fixes ship in OTel 3.1.2 (this PR only bumps the pin; the generator work landed upstream):

Changes in this PR

  • internal/qyl.instrumentation.generators/…/ServiceDefaultsSourceGenerator.cs — detect OTel and compose its Build wrapper; ServiceDefaults becomes the single Build() interceptor. (commit 41f948ad)
  • services/qyl.collector/qyl.collector.csproj — set QylAutoInstrumentationInterceptWebApplicationBuilderBuild=false. (commit 41f948ad)
  • Directory.Packages.props — pin Qyl.OpenTelemetry.AutoInstrumentation 3.1.0 → 3.1.2. (commit 541bac80)

Verification (complete & verified)

  • 3.1.2 confirmed published and indexed on nuget.org; a clean-cache dotnet restore resolves it from https://api.nuget.org/v3/index.json (not a local feed).
  • dotnet build services/qyl.collector -c Release0 warnings, 0 errors (both CS9153 and CS9207 gone).
  • ✅ Health endpoints preserved — the generated ServiceDefaults interceptor still calls RegisterQylHealthChecks + MapQylDefaultEndpoints around the composed OTel Build().

🤖 Generated with Claude Code

ANcpLua and others added 2 commits June 30, 2026 03:25
…CS9153

qyl.collector ran two interceptor generators that both targeted
WebApplicationBuilder.Build(): ServiceDefaults (DI/hosted/health/endpoints) and
Qyl.OpenTelemetry.AutoInstrumentation (OTel middleware). C# forbids two
interceptors per call site, so the Release build failed with CS9153.

Make ServiceDefaults the single owner of Build() and compose the OTel wrapper:
- ServiceDefaultsSourceGenerator detects Qyl.OpenTelemetry.AutoInstrumentation
  (via QylInterceptedAspNetCore) and routes its Build() interceptor through
  QylInterceptedAspNetCore.Build(builder) (build + OTel middleware) instead of
  builder.Build(); without the package it builds the host directly (unchanged).
- qyl.collector sets QylAutoInstrumentationInterceptWebApplicationBuilderBuild=false
  so the OTel generator yields Build() to ServiceDefaults.

Requires Qyl.OpenTelemetry.AutoInstrumentation 3.1.1 (adds the opt-out). Version
pin bump is gated on 3.1.1 indexing on nuget.org — WIP until then.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lves CS9153 + CS9207)

Bump the OTel auto-instrumentation pin to 3.1.2, which carries both fixes the collector
build needs:
  - #16 (3.1.1): WebApplicationBuilder.Build() interceptor opt-out, so ServiceDefaults
    owns Build() and composes QylInterceptedAspNetCore.Build — resolves CS9153.
  - #17 (3.1.2): the generator no longer emits an un-interceptable RequestDelegate.Invoke
    interceptor for hand-written middleware next(context) hops — resolves CS9207.

Verified: a clean-cache restore resolves 3.1.2 from nuget.org (not a local feed), and
`dotnet build services/qyl.collector -c Release` succeeds with 0 warnings / 0 errors.
Health endpoints preserved — ServiceDefaults still registers health checks and maps
MapQylDefaultEndpoints around the composed OTel Build().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b08e5034-ec1e-4dde-847e-983deecce6d2

📥 Commits

Reviewing files that changed from the base of the PR and between ccf0aeb and 541bac8.

⛔ Files ignored due to path filters (3)
  • internal/qyl.instrumentation.generators/GeneratorPipelineHelpers.cs is excluded by none and included by none
  • internal/qyl.instrumentation.generators/ServiceDefaultsSourceGenerator.cs is excluded by none and included by none
  • services/qyl.collector/qyl.collector.csproj is excluded by none and included by none
📒 Files selected for processing (1)
  • Directory.Packages.props
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Dependency Audit
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{cs,csx,csproj,props}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

.NET code must have nullable enabled.

Files:

  • Directory.Packages.props
**/Directory.Packages.props

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use central package management via Directory.Packages.props.

Files:

  • Directory.Packages.props
**

⚙️ CodeRabbit configuration file

AGENTS.md

**:

10.0.9
10.7.0
10.7.0
1.16.0
1.15.1
1.5.3
3.35.1
2.80.0
2.81.1

2.2.27
1.11.0

<!-- MAF (Microsoft.Agents.AI.*) — mirrors SDK truth; inlined so the repo builds with or without the sibling SDK checkout. -->
<MicrosoftAgentsAIVersion>1.11.0</MicrosoftAgentsAIVersion>
<MicrosoftAgentsAIHostingVersion>1.11.0-preview.260623.1</MicrosoftAgentsAIHostingVersion>

<NukeVersion>10.1.0</NukeVersion>
<SpectreConsoleVersion>0.57.0</SpectreConsoleVersion>
<VersionizeVersion>2.5.0</VersionizeVersion>

**:

<Import Project="$(MSBuildThisFileDirectory)../framework/ANcpLua.NET.Sdk/src/Build/Common/Version.props"
...

Files:

  • Directory.Packages.props
**/*.props

⚙️ CodeRabbit configuration file

MSBuild property files (Directory.Build.props, Directory.Packages.props, Version.props). Review for: Central Package Management correctness, version consistency, and that new packages are added with explicit version pins. Flag transitive dependency promotions that aren't justified. Verify TFM targeting is correct (.NET 10).

Files:

  • Directory.Packages.props
🔇 Additional comments (1)
Directory.Packages.props (1)

77-77: LGTM!


Summary by CodeRabbit

  • Chores
    • Updated an underlying telemetry package to the latest patch version, bringing minor improvements and stability fixes.

Walkthrough

Qyl.OpenTelemetry.AutoInstrumentation is version-bumped from 3.1.0 to 3.1.2 in Directory.Packages.props. No other changes.

Package Version Bump

Layer / File(s) Summary
Central package version update
Directory.Packages.props
Qyl.OpenTelemetry.AutoInstrumentation bumped from 3.1.0 to 3.1.2.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested labels

area:infra


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Title check ❌ Error The title matches the fix, but it violates the required scope set and exceeds 72 characters. Use an allowed scope such as infra, keep it under 72 characters, and retain the conventional-commit format.
✅ Passed checks (7 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the build break, the generator fixes, and the package bump.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Otel Instrumentation Required ✅ Passed The PR only adds a source generator plus config/package pinning; no new DI-registered service class appears in the diff.
No Unbounded Mcp Responses ✅ Passed No files under src/qyl.mcp/ were changed, and that path does not exist in this checkout.
Duckdb Backpressure On Write Paths ✅ Passed PR only changes the OTel package pin; no new DuckDB write path was added. Existing DuckDbStore already uses a bounded Channel and TryWrite backpressure.
Cancellationtoken Threading ✅ Passed No new public async methods were added in the PR scope; the touched generator file has no public async APIs, and the only actual change is a package pin.

Comment @coderabbitai help to get the list of available commands.

@railway-app

railway-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

🚅 Deployed to the qyl-pr-439 environment in qyl

Service Status Web Updated (UTC)
qyl-collector 🕛 Waiting for status checks (View Logs) Web Jun 30, 2026 at 2:16 am

@ANcpLua
ANcpLua enabled auto-merge (squash) June 30, 2026 02:44
@ANcpLua
ANcpLua disabled auto-merge June 30, 2026 02:44
@ANcpLua
ANcpLua enabled auto-merge (squash) June 30, 2026 02:44
The Backend (.NET) job cached ~/.nuget/packages via setup-dotnet, keyed on dependency
files including Directory.Packages.props. On the self-hosted runner that folder already
persists on local disk between jobs, so the cache is redundant — and this PR's pin bump
changed the key, forcing a post-job tar+upload of the accumulated 8.1 GB global packages
folder (~17 min at ~5 MB/s) that serialized the whole PR (Frontend queued behind it).
Disable the cache; restore stays fast from local disk.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ANcpLua
ANcpLua merged commit 78d1435 into main Jun 30, 2026
5 checks passed
@ANcpLua
ANcpLua deleted the fix/collector-build-interceptor-collision branch June 30, 2026 03:02
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.

1 participant