> Source: https://www.ymotongpoo.com/works/otel-specs-ja/semconv/dotnet/dotnet-dns-metrics/


# .NETが発行するDNSメトリクスに関するセマンティック規約

**ステータス**: [Stable][DocumentStatus]

この記事では、.NETが発行するDNSメトリクスに関するセマンティック規約を定義します。

## DNSメトリクス

### メトリクス: `dns.lookup.duration`

このメトリクスは、`[ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ]` の[`ExplicitBucketBoundaries` advisoryパラメータ](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.59.0/specification/metrics/api.md#instrument-advisory-parameters)を指定すべきです（SHOULD）。

<!-- Tables in this document are not auto-generated and are intentionally frozen in time. From the .NET perspective this metric and its attributes are stable till the next major version. They are still experimental in the OpenTelemetry. -->
| Name | Instrument Type | Unit (UCUM) | Description |
| ---- | --------------- | ----------- | ----------- |
| `dns.lookup.duration` | Histogram | `s` | DNSルックアップの実行に要した時間を計測します。[1] |

**[1]:** Meterの名前: `System.Net.NameResolution`; 追加されたバージョン: .NET 8.0

| Attribute | Type | Description | Examples | Requirement Level |
| --- | --- | --- | --- | --- |
| `dns.question.name` | string | クエリの対象となる名前。[1] | `www.example.com`; `dot.net` | Required |
| [`error.type`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/error/) | string | 解決エラーのいずれか、または例外型の完全な名前。[2] | `host_not_found`; `no_recovery`; `System.Net.Sockets.SocketException` | Conditionally Required: if and only if an error has occurred. |

**[1]:** クエリの対象となる名前です。
name フィールドに印字不可能な文字（32未満または126超）が含まれる場合、それらの文字はエスケープされた10進整数（\DDD）として表現されるべきです。バックスラッシュと引用符はエスケープされるべきです。タブ、キャリッジリターン、ラインフィードは、それぞれ\t、\r、\nに変換されるべきです。

**[2]:** 次のエラーコードが報告されます。

- "host_not_found"
- "try_again"
- "address_family_not_supported"
- "no_recovery"

詳細は[SocketError](https://learn.microsoft.com/dotnet/api/system.net.sockets.socketerror)を参照してください。

`error.type`には、次のよく知られた値の一覧があります。これらのいずれかが該当する場合は、対応する値を使用しなければならず、そうでない場合は、独自の値を使用してもかまいません。

| Value | Description |
| --- | --- |
| `_OTHER` | 計装が独自の値を定義していない場合に使用するフォールバック用のエラー値。 |

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status

