Documentation
¶
Overview ¶
Package rkmidtrace is a middleware for recording tracing
Index ¶
- func NewFileExporter(outputPath string, opts ...stdouttrace.Option) sdktrace.SpanExporter
- func NewNoopExporter() sdktrace.SpanExporter
- func NewOTLPTraceExporter(client otexporterotlp.Client) sdktrace.SpanExporter
- func NewZipkinExporter(url string) sdktrace.SpanExporter
- type AfterCtx
- type BeforeCtx
- type BootConfig
- type NoopExporter
- type Option
- func ToOptions(config *BootConfig, entryName, entryType string) []Option
- func WithEntryNameAndType(entryName, entryType string) Option
- func WithExporter(exporter sdktrace.SpanExporter) Option
- func WithMockOptionSet(mock OptionSetInterface) Option
- func WithPathToIgnore(paths ...string) Option
- func WithPropagator(propagator propagation.TextMapPropagator) Option
- func WithSpanProcessor(processor sdktrace.SpanProcessor) Option
- func WithTracerProvider(provider *sdktrace.TracerProvider) Option
- type OptionSetInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileExporter ¶
func NewFileExporter(outputPath string, opts ...stdouttrace.Option) sdktrace.SpanExporter
NewFileExporter create a file exporter whose default output is stdout.
func NewNoopExporter ¶
func NewNoopExporter() sdktrace.SpanExporter
NewNoopExporter create a noop exporter
func NewOTLPTraceExporter ¶
func NewOTLPTraceExporter(client otexporterotlp.Client) sdktrace.SpanExporter
func NewZipkinExporter ¶
func NewZipkinExporter(url string) sdktrace.SpanExporter
Types ¶
type AfterCtx ¶
type AfterCtx struct {
Input struct {
ResCode int
ResMsg string
Attributes []attribute.KeyValue
}
Output struct{}
}
AfterCtx context for After() function
func NewAfterCtx ¶
func NewAfterCtx() *AfterCtx
NewAfterCtx create new AfterCtx with fields initialized
type BeforeCtx ¶
type BeforeCtx struct {
Input struct {
UrlPath string
SpanName string
IsClient bool
Attributes []attribute.KeyValue
RequestCtx context.Context
Carrier propagation.TextMapCarrier
}
Output struct {
NewCtx context.Context
Span oteltrace.Span
}
}
BeforeCtx context for Before() function
func NewBeforeCtx ¶
func NewBeforeCtx() *BeforeCtx
NewBeforeCtx create new BeforeCtx with fields initialized
type BootConfig ¶
type BootConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Ignore []string `yaml:"ignore" json:"ignore"`
Exporter struct {
File struct {
Enabled bool `yaml:"enabled" json:"enabled"`
OutputPath string `yaml:"outputPath" json:"outputPath"`
} `yaml:"file" json:"file"`
Otlp struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Endpoint string `yaml:"endpoint" json:"endpoint"`
} `yaml:"otlp" json:"otlp"`
Zipkin struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Endpoint string `yaml:"endpoint" json:"endpoint"`
} `yaml:"zipkin" json:"zipkin"`
} `yaml:"exporter" json:"exporter"`
}
BootConfig for YAML
type NoopExporter ¶
type NoopExporter struct{}
NoopExporter noop
func (*NoopExporter) ExportSpans ¶
func (nsb *NoopExporter) ExportSpans(context.Context, []sdktrace.ReadOnlySpan) error
ExportSpans handles export of SpanSnapshots by dropping them.
type Option ¶
type Option func(*optionSet)
Option is used while creating middleware as param
func ToOptions ¶
func ToOptions(config *BootConfig, entryName, entryType string) []Option
ToOptions convert BootConfig into Option list
func WithEntryNameAndType ¶
WithEntryNameAndType provide entry name and entry type.
func WithExporter ¶
func WithExporter(exporter sdktrace.SpanExporter) Option
WithExporter Provide sdktrace.SpanExporter.
func WithMockOptionSet ¶
func WithMockOptionSet(mock OptionSetInterface) Option
WithMockOptionSet provide mock OptionSetInterface
func WithPathToIgnore ¶
WithPathToIgnore provide paths prefix that will ignore.
func WithPropagator ¶
func WithPropagator(propagator propagation.TextMapPropagator) Option
WithPropagator provide propagation.TextMapPropagator.
func WithSpanProcessor ¶
func WithSpanProcessor(processor sdktrace.SpanProcessor) Option
WithSpanProcessor provide sdktrace.SpanProcessor.
func WithTracerProvider ¶
func WithTracerProvider(provider *sdktrace.TracerProvider) Option
WithTracerProvider provide *sdktrace.TracerProvider.
type OptionSetInterface ¶
type OptionSetInterface interface {
GetEntryName() string
GetEntryType() string
BeforeCtx(req *http.Request, isClient bool, attrs ...attribute.KeyValue) *BeforeCtx
Before(*BeforeCtx)
AfterCtx(resCode int, resMsg string, attrs ...attribute.KeyValue) *AfterCtx
After(before *BeforeCtx, after *AfterCtx)
GetTracer() oteltrace.Tracer
GetProvider() *sdktrace.TracerProvider
GetPropagator() propagation.TextMapPropagator
ShouldIgnore(string) bool
}
OptionSetInterface mainly for testing purpose
func NewOptionSet ¶
func NewOptionSet(opts ...Option) OptionSetInterface
NewOptionSet Create new optionSet with options.
func NewOptionSetMock ¶
func NewOptionSetMock(before *BeforeCtx, after *AfterCtx, tracer oteltrace.Tracer, provider *sdktrace.TracerProvider, propagator propagation.TextMapPropagator) OptionSetInterface
NewOptionSetMock for testing purpose