这个包重要定义了各个服务之间的关系,也算是tag便签的一个规范吧
记录这个有点无聊了,算加深映像吧
文档:https://godoc.org/github.com/opentracing/opentracing-go/ext

Variables

这些常量定义了推荐的通用标记名称,以便在跟踪系统和语言/平台之间具有更好的可移植性。

  1. var (
  2. // panKind暗示了span之间的关系,例如客户端/服务器
  3. SpanKind = spanKindTagName("span.kind")
  4. // SpanKindRPCClient marks a span representing the client-side of an RPC
  5. // or other remote call
  6. SpanKindRPCClientEnum = SpanKindEnum("client")
  7. SpanKindRPCClient = opentracing.Tag{Key: string(SpanKind), Value: SpanKindRPCClientEnum}
  8. // SpanKindRPCServer marks a span representing the server-side of an RPC
  9. // or other remote call
  10. SpanKindRPCServerEnum = SpanKindEnum("server")
  11. SpanKindRPCServer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindRPCServerEnum}
  12. // SpanKindProducer marks a span representing the producer-side of a
  13. // message bus
  14. SpanKindProducerEnum = SpanKindEnum("producer")
  15. SpanKindProducer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindProducerEnum}
  16. // SpanKindConsumer marks a span representing the consumer-side of a
  17. // message bus
  18. SpanKindConsumerEnum = SpanKindEnum("consumer")
  19. SpanKindConsumer = opentracing.Tag{Key: string(SpanKind), Value: SpanKindConsumerEnum}
  20. // 框架或工具包描述,如gin,grpc,gorm
  21. Component = StringTagName("component")
  22. // SamplingPriority determines the priority of sampling this Span.
  23. SamplingPriority = Uint16TagName("sampling.priority")
  24. // PeerService records the service name of the peer.
  25. PeerService = StringTagName("peer.service")
  26. // PeerAddress records the address name of the peer. This may be a "ip:port",
  27. // a bare "hostname", a FQDN or even a database DSN substring
  28. // like "mysql://username@127.0.0.1:3306/dbname"
  29. PeerAddress = StringTagName("peer.address")
  30. // PeerHostname records the host name of the peer
  31. PeerHostname = StringTagName("peer.hostname")
  32. // PeerHostIPv4 records IP v4 host address of the peer
  33. PeerHostIPv4 = IPv4TagName("peer.ipv4")
  34. // PeerHostIPv6 records IP v6 host address of the peer
  35. PeerHostIPv6 = StringTagName("peer.ipv6")
  36. // PeerPort records port number of the peer
  37. PeerPort = Uint16TagName("peer.port")
  38. // HTTPUrl should be the URL of the request being handled in this segment
  39. // of the trace, in standard URI format. The protocol is optional.
  40. HTTPUrl = StringTagName("http.url")
  41. // HTTPMethod is the HTTP method of the request, and is case-insensitive.
  42. HTTPMethod = StringTagName("http.method")
  43. // HTTPStatusCode is the numeric HTTP status code (200, 404, etc) of the
  44. // HTTP response.
  45. HTTPStatusCode = Uint16TagName("http.status_code")
  46. // DBInstance is database instance name.
  47. DBInstance = StringTagName("db.instance")
  48. // DBStatement is a database statement for the given database type.
  49. // It can be a query or a prepared statement (i.e., before substitution).
  50. DBStatement = StringTagName("db.statement")
  51. // DBType is a database type. For any SQL database, "sql".
  52. // For others, the lower-case database category, e.g. "redis"
  53. DBType = StringTagName("db.type")
  54. // DBUser is a username for accessing database.
  55. DBUser = StringTagName("db.user")
  56. // MessageBusDestination is an address at which messages can be exchanged
  57. MessageBusDestination = StringTagName("message_bus.destination")
  58. // Error indicates that operation represented by the span resulted in an error.
  59. Error = BoolTagName("error")
  60. )
  1. sp := tracer.StartSpan("span_client")
  2. sp.SetTag("Component", value)
  3. ext.Component.Set(span,value)
  4. opentracing.Tag{Key: string(ext.Component), Value: value}

函数

func RPCServerOption(client opentracing.SpanContext) opentracing.StartSpanOption