Skip to main content
Source: Al0109NonInterceptableTracedAnalyzer.cs

Description

The source generator that implements [Traced] instrumentation works by intercepting method calls. Abstract methods, extern methods, and partial definition methods cannot be intercepted, so [Traced] on them has no effect.

Bad Code

public abstract class BaseService
{
    [Traced("MyApp")]
    public abstract void ProcessAsync();  // Cannot be intercepted
}

Good Code

// Apply [Traced] at class level instead — concrete overrides get traced
[Traced("MyApp")]
public abstract class BaseService
{
    public abstract void ProcessAsync();
}

Properties

  • Category: OpenTelemetry
  • Severity: Warning
  • Enabled by default: True
  • Code fix available: True

Configuration

dotnet_diagnostic.AL0109.severity = warning