Documentation ¶
Index ¶
- Constants
- Variables
- func ContextWithLogger(ctx context.Context, l *logrus.Logger) context.Context
- func HTTPServerRequest(req *http.Request) []attribute.KeyValue
- func HTTPServerStatus(code int) (codes.Code, string)
- func Initialize(traceProvider, service string)
- func InstrumentCommonAttributes(tracerName string, excludeEndpoints map[string]map[string]bool) (filterFunc restful.FilterFunction)
- func LogTraceError(ctx context.Context, err error, errMsg string, fields ...logrus.Fields)
- func LogTraceInfo(ctx context.Context, msg string, fields ...logrus.Fields)
- func LoggerAddField(ctx context.Context, key string, value interface{}) context.Context
- func LoggerFromContext(ctx context.Context) *logrus.Entry
- func NewAutoNamedChildSpan(ctx context.Context, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func NewChildSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func NewLogEntryContext(ctx context.Context, format, level string) (context.Context, *logrus.Entry)
- func NewLogger(format, level string) *logrus.Logger
- func NewRootSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func SetUpTracer(ctx context.Context, url string, connectTimeout time.Duration) (func(), error)
- func SpanFromContext(ctx context.Context) trace.Span
- func TraceError(ctx context.Context, err error, errMsg string)
- func TraceIDFromContext(ctx context.Context) string
Constants ¶
const ( UserIDAttribute = "LogUserId" FlightID = "x-flight-id" HTTPMethodKey = attribute.Key("http.method") HTTPStatusCodeKey = attribute.Key("http.status_code") HTTPFlavorKey = attribute.Key("http.flavor") HTTPUserAgentKey = attribute.Key("http.user_agent") HTTPSchemeKey = attribute.Key("http.scheme") HTTPClientIPKey = attribute.Key("http.client_ip") EnduserIDKey = attribute.Key("enduser.id") NetHostNameKey = attribute.Key("net.host.name") NetHostPortKey = attribute.Key("net.host.port") NetSockPeerAddrKey = attribute.Key("net.sock.peer.addr") NetSockPeerPortKey = attribute.Key("net.sock.peer.port") )
const (
LogFieldTraceID = "trace_id"
)
Variables ¶
var ( HTTPSchemeHTTP = HTTPSchemeKey.String("http") HTTPSchemeHTTPS = HTTPSchemeKey.String("https") )
Functions ¶
func ContextWithLogger ¶
ContextWithLogger inserts a log entry from l into ctx and returns the updated context. Note that this will over-ride any existing log entry in the context. For go-restful endpoints, consider using the Logger function instead
func HTTPServerRequest ¶ added in v1.1.2
func Initialize ¶
func Initialize(traceProvider, service string)
func InstrumentCommonAttributes ¶
func InstrumentCommonAttributes(tracerName string, excludeEndpoints map[string]map[string]bool) (filterFunc restful.FilterFunction)
InstrumentCommonAttributes is a filter that will add span attributes for user id and flight id
Parameters tracerName: tracer name excludeEndpoints: consists of blacklisted endpoint name to not send tracer eg. key: /healthz , key2: map of http.Method (GET, POST, DELETE, PUT) , value : boolean
func LogTraceError ¶
LogTraceError logs the provided error and message to the logger obtained from the context, records the error in the trace span and sets the status of the span to Error.
Parameters: ctx: Context in which the function operates, it must contain a valid span and logger. err: Error to be logged and recorded. If this is nil, only the error message will be logged. errMsg: Message to be logged and recorded. This message is also used as the span status description when error occurs.
This function does not return any values.
func LogTraceInfo ¶ added in v1.1.4
LogTraceInfo logs the given message to the logger obtained from the context and records the message in the trace span.
This function does not return any values.
func LoggerAddField ¶
LoggerAddField extracts the logger in the context and adds a field with the given key and value
func LoggerFromContext ¶
LoggerFromContext extracts the logger from the context. If it's not found, a logger with default settings is returned For web API endpoints, the Logger go-restful filter is usually used to add the logger in the request context.
func NewAutoNamedChildSpan ¶
func NewChildSpan ¶
func NewLogEntryContext ¶
NewLogEntryContext sets up a log entry with the given format and level and injects it into ctx, which are then returned. For any invalid value including empty string, it will fall back to using the defaults of logrus
func NewLogger ¶
NewLogger returns a logger with the format and level set with the given values. For any invalid value including empty string, it will fall back to using the defaults of logrus
func NewRootSpan ¶
func SetUpTracer ¶
SetUpTracer sets up a GRPC reciever for serviceName with url as the endpoint of the collector. If a connection is not establised within connectTimeout, it is aborted and returns an error
func TraceError ¶ added in v1.1.1
TraceError record the current error in trace span without log message.
Parameters: ctx: Context in which the function operates, it must contain a valid span. err: Error to be and recorded. If this is nil, this method does nothing. errMsg: Message to be recorded. This message is also used as the span status description when error occurs.
func TraceIDFromContext ¶
Types ¶
This section is empty.