- Variables
- 函数
- BoolTagName">type BoolTagName
- IPv4TagName">type IPv4TagName
- StringTagName">type StringTagName
- Uint16TagName">type Uint16TagName
- Uint32TagName">type Uint32TagName
这个包重要定义了各个服务之间的关系,也算是tag便签的一个规范吧
记录这个有点无聊了,算加深映像吧
文档:https://godoc.org/github.com/opentracing/opentracing-go/ext
Variables
这些常量定义了推荐的通用标记名称,以便在跟踪系统和语言/平台之间具有更好的可移植性。
var (// panKind暗示了span之间的关系,例如客户端/服务器SpanKind = spanKindTagName("span.kind")// SpanKindRPCClient marks a span representing the client-side of an RPC// or other remote callSpanKindRPCClientEnum = SpanKindEnum("client")SpanKindRPCClient = opentracing.Tag{Key: string(SpanKind), Value: SpanKindRPCClientEnum}// SpanKindRPCServer marks a span representing the server-side of an RPC// or other remote callSpanKindRPCServerEnum = SpanKindEnum("server")SpanKindRPCServer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindRPCServerEnum}// SpanKindProducer marks a span representing the producer-side of a// message busSpanKindProducerEnum = SpanKindEnum("producer")SpanKindProducer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindProducerEnum}// SpanKindConsumer marks a span representing the consumer-side of a// message busSpanKindConsumerEnum = SpanKindEnum("consumer")SpanKindConsumer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindConsumerEnum}// 框架或工具包描述,如gin,grpc,gormComponent = StringTagName("component")// SamplingPriority determines the priority of sampling this Span.SamplingPriority = Uint16TagName("sampling.priority")// PeerService records the service name of the peer.PeerService = StringTagName("peer.service")// PeerAddress records the address name of the peer. This may be a "ip:port",// a bare "hostname", a FQDN or even a database DSN substring// like "mysql://username@127.0.0.1:3306/dbname"PeerAddress = StringTagName("peer.address")// PeerHostname records the host name of the peerPeerHostname = StringTagName("peer.hostname")// PeerHostIPv4 records IP v4 host address of the peerPeerHostIPv4 = IPv4TagName("peer.ipv4")// PeerHostIPv6 records IP v6 host address of the peerPeerHostIPv6 = StringTagName("peer.ipv6")// PeerPort records port number of the peerPeerPort = Uint16TagName("peer.port")// HTTPUrl should be the URL of the request being handled in this segment// of the trace, in standard URI format. The protocol is optional.HTTPUrl = StringTagName("http.url")// HTTPMethod is the HTTP method of the request, and is case-insensitive.HTTPMethod = StringTagName("http.method")// HTTPStatusCode is the numeric HTTP status code (200, 404, etc) of the// HTTP response.HTTPStatusCode = Uint16TagName("http.status_code")// DBInstance is database instance name.DBInstance = StringTagName("db.instance")// DBStatement is a database statement for the given database type.// It can be a query or a prepared statement (i.e., before substitution).DBStatement = StringTagName("db.statement")// DBType is a database type. For any SQL database, "sql".// For others, the lower-case database category, e.g. "redis"DBType = StringTagName("db.type")// DBUser is a username for accessing database.DBUser = StringTagName("db.user")// MessageBusDestination is an address at which messages can be exchangedMessageBusDestination = StringTagName("message_bus.destination")// Error indicates that operation represented by the span resulted in an error.Error = BoolTagName("error"))
sp := tracer.StartSpan("span_client")sp.SetTag("Component", value)ext.Component.Set(span,value)opentracing.Tag{Key: string(ext.Component), Value: value}
函数
func RPCServerOption(client opentracing.SpanContext) opentracing.StartSpanOption
- RPCServerOption返回一个适用于RPC服务器跨度的StartSpanOption
- 其中的“client”表示远程对等跨度的元数据(如果可用)。
- client== nil,由于检测不到客户端,这个RPC服务器span将是一个root span
type BoolTagName
func (tag BoolTagName) Set(span opentracing.Span, value bool)type BoolTagName string
type IPv4TagName
func (tag IPv4TagName) Set(span opentracing.Span, value uint32)type IPv4TagName string
func (tag IPv4TagName) SetString(span opentracing.Span, value string)type StringTagName
func (tag StringTagName) Set(span opentracing.Span, value string)type StringTagName string
type Uint16TagName
func (tag Uint16TagName) Set(span opentracing.Span, value uint16)type Uint16TagName string
type Uint32TagName
func (tag Uint32TagName) Set(span opentracing.Span, value uint32)type Uint32TagName string
