Skip to main content
Source: Al0086IncorrectAttributeTypeAnalyzer.cs

Description

OpenTelemetry attributes should use the correct value types as defined by semantic conventions. Using a string where an int is expected degrades query performance.

Bad Code

activity?.SetTag("http.response.status_code", "200"); // string instead of int

Good Code

activity?.SetTag("http.response.status_code", 200);

Properties

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

Configuration

dotnet_diagnostic.AL0086.severity = warning