> Source: https://www.ymotongpoo.com/works/otel-specs-ja/semconv/non-normative/code-attrs-migration/


# code属性のセマンティック規約の安定性に関する移行ガイド

実験的な`code.*`セマンティック規約は、[v1.33.0](https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.33.0)で安定版に昇格しました。このガイドでは破壊的変更を概説し、安定版の属性を採用する計装やテレメトリーバックエンドに向けた移行方法を示します。

計装の作者は、標準の`OTEL_SEMCONV_STABILITY_OPT_IN`による移行手法を使用してもかまいません（MAY）。使用する場合は、`code`と`code/dup`の値をサポートすべきです。

## 変更点のまとめ

この節では、code属性のセマンティック規約について、[v1.29.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/attributes-registry/code.md)から[v1.33.0](https://github.com/open-telemetry/semantic-conventions/blob/v1.33.0/docs/attributes-registry/code.md)への変更をまとめます。

<!-- prettier-ignore-start -->
| Change                                    | Comments                                      |
| ----------------------------------------- | --------------------------------------------- |
| `code.lineno` &rarr; `code.line.number`   |                                               |
| `code.column` &rarr; `code.column.number` |                                               |
| `code.filepath` &rarr; `code.file.path`   |                                               |
| `code.namespace`                          | Removed, integrated into `code.function.name` |
| `code.function`                           | Removed, integrated into `code.function.name` |
| New: `code.function.name`                 | See definition and examples below             |
<!-- prettier-ignore-end -->

`code.function.name`は次のように定義されています。

> 引数を含まない、メソッドまたは関数の完全修飾名。
> 値は、その言語ランタイムの自然な表現に合致すべきであり、これは`code.stacktrace`属性値内で使われる表現と同一になる可能性が高い。
>
> 例:
>
> * Javaのメソッド: `com.example.MyHttpService.serveRequest`
> * Javaの匿名クラスのメソッド: `com.mycompany.Main$1.myMethod`
> * Javaのラムダメソッド: `com.mycompany.Main$$Lambda/0x0000748ae4149c00.myMethod`
> * PHPの関数: `GuzzleHttp\Client::transfer`
> * Goの関数: `github.com/my/repo/pkg.foo.func5`
> * Elixir: `OpenTelemetry.Ctx.new`
> * Erlang: `opentelemetry_ctx:new`
> * Rust: `playground::my_module::my_cool_func`
> * C言語の関数: `fopen`

