# README
组件
Tracing
概览
- 基于 opentracing 语义
- 使用 protobuf 协议描述 trace 结构
- 参考 Kratos 代码改造,对比opentracing-go的实现更为轻量
结构定义
根据opentracing的语义:
Tag
kv结构
Log
kv结构
封装
Inject
:注入的过程就是把 context 的所有信息写入到一个叫 Carrier 的 map 中,然后把 map 中的所有 KV 对写入 HTTP Header 或者 grpc MetadataExtract
:抽取过程是注入的逆过程,从 carrier,也就是 HTTP Headers(grpc Metadata),构建 SpanContext
整个过程类似客户端和服务器传递数据的序列化和反序列化的过程。这里的 Carrier (Map)支持 Key 为 string 类型,value 为 string 或者 Binary 格式(Bytes)
参考
# Functions
Bool new tagBool NOTE: use TagBool.
从context.Context中获取t Trace结构(大结构,所有的span都是存储在t Trace中).
Int new tag Int.
Log new log.
将Trace存储在context中.
String new tag String.
TagBool new bool tag.
TagFloat32 new float64 tag.
TagFloat64 new float64 tag.
TagInt new int tag.
TagInt64 new int64 tag.
TagString new string tag.
# Constants
trace 键.
GRPCFormat represents Trace as gRPC metadata.
HTTPFormat represents Trace as HTTP header string pairs.
The type or "kind" of an error (only for event="error" logs).
For languages that support such a thing (e.g., Java, Python), the actual Throwable/Exception/Error object instance itself.
A stable identifier for some notable moment in the lifetime of a Span.
A concise, human-readable, one-line message explaining the event.
A stack trace in platform-conventional format; may or may not pertain to an error.
Standard Span tags https://github.com/opentracing/specification/blob/master/semantic_conventions.md#span-tags-table.
legacy tag.
Standard Span tags https://github.com/opentracing/specification/blob/master/semantic_conventions.md#span-tags-table.
The software package, framework, library, or module that generated the associated Span.
Database instance name.
A database statement for the given database type.
Database type.
Username for accessing database.
true if and only if the application considers the operation represented by the Span to have failed type bool.
HTTP method of the request for the associated Span.
HTTP response status code for the associated Span.
URL of the request being handled in this segment of the trace, in standard URI format.
An address at which messages can be exchanged.
Remote "address", suitable for use in a networking client library.
Remote hostname.
Remote IPv4 address as a .-separated tuple.
Remote IPv6 address as a string of colon-separated 4-char hex tuples.
Remote port.
Remote service name (for some unspecified definition of "service").
If greater than 0, a hint to the Tracer to do its best to capture the trace.
Either "client" or "server" for the appropriate roles in an RPC, and "producer" or "consumer" for the appropriate roles in a messaging scenario.
# Type aliases
BuiltinFormat is used to demarcate the values within package `trace` that are intended for use with the Tracer.Inject() and Tracer.Extract() methods.
No description provided by the author