Documentation
¶
Index ¶
- Constants
- Variables
- func BranchNamedScope(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func BranchNamedScopeDebug(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func BranchNamedScopeError(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func BranchNamedScopeInfo(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func BranchNamedScopeWarn(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func BranchScope(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func BranchScopeDebug(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func BranchScopeError(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func BranchScopeInfo(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func BranchScopeWarn(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func CallNamedScope(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeBranch(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeBranchDebug(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeBranchError(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeBranchInfo(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeBranchWarn(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeDebug(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeError(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeInfo(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallNamedScopeWarn(ctx context.Context, spanName string, action ScopeAction, ...) error
- func CallScope(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeBranch(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeBranchDebug(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeBranchError(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeBranchInfo(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeBranchWarn(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeDebug(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeError(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeInfo(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CallScopeWarn(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
- func CloseTracing(ctx context.Context) error
- func EndScope(ctx context.Context, err error)
- func InitTracing(ctx context.Context, libraryName string, opts ...TracingOption) error
- func NewHTTPClient() *http.Client
- func NewResource(serviceName, version string, resources ...*resource.Resource) (*resource.Resource, error)
- func StartNamedScope(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func StartNamedScopeDebug(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func StartNamedScopeError(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func StartNamedScopeInfo(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func StartNamedScopeWarn(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
- func StartScope(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func StartScopeDebug(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func StartScopeError(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func StartScopeInfo(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func StartScopeWarn(ctx context.Context, opts ...trace.SpanStartOption) context.Context
- func Tracer(opts ...trace.TracerOption) trace.Tracer
- type DummySpan
- func (s *DummySpan) AddEvent(name string, options ...trace.EventOption)
- func (s *DummySpan) End(options ...trace.SpanEndOption)
- func (s *DummySpan) IsRecording() bool
- func (s *DummySpan) RecordError(err error, options ...trace.EventOption)
- func (s *DummySpan) SetAttributes(kv ...attribute.KeyValue)
- func (s *DummySpan) SetName(name string)
- func (s *DummySpan) SetStatus(code codes.Code, description string)
- func (s *DummySpan) SpanContext() trace.SpanContext
- func (s *DummySpan) TracerProvider() trace.TracerProvider
- type Level
- type LevelTracer
- type LevelTracerProvider
- type LevelTracingOption
- type MetricSpanProcessor
- type ResourceOption
- type ScopeAction
- type TracerProviderTracingOption
- type TracingOption
Constants ¶
const ( ErrorClassKey = "error.class" ErrorTypeKey = "error.type" )
const LogLevelKey = "log.level"
LogLevelKey is the span attribute key for storing numeric log level.
Variables ¶
var ( // Deprecated: Use CallScope Scope = CallScope // Deprecated: Use CallScopeDebug ScopeDebug = CallScopeDebug // Deprecated: Use CallScopeInfo ScopeInfo = CallScopeInfo // Deprecated: Use CallScopeWarn ScopeWarn = CallScopeWarn // Deprecated: Use CallScopeError ScopeError = CallScopeError // Deprecated: Use CallScope NamedScope = CallNamedScope // Deprecated: Use CallNamedScopeDebug NamedScopeDebug = CallNamedScopeDebug // Deprecated: Use CallNamedScopeInfo NamedScopeInfo = CallNamedScopeInfo // Deprecated: Use CallNamedScopeWarn NamedScopeWarn = CallNamedScopeWarn // Deprecated: Use CallNamedScopeError NamedScopeError = CallNamedScopeError )
var ( // Metrics contains Prometheus metrics available for use. Metrics = []prometheus.Collector{ traceCounter, spanCounter, } )
var (
SemconvSchemaURL = semconv.SchemaURL
)
Functions ¶
func BranchNamedScope ¶ added in v4.9.4
func BranchNamedScope(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
BranchNamedScope branch an existing scope with user-provided span name.
func BranchNamedScopeDebug ¶ added in v4.9.4
func BranchNamedScopeDebug(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
BranchNamedScopeDebug branch an existing scope with user-provided span name with debug log level.
func BranchNamedScopeError ¶ added in v4.9.4
func BranchNamedScopeError(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
BranchNamedScopeError branch an existing scope with user-provided span name with error log level.
func BranchNamedScopeInfo ¶ added in v4.9.4
func BranchNamedScopeInfo(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
BranchNamedScopeInfo branch an existing scope with user-provided span name with info log level.
func BranchNamedScopeWarn ¶ added in v4.9.4
func BranchNamedScopeWarn(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
BranchNamedScopeWarn branch an existing scope with user-provided span name with warn log level.
func BranchScope ¶ added in v4.9.4
BranchScope branch an existing scope with span named after fully qualified caller function.
func BranchScopeDebug ¶ added in v4.9.4
BranchScopeDebug branch an existing scope with span named after fully qualified caller function with debug log level.
func BranchScopeError ¶ added in v4.9.4
BranchScopeError branch an existing scope with span named after fully qualified caller function with error log level.
func BranchScopeInfo ¶ added in v4.9.4
BranchScopeInfo branch an existing scope with span named after fully qualified caller function with info log level.
func BranchScopeWarn ¶ added in v4.9.4
BranchScopeWarn branch an existing scope with span named after fully qualified caller function with warn log level.
func CallNamedScope ¶ added in v4.9.4
func CallNamedScope(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScope calls action function within a tracing span. Equivalent to wrapping a code block with `StartNamedScope()`/`EndScope()`.
func CallNamedScopeBranch ¶ added in v4.9.4
func CallNamedScopeBranch(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeBranch calls action function within an existing tracing span. Equivalent to wrapping a code block with `BranchNamedScope()`/`EndScope()`.
func CallNamedScopeBranchDebug ¶ added in v4.9.4
func CallNamedScopeBranchDebug(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeBranchDebug calls action function within an existing tracing span. Scope tagged with log level debug. Equivalent to wrapping a code block with `BranchNamedScope()`/`EndScope()`.
func CallNamedScopeBranchError ¶ added in v4.9.4
func CallNamedScopeBranchError(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeBranchError calls action function within an existing tracing span. Scope tagged with log level debug. Equivalent to wrapping a code block with `BranchNamedScope()`/`EndScope()`.
func CallNamedScopeBranchInfo ¶ added in v4.9.4
func CallNamedScopeBranchInfo(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeBranchInfo calls action function within an existing tracing span. Scope tagged with log level debug. Equivalent to wrapping a code block with `BranchNamedScope()`/`EndScope()`.
func CallNamedScopeBranchWarn ¶ added in v4.9.4
func CallNamedScopeBranchWarn(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeBranchWarn calls action function within an existing tracing span. Scope tagged with log level debug. Equivalent to wrapping a code block with `BranchNamedScope()`/`EndScope()`.
func CallNamedScopeDebug ¶ added in v4.9.4
func CallNamedScopeDebug(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeDebug calls action function within a tracing span. Scope tagged with log level debug. Equivalent to wrapping a code block with `StartNamedScope()`/`EndScope()`.
func CallNamedScopeError ¶ added in v4.9.4
func CallNamedScopeError(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeError calls action function within a tracing span. Scope tagged with log level error. Equivalent to wrapping a code block with `StartNamedScope()`/`EndScope()`.
func CallNamedScopeInfo ¶ added in v4.9.4
func CallNamedScopeInfo(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeInfo calls action function within a tracing span. Scope tagged with log level info. Equivalent to wrapping a code block with `StartNamedScope()`/`EndScope()`.
func CallNamedScopeWarn ¶ added in v4.9.4
func CallNamedScopeWarn(ctx context.Context, spanName string, action ScopeAction, opts ...trace.SpanStartOption) error
CallNamedScopeWarn calls action function within a tracing span. Scope tagged with log level warning. Equivalent to wrapping a code block with `StartNamedScope()`/`EndScope()`.
func CallScope ¶ added in v4.9.4
func CallScope(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScope calls action function within a tracing span named after the calling function. Equivalent to wrapping a code block with `StartScope()`/`EndScope()`.
func CallScopeBranch ¶ added in v4.9.4
func CallScopeBranch(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeBranch calls action function within a tracing span named after the calling function. Equivalent to wrapping a code block with `BranchScope()`/`EndScope()`.
func CallScopeBranchDebug ¶ added in v4.9.4
func CallScopeBranchDebug(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeBranchDebug calls action function within a tracing span named after the calling function. Scope tagged with log level debug. Equivalent to wrapping a code block with `BranchScopeDebug()`/`EndScope()`.
func CallScopeBranchError ¶ added in v4.9.4
func CallScopeBranchError(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeBranchError calls action function within a tracing span named after the calling function. Scope tagged with log level error. Equivalent to wrapping a code block with `BranchScopeError()`/`EndScope()`.
func CallScopeBranchInfo ¶ added in v4.9.4
func CallScopeBranchInfo(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeBranchInfo calls action function within a tracing span named after the calling function. Scope tagged with log level info. Equivalent to wrapping a code block with `BranchScopeInfo()`/`EndScope()`.
func CallScopeBranchWarn ¶ added in v4.9.4
func CallScopeBranchWarn(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeBranchWarn calls action function within a tracing span named after the calling function. Scope tagged with log level warn. Equivalent to wrapping a code block with `BranchScopeWarn()`/`EndScope()`.
func CallScopeDebug ¶ added in v4.9.4
func CallScopeDebug(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeDebug calls action function within a tracing span named after the calling function. Scope tagged with log level debug. Equivalent to wrapping a code block with `StartScope()`/`EndScope()`.
func CallScopeError ¶ added in v4.9.4
func CallScopeError(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeError calls action function within a tracing span named after the calling function. Scope tagged with log level error. Equivalent to wrapping a code block with `StartScope()`/`EndScope()`.
func CallScopeInfo ¶ added in v4.9.4
func CallScopeInfo(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeInfo calls action function within a tracing span named after the calling function. Scope tagged with log level info. Equivalent to wrapping a code block with `StartScope()`/`EndScope()`.
func CallScopeWarn ¶ added in v4.9.4
func CallScopeWarn(ctx context.Context, action ScopeAction, opts ...trace.SpanStartOption) error
CallScopeWarn calls action function within a tracing span named after the calling function. Scope tagged with log level warning. Equivalent to wrapping a code block with `StartScope()`/`EndScope()`.
func CloseTracing ¶
CloseTracing closes the global OpenTelemetry tracer provider. This allows queued up traces to be flushed.
func EndScope ¶
EndScope end scope created by `StartScope()`/`StartNamedScope()`. Logs error return value and ends span.
func InitTracing ¶
func InitTracing(ctx context.Context, libraryName string, opts ...TracingOption) error
InitTracing initializes a global OpenTelemetry tracer provider singleton. Call to initialize before using functions in this package. Instruments logrus to mirror to active trace. Must use `WithContext()` method. Call after initializing logrus. libraryName is typically the application's module name. Pass empty string to autodetect module name. Prometheus metrics are accessible by registering the metrics at `tracing.Metrics`.
func NewHTTPClient ¶ added in v4.11.0
NewHTTPClient creates an HTTP client configured with OpenTelemetry middleware to generate a span on request and propagate the trace to the server.
func NewResource ¶ added in v4.3.1
func NewResource(serviceName, version string, resources ...*resource.Resource) (*resource.Resource, error)
NewResource creates a resource with sensible defaults. Replaces common use case of verbose usage.
func StartNamedScope ¶
func StartNamedScope(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
Start a scope with user-provided span name.
func StartNamedScopeDebug ¶ added in v4.7.0
func StartNamedScopeDebug(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
StartNamedScopeDebug start a scope with user-provided span name with debug log level.
func StartNamedScopeError ¶ added in v4.7.0
func StartNamedScopeError(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
StartNamedScopeError start a scope with user-provided span name with error log level.
func StartNamedScopeInfo ¶ added in v4.7.0
func StartNamedScopeInfo(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
StartNamedScopeInfo start a scope with user-provided span name with info log level.
func StartNamedScopeWarn ¶ added in v4.7.0
func StartNamedScopeWarn(ctx context.Context, spanName string, opts ...trace.SpanStartOption) context.Context
StartNamedScopeWarn start a scope with user-provided span name with warning log level.
func StartScope ¶
StartScope start a scope with span named after fully qualified caller function.
func StartScopeDebug ¶ added in v4.7.0
StartScopeDebug start a scope with span named after fully qualified caller function with debug log level.
func StartScopeError ¶ added in v4.7.0
StartScopeError start a scope with span named after fully qualified caller function with error log level.
func StartScopeInfo ¶ added in v4.7.0
StartScopeInfo start a scope with span named after fully qualified caller function with info log level.
func StartScopeWarn ¶ added in v4.7.0
StartScopeWarn start a scope with span named after fully qualified caller function with warning log level.
Types ¶
type DummySpan ¶ added in v4.7.0
type DummySpan struct {
// contains filtered or unexported fields
}
DummySpan is used to create a stub span as a placeholder for spans not intended for export. This is used to selectively disable tracing individual spans based on criteria, such as log level. Any child spans created from a DummySpan will be linked to the dummy's next non-dummy ancestor.
func (*DummySpan) AddEvent ¶ added in v4.7.0
func (s *DummySpan) AddEvent(name string, options ...trace.EventOption)
func (*DummySpan) End ¶ added in v4.7.0
func (s *DummySpan) End(options ...trace.SpanEndOption)
func (*DummySpan) IsRecording ¶ added in v4.7.0
func (*DummySpan) RecordError ¶ added in v4.7.0
func (s *DummySpan) RecordError(err error, options ...trace.EventOption)
func (*DummySpan) SetAttributes ¶ added in v4.7.0
func (*DummySpan) SpanContext ¶ added in v4.7.0
func (s *DummySpan) SpanContext() trace.SpanContext
func (*DummySpan) TracerProvider ¶ added in v4.7.0
func (s *DummySpan) TracerProvider() trace.TracerProvider
type LevelTracer ¶ added in v4.7.0
LevelTracer is created by `LevelTracerProvider`.
type LevelTracerProvider ¶ added in v4.7.0
type LevelTracerProvider struct { *sdktrace.TracerProvider // contains filtered or unexported fields }
LevelTracerProvider wraps a TracerProvider to apply log level processing. Tag spans with `log.level` and `log.levelNum=n`, where `n` is numeric log level 0-6 (Panic, Fatal, Error, Warn, Info, Debug, Trace). If span log level is lower severity than threshold, create a `DummySpan` instead. `DummySpan` behaves like an alias of its next non-dummy ancestor, but gets filtered out and omitted from export. Nested spans containing a mix of real and `DummySpan` will be linked as if the `DummySpan` never happened.
func NewLevelTracerProvider ¶ added in v4.7.0
func NewLevelTracerProvider(level Level, opts ...sdktrace.TracerProviderOption) *LevelTracerProvider
func (*LevelTracerProvider) Tracer ¶ added in v4.7.0
func (tp *LevelTracerProvider) Tracer(libraryName string, opts ...trace.TracerOption) trace.Tracer
type LevelTracingOption ¶ added in v4.7.0
type LevelTracingOption struct {
// contains filtered or unexported fields
}
func WithLevel ¶ added in v4.7.0
func WithLevel(level Level) *LevelTracingOption
WithLevel passes a log level to InitTracing.
type MetricSpanProcessor ¶ added in v4.7.0
type MetricSpanProcessor struct {
// contains filtered or unexported fields
}
MetricSpanProcessor implements SpanProcessor as a middleware to track via Prometheus metrics before export.
func NewMetricSpanProcessor ¶ added in v4.7.0
func NewMetricSpanProcessor(next sdktrace.SpanProcessor) *MetricSpanProcessor
func (*MetricSpanProcessor) ForceFlush ¶ added in v4.7.0
func (p *MetricSpanProcessor) ForceFlush(ctx context.Context) error
func (*MetricSpanProcessor) OnEnd ¶ added in v4.7.0
func (p *MetricSpanProcessor) OnEnd(s sdktrace.ReadOnlySpan)
func (*MetricSpanProcessor) OnStart ¶ added in v4.7.0
func (p *MetricSpanProcessor) OnStart(parent context.Context, s sdktrace.ReadWriteSpan)
type ResourceOption ¶ added in v4.7.0
type ResourceOption struct {
// contains filtered or unexported fields
}
func WithResource ¶ added in v4.7.0
func WithResource(res *resource.Resource) *ResourceOption
WithResource is convenience function for common use case of passing a Resource object as TracerProviderOption.
type ScopeAction ¶
type TracerProviderTracingOption ¶ added in v4.7.0
type TracerProviderTracingOption struct {
// contains filtered or unexported fields
}
func WithTracerProviderOption ¶ added in v4.7.0
func WithTracerProviderOption(opts ...sdktrace.TracerProviderOption) *TracerProviderTracingOption
WithTracerProviderOption passes TracerProviderOption arguments to InitTracing.
type TracingOption ¶ added in v4.7.0
type TracingOption interface {
// contains filtered or unexported methods
}