traces

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 39 Imported by: 0

Documentation

Overview

Package traces

Package traces

Package traces

Package traces

Index

Constants

View Source
const (
	SpanKindClient = "spanKindClient"
	SpanKindServer = "spanKindServer"
)

Variables

View Source
var Integer64AsStringConfig = jsoniter.Config{
	EscapeHTML:                    false,
	MarshalFloatWith6Digits:       true,
	ObjectFieldMustBeSimpleString: true,
}.Froze()

Functions

func ClientFilter

func ClientFilter(opts ...FilterOption) filter.ClientFilter

ClientFilter client filter in trpc

func GetTextMapCarriers

func GetTextMapCarriers(md codec.MetaData, msg codec.Msg) propagation.TextMapCarrier

GetTextMapCarriers ...

func Init

func Init()

Init trace filter

func ProtoMessageToCustomJSONString

func ProtoMessageToCustomJSONString(message interface{}) string

ProtoMessageToCustomJSONString use json-iterator serialization, convert int64/uint64 to string

func ProtoMessageToCustomJSONStringWithContext

func ProtoMessageToCustomJSONStringWithContext(ctx context.Context, message interface{}) string

ProtoMessageToCustomJSONStringWithContext use DefaultTraceEventMsgMarshaller

func ProtoMessageToJSONBytes

func ProtoMessageToJSONBytes(message interface{}) []byte

ProtoMessageToJSONBytes .

func ProtoMessageToJSONIndentBytes

func ProtoMessageToJSONIndentBytes(message interface{}) []byte

ProtoMessageToJSONIndentBytes return pretty string bytes for multiple lines with indent

func ProtoMessageToJSONIndentString

func ProtoMessageToJSONIndentString(message interface{}) string

ProtoMessageToJSONIndentString return pretty string for multiple lines

func ProtoMessageToJSONString

func ProtoMessageToJSONString(message interface{}) string

ProtoMessageToJSONString use json-iteration marshaller

func ProtoMessageToPBJSONString

func ProtoMessageToPBJSONString(message interface{}) string

ProtoMessageToPBJSONString use pbjson serialization,convert uint64 to string

func RegisterCarrier

func RegisterCarrier(carrier func(md codec.MetaData, msg codec.Msg) propagation.TextMapCarrier)

RegisterCarrier register otelcarrier

func ServerFilter

func ServerFilter(opts ...FilterOption) filter.ServerFilter

ServerFilter opentelemetry server filter in trpc

func SetMaxStringLength

func SetMaxStringLength(limit int)

SetMaxStringLength sets the maximum length of a string attribute value.

func SetTraceEventMsgMarshaler

func SetTraceEventMsgMarshaler(f TraceEventMsgMarshalerWithContext)

SetTraceEventMsgMarshaler set marshaler for trace event msg

Types

type AttributesAfterHandle

type AttributesAfterHandle func(ctx context.Context, rsp interface{}) []attribute.KeyValue

AttributesAfterHandle hook

var DefaultAttributesAfterClientHandle AttributesAfterHandle = func(ctx context.Context,
	rsp interface{}) []attribute.KeyValue {
	return nil
}

DefaultAttributesAfterClientHandle set by user

var DefaultAttributesAfterServerHandle AttributesAfterHandle = func(ctx context.Context,
	rsp interface{}) []attribute.KeyValue {
	return nil
}

DefaultAttributesAfterServerHandle set by user

type FilterOption

type FilterOption func(*FilterOptions)

FilterOption filter option

type FilterOptions

type FilterOptions struct {
	// TraceLogMode trace log mode
	TraceLogMode config.LogMode
	// TraceLogOption trace_log option
	TraceLogOption config.TraceLogOption
	// DisableTraceBody disable req/rsp event log
	DisableTraceBody bool
	// DisableParentSampling ignore parent sampling
	DisableParentSampling bool
}

FilterOptions FilterOptions

type TraceAttributesFunc

type TraceAttributesFunc func(ctx context.Context, req interface{}) []attribute.KeyValue

TraceAttributesFunc hook for get trace attribute from ctx and req

var DefaultTraceAttributesFunc TraceAttributesFunc = func(ctx context.Context, req interface{}) []attribute.KeyValue {
	return nil
}

DefaultTraceAttributesFunc can be set by user

type TraceEventMsgMarshaler

type TraceEventMsgMarshaler func(message interface{}) string

TraceEventMsgMarshaler marshaler for trace event msg

var DefaultTraceEventMsgMarshaler TraceEventMsgMarshaler = ProtoMessageToCustomJSONString

DefaultTraceEventMsgMarshaler can be set by user Deprecated: use SetTraceEventMsgMarshaler instead

type TraceEventMsgMarshalerWithContext

type TraceEventMsgMarshalerWithContext func(ctx context.Context, message interface{}) string

TraceEventMsgMarshalerWithContext marshaler for trace event msg with ctx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL