Documentation ¶
Index ¶
- Constants
- func AttachRequest(ctx context.Context, req *http.Request)
- func GetContextHeader(ctx context.Context) http.Header
- func NewContext(cts ...context.Context) context.Context
- func NewContextWithHeader(header http.Header) context.Context
- func SetContextTracing(ctx context.Context, tracing Tracing) context.Context
- type Attr
- type Bucket
- type DebuggerManager
- type Entity
- type Generator
- type Item
- type LoggingFormatter
- type LoggingManager
- type LoggingPlugin
- type LoggingWriter
- type Span
- type SpanFormatter
- type SpanId
- type SpanManager
- type SpanPlugin
- type SpanReporter
- type SpanWithGetter
- type SpanWithLogger
- type Stack
- type StackItem
- type TraceId
- type Tracing
Constants ¶
View Source
const ( AttrHeader = "http.header" AttrProtocol = "http.protocol" AttrRequestMethod = "http.request.method" AttrRequestUrl = "http.request.url" AttrUserAgent = "http.user.agent" )
View Source
const (
ContextKey = "__GO_LIB_LOG_TRACING__"
)
Variables ¶
This section is empty.
Functions ¶
func AttachRequest ¶
AttachRequest 向 <http.Request> 添加兼容 OpenTracing 的 <common.Tracing> 参数.
func GetContextHeader ¶
GetContextHeader 从 <context.Context> 提取 <http.Header> 参数.
func NewContextWithHeader ¶ added in v1.1.5
Types ¶
type Attr ¶
Attr 属性参数.
func (Attr) SetProtocol ¶
func (Attr) SetRequestMethod ¶
func (Attr) SetRequestUrl ¶
func (Attr) SetUserAgent ¶
type Bucket ¶
type DebuggerManager ¶ added in v1.1.1
type DebuggerManager interface { Error(format string, args ...any) Info(format string, args ...any) Fatal(format string, args ...any) }
var (
Debugger DebuggerManager
)
type Entity ¶
type Entity struct { Level base.Level `json:"level"` Message string `json:"message"` Time string `json:"time"` TimeMicro int64 `json:"time_micro"` Stack string `json:"stack,omitempty"` TraceId string `json:"trace_id,omitempty"` SpanId string `json:"span_id,omitempty"` SpanPosition int32 `json:"span_position,omitempty"` ParentSpanId string `json:"parent_span_id,omitempty"` ParentSpanPosition int32 `json:"parent_span_position,omitempty"` Pid int `json:"pid,omitempty"` ServiceAddresses []string `json:"service_addresses,omitempty"` ServiceHost string `json:"service_host,omitempty"` ServicePort int `json:"service_port,omitempty"` ServiceName string `json:"service_name,omitempty"` ServiceVersion string `json:"service_version,omitempty"` }
Entity 日志实体.
func NewEntityWithBody ¶ added in v1.1.1
type Generator ¶
type Generator interface { // Convert // converts a byte list to hex string Convert(bs []byte) string // Decode // hex string to byte list. Decode(str string) (b []byte) // Make // a byte list with given length // // Generate.Make(8) // Generate.Make(16) Make(n int) (b []byte) }
Generator is a tool use to generate trace and span identify.
func NewGenerator ¶
func NewGenerator() Generator
type Item ¶
type Item interface { Copy() Item Level() base.Level Message() string ParentSpan() (SpanId, int32) Release() Span() (SpanId, int32) Stack() Stack String() string Time() time.Time TraceId() TraceId }
Item 日志条目.
type LoggingFormatter ¶ added in v1.1.1
type LoggingManager ¶ added in v1.1.1
type LoggingManager interface { GetPlugin() (plugin LoggingPlugin) Log(ctx context.Context, level base.Level, message string) Send(items ...Item) SetPlugin(plugin LoggingPlugin) Wait() }
type LoggingPlugin ¶ added in v1.1.1
type LoggingPlugin interface { GetFormatter() (formatter LoggingFormatter) GetWriter() (formatter LoggingWriter) SetFormatter(formatter LoggingFormatter) SetWriter(writer LoggingWriter) Sync() bool Write(items []Item) (err error) }
type LoggingWriter ¶ added in v1.1.1
type LoggingWriter interface {
Write(formatter LoggingFormatter, items []Item) (err error)
}
type Span ¶
type Span interface { Child(format string, args ...any) Span End() Release() SpanWithGetter SpanWithLogger }
type SpanFormatter ¶
type SpanManager ¶ added in v1.1.1
type SpanManager interface { GetPlugin() (plugin SpanPlugin) Send(span Span) SetPlugin(plugin SpanPlugin) Wait() }
type SpanPlugin ¶
type SpanPlugin interface { GetFormatter() (formatter SpanFormatter) GetReporter() (reporter SpanReporter) Report(spans []Span) (err error) SetFormatter(formatter SpanFormatter) SetReporter(reporter SpanReporter) }
type SpanReporter ¶ added in v1.1.1
type SpanReporter interface { // Report // 上报数据. Report(formatter SpanFormatter, spans []Span) (err error) }
SpanReporter 上报跟踪数据, 应用于 Jaeger, Zipkin 等.
type SpanWithGetter ¶ added in v1.1.1
type SpanWithGetter interface { GetAttr() Attr GetContext() context.Context GetEndTime() time.Time GetDuration() time.Duration GetLogs() []Item GetName() string GetStartTime() time.Time GetTracing() Tracing }
SpanWithGetter 读取参数.
type SpanWithLogger ¶ added in v1.1.1
type SpanWithLogger interface { Debug(format string, args ...any) Info(format string, args ...any) Warn(format string, args ...any) Error(format string, args ...any) Fatal(format string, args ...any) }
SpanWithLogger 操作日志.
type Tracing ¶
type Tracing interface { // Child // 创建子链路追踪标识接口. // // 基于当前 Tracing, 创建子 Tracing 实例, 维护本节与上级的跟踪跨度ID. Child() Tracing // GetParent // 读取上级链路跟踪ID与点位. GetParent() (SpanId, int32) // GetParentSpanId // 读取上级链路跟踪ID. GetParentSpanId() SpanId // GetSpan // 读取链路跟踪跨度ID与点位. GetSpan() (SpanId, int32) // GetSpanAndIncrement // 取本级点位, 并递增至下个节点点位. GetSpanAndIncrement() (SpanId, int32) // GetSpanId // 读取链路跟踪跨度ID. GetSpanId() SpanId // GetTraceId // 读取链路追踪ID. GetTraceId() TraceId }
Tracing 链路追踪标识接口.
func GetContextTracing ¶
GetContextTracing 从 <context.Context> 提取 <common.Tracing>.
func NewTracingWithContext ¶
NewTracingWithContext 创建子级追踪.
func NewTracingWithHeader ¶
func NewTracingWithRequest ¶
Click to show internal directories.
Click to hide internal directories.