说明:
以下加粗字体为目前正在使用中的字段。
Span 基础字段
字段名 | 类型 | 参数说明 | 例子 | 是否必要 | 需要手动埋点 |
Name | string | 调用操作 (接口名/执行语句等) | /api/v1/auth | 是 | - |
TraceId | bytes | 链路 ID | e4a230f901100099f3bf34faf75284c4 | 是 | - |
SpanId | bytes | SpanID | 5053f7cfe6dc50c1 | 是 | - |
TraceState | string | "" | 否 | - | |
SpanKind | int | 包括以下类型:
0(未定义 Span)
1(内部 Span)
2(服务端侧 Span)
3(客户端侧 Span)
4(生产者 Span)
5(消费者 Span) | 2 | 是 | - |
StartTime | int64 | 开始时间戳 | 1692693930485000000 | 是 | - |
EndTime | int64 | 结束时间戳 | 1692693930485000000 | 是 | - |
Status.Code | string | 包括以下类型: Unset(未定义) Ok(正常) Error(异常) | Unset | 是 | - |
ParentSpanId | bytes | 父 Span ID | 5053f7cfe6dc50c1 | 否 | - |
Attributes | []KeyValue | span标签 | "" | 否 | - |
通用标签
字段名 | 类型 | 参数说明 | 例子 | 是否必要 | 需要手动上报 | 手动埋点位置 |
service.name | string | 当前服务名 | tapm-api | 是 | 1 | resource.attributes |
service.instance | string | 当前服务实例 | 127.0.0.1 | 是 | 1 | resource.attributes |
component | string | 组件类型 | http | 是 | - | - |
token | string | apm 鉴权 | xxx | 是 | - | - |
net.host.name | string | Host端名称 | gin-demo | 否 | 1 | span.attributes |
net.host.port | string | 请求端口 | 8080 | 否 | - | - |
net.sock.peer.addr | string | 远端服务端地址 | ::1 | 否 | - | - |
net.sock.peer.port | string | 远端服务端口 | 57719 | 否 | - | - |
net.peer.ip | string | IPv4 地址 | 127.0.0.1 | 否 | - | - |
net.peer.port | int | 当前实例端口 | 8080 | 否 | - | - |
sampling.priorty | int | 采样策略 | 1 | 否 | - | - |
peer.instance | string | 远端服务实例 | HTTP→ip+port | 否 | - | - |
peer.service | string | 远端服务名 | tapm-collector | 否 | - | - |
peer.address | string | 远端地址 | 127.0.0.1:8080 | 否 | - | - |
peer.hostname | string | 远端域名 | opentracing.io | 否 | - | - |
peer.ipv6 | string | IPv6 地址 | 2001:0db8:85a3:0000:0000:8a2e:0370:7334 | 否 | - | - |
peer.port | int | 远端端口 | 8080 | 否 | - | - |
Http 服务
http.*
字段名 | 类型 | 参数说明 | 例子 | 是否必要 | 需要手动埋点 | 手动埋点位置 |
http.status_code | int | Http 返回状态码 | 200 | 是 | - | - |
http.scheme | string | URL 协议 | https | 是 | - | - |
http.flavor | string | Http 协议版本 | 1.0 | 是 | - | - |
http.method | string | Http 方法 | GET | 是 | - | - |
http.route | string | 请求路由映射 | /users | 是 | - | - |
http.url | string | 完整请求地址 | https://domain.net/path/to?resource=here | 否 | - | - |
http.target | string | 请求地址 URL | /path/to?resource=here | 否 | - | - |
http.host | string | 请求域名 IP 地址+host | domain.net | 否 | - | - |
http.user_agent | string | CERN-LineMode/2.15 | 否 | - | - | |
http.request_content_length | int | 请求体长度(压缩后) | 3495 | 否 | - | - |
http.request_content_length_uncompressed | int | 请求体长度(未压缩) | 5493 | 否 | - | - |
http.response_content_length | int | 返回体长度(压缩后) | 3495 | 否 | - | - |
http.response_content_length_uncompressed | int | 返回体长度(未压缩) | 5493 | 否 | - | - |
http.server_name | string | 服务名 | example.com | 否 | - | - |
http.client_ip | string | 客户端地址 | 83.164.160.102 | 否 | - | - |
Rpc 服务
rpc.*
字段名 | 类型 | 参数说明 | 例子 | 是否必要 | 需要手动上报 | 手动埋点位置 |
rpc.method | string | 接口方法名 | SayHello | 是 | - | span.attributes |
rpc.service | string | 接口服务名 | proto.HelloService | 是 | - | span.attributes |
rpc.system | string | RPC 系统 | gRPC | 是 | - | span.attributes |
rpc.grpc.status_code | int | gRPC 调用状态码 | 0 | 是 | - | span.attributes |
数据库组件(Redis)
db.* / db.{DB.System}.*
字段名 | 类型 | 参数说明 | 例子 | 是否必要 | 需要手动上报 | 手动埋点位置 |
db.instance | string | 数据库实例名 | customers | 是 | - | span.attributes |
db.statement | string | 执行语句 | select * from user | 是 | - | span.attributes |
db.system | string | 数据库类型包括: mysql redis
mongodb
memcached
postgresql
oracle
clickhouse | mysql | 是 | - | span.attributes |
db.user | string | 数据库用户名 | root | 否 | 1 | span.attributes |
db.operation | string | 数据库操作 | SELECT | 建议 | 1 | span.attributes |
db.ip | string | 数据库 IP | 127.0.0.1 | 建议 | 1 | span.attributes |
db.port | string | 数据库端口号 | 3306 | 否 | 1 | span.attributes |
异常标签
exception.* / error.*
字段名 | 类型 | 参数说明 | 例子 | 是否必要 | 需要手动埋点 | 手动埋点位置 |
error.kind | string | 错误类型 | error | 否 | 1 | span.attributes |
error.object | string | 错误对象 | java.lang.UnsupportedOperationException | 是 | 1 | span.attributes |
error.message | string | 可理解的错误信息 | Could not connect to backend | 否 | 1 | span.attributes |
error | bool | 是否有异常 | true | 是 | 1 | span.attributes |
exception.type | string | 错误事件类型 | *net.OpError | 否 | - | span.attributes |
exception.message | string | 错误信息 | Could not connect to backend | 否 | - | event.attributes |
JSON 示例
以 rpc 为例
{"Name": "proto.HelloService/SayHello","SpanContext": {"TraceID": "e4a230f901100099f3bf34faf75284c4","SpanID": "316c82bffab506ba","TraceFlags": "01","TraceState": "","Remote": false},"Parent": {"TraceID": "e4a230f901100099f3bf34faf75284c4","SpanID": "6f79646dd2c6832b","TraceFlags": "01","TraceState": "","Remote": true},"SpanKind": 2,"StartTime": "2023-09-22T11:47:53.646152+08:00","EndTime": "2023-09-22T11:47:53.748165063+08:00","Attributes": [{"Key": "rpc.system","Value": {"Type": "STRING","Value": "grpc"}},{"Key": "rpc.service","Value": {"Type": "STRING","Value": "proto.HelloService"}},{"Key": "rpc.method","Value": {"Type": "STRING","Value": "SayHello"}},{"Key": "net.peer.ip","Value": {"Type": "STRING","Value": "127.0.0.1"}},{"Key": "net.peer.port","Value": {"Type": "STRING","Value": "51931"}},{"Key": "rpc.grpc.status_code","Value": {"Type": "INT64","Value": 0}}],"Events": [{ // 自定义事件"Name": "message","Attributes": [{"Key": "message.type","Value": {"Type": "STRING","Value": "RECEIVED"}},{"Key": "message.id","Value": {"Type": "INT64","Value": 1}},{"Key": "message.uncompressed_size","Value": {"Type": "INT64","Value": 7}}],"DroppedAttributeCount": 0,"Time": "2023-09-22T11:47:53.646168+08:00"},{"Name": "message","Attributes": [{"Key": "message.type","Value": {"Type": "STRING","Value": "SENT"}},{"Key": "message.id","Value": {"Type": "INT64","Value": 1}},{"Key": "message.uncompressed_size","Value": {"Type": "INT64","Value": 13}}],"DroppedAttributeCount": 0,"Time": "2023-09-22T11:47:53.748167+08:00"}],"Links": null,"Status": {"Code": "Unset","Description": ""},"DroppedAttributes": 0,"DroppedEvents": 0,"DroppedLinks": 0,"ChildSpanCount": 1,"Resource": [{"Key": "service.name","Value": {"Type": "STRING","Value": "test-service"}},{ // 上报token"Key": "token","Value": {"Type": "STRING","Value": "xxxxxxxxxxxxxxxxx"}}],"InstrumentationLibrary": {"Name": "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc","Version": "semver:0.33.0","SchemaURL": ""}}