Code

代码属性

这些属性提供了关于源代码的上下文

Attributes

StabilityValue Type描述Example Values
code.column.numberStableintcode.file.path 中最能代表操作的列号。它应该指向 code.function.name 中命名的代码单元。由于 Profile 信号中的数据已在“message Line”中捕获,因此不得在此信号上使用此属性。强制执行此约束是为了防止冗余并维护数据完整性。16
code.file.pathStable字符串源代码文件名,用于尽可能唯一地标识代码单元(最好是绝对文件路径)。由于 Profile 信号中的数据已在“message Function”中捕获,因此不得在此信号上使用此属性。强制执行此约束是为了防止冗余并维护数据完整性。/usr/local/MyApplication/content_root/app/index.php
code.function.nameStable字符串方法或函数的完全限定名称,不含参数。该值应适合语言运行时的自然表示,这也可能与 code.stacktrace 属性值中使用的相同。由于 Profile 信号中的数据已在“message Function”中捕获,因此不得在此信号上使用此属性。强制执行此约束是为了防止冗余并维护数据完整性。[1]com.example.MyHttpService.serveRequest; GuzzleHttp\Client::transfer; fopen
code.line.numberStableintcode.file.path 中最能代表操作的行号。它应该指向 code.function.name 中命名的代码单元。由于 Profile 信号中的数据已在“message Line”中捕获,因此不得在此信号上使用此属性。强制执行此约束是为了防止冗余并维护数据完整性。42
code.stacktraceStable字符串一个堆栈跟踪字符串,采用语言运行时的自然表示。其表示与 exception.stacktrace 相同。由于 Profile 信号中的数据已在“message Location”中捕获,因此不得在此信号上使用此属性。强制执行此约束是为了防止冗余并维护数据完整性。at com.example.GenerateTrace.methodB(GenerateTrace.java:13)\n at com.example.GenerateTrace.methodA(GenerateTrace.java:9)\n at com.example.GenerateTrace.main(GenerateTrace.java:5)

[1] code.function.name: 值和格式取决于每种语言运行时,因此无法提供详尽的示例列表。值通常与 code.stacktrace 中存储的本机堆栈跟踪表示中的值相同(或为其前缀),且不包含参数信息。

示例

  • Java 方法: com.example.MyHttpService.serveRequest
  • Java 匿名类方法: com.mycompany.Main$1.myMethod
  • Java Lambda 方法: 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

已弃用的代码属性

这些已弃用的属性提供了关于源代码的上下文

Attributes

StabilityValue Type描述Example Values
code.columnDeprecated
已替换为 code.column.number
int已弃用,请使用 code.column.number16
code.filepathDeprecated
已替换为 code.file.path
字符串已弃用,请使用 code.file.path 代替/usr/local/MyApplication/content_root/app/index.php
code.functionDeprecated
值应包含在 code.function.name 中,后者应为完全限定名称。
字符串已弃用,请使用 code.function.name 代替serveRequest
code.linenoDeprecated
已替换为 code.line.number
int已弃用,请使用 code.line.number 代替42
code.namespaceDeprecated
值应包含在 code.function.name 中,后者应为完全限定名称。
字符串已弃用,命名空间现在包含在 code.function.namecom.example.MyHttpService