> ## Documentation Index
> Fetch the complete documentation index at: https://ancplua.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AL0087 - Prefer constant attribute

> Use constant fields instead of string literals for attribute names

Source: [Al0087PreferConstantAttributeAnalyzer.cs](https://github.com/ANcpLua/ANcpLua.Analyzers/blob/main/src/ANcpLua.Analyzers/Analyzers/Al0087PreferConstantAttributeAnalyzer.cs)

## Description

Attribute names used in `SetTag()` calls should reference constant fields instead of string literals to prevent typos and enable refactoring.

## Bad Code

```csharp theme={null}
activity?.SetTag("http.request.method", method);
activity?.SetTag("http.response.status_code", statusCode);
```

## Good Code

```csharp theme={null}
activity?.SetTag(SemanticConventions.HttpRequestMethod, method);
activity?.SetTag(SemanticConventions.HttpResponseStatusCode, statusCode);
```

## Properties

* **Category**: OpenTelemetry
* **Severity**: Info
* **Enabled by default**: True
* **Code fix available**: False

## Configuration

```editorconfig theme={null}
dotnet_diagnostic.AL0087.severity = suggestion
```
