Documentation ¶
Index ¶
- Constants
- Variables
- func AddErrorCurrentSpan(ctx context.Context, err error) error
- func AddErrorSpan(span *trace.Span, err error) error
- func AddMessageCurrentSpan(ctx context.Context, message string, attrs ...trace.Attribute) error
- func AddMessageSpan(span *trace.Span, message string, attrs ...trace.Attribute)
- func AlwaysGRPC(_ context.Context, _ stats.RPCStats) bool
- func AlwaysHTTP(_ *http.Request) bool
- func CurrentSpan(ctx context.Context) (*trace.Span, error)
- func Exporter(address string, serviceName string, sampler trace.Sampler) error
- func NewMiddleware(ops ...HTTPOption) func(http.Handler) http.Handler
- func SamplerForFraction(fraction float64) trace.Sampler
- func SpanContextAnnotator(ctx context.Context, req *http.Request) metadata.MD
- func StartSpan(ctx context.Context, name string) (context.Context, *trace.Span)
- func TagCurrentSpan(ctx context.Context, attrs ...trace.Attribute) error
- func TagSpan(span *trace.Span, attrs ...trace.Attribute)
- func ThisFunction() string
- func Trace() (file string, line int, name string)
- type GRPCOption
- type HTTPOption
- type Handler
- type ServerHandler
Constants ¶
const ( //RequestHeaderAnnotationPrefix is a prefix which is added to each request header attribute RequestHeaderAnnotationPrefix = "request.header." //RequestTrailerAnnotationPrefix is a prefix which is added to each request trailer attribute RequestTrailerAnnotationPrefix = "request.trailer." //ResponseHeaderAnnotationPrefix is a prefix which is added to each response header attribute ResponseHeaderAnnotationPrefix = "response.header." //ResponseTrailerAnnotationPrefix is a prefix which is added to each response header attribute ResponseTrailerAnnotationPrefix = "response.trailer." //RequestPayloadAnnotationKey is a key under which request payload stored in span RequestPayloadAnnotationKey = "request.payload" //ResponsePayloadAnnotationKey is a key under which response payload stored in span ResponsePayloadAnnotationKey = "response.payload" //ResponseErrorKey is a key under which response error will be stored in span ResponseErrorKey = "response.error" //DefaultMaxPayloadSize represent max payload size which will be added to span DefaultMaxPayloadSize = 1024 * 1024 //TruncatedMarkerKey is a key for annotation which will be presented in span in case payload was truncated TruncatedMarkerKey = "payload.truncated" //TruncatedMarkerValue is a value for annotation which will be presented in span in case payload was truncated TruncatedMarkerValue = "true" //ObfuscationFactor is a percent of value which will be omitted from obfuscated value ObfuscationFactor = 0.80 )
Variables ¶
var ( //ErrSpanNotFound is an error which signal that there is no currently active spans ErrSpanNotFound = errors.New("there is no currently active spans") )
Functions ¶
func AddErrorCurrentSpan ¶
AddErrorCurrentSpan get current span from context and adds error into it
func AddErrorSpan ¶
AddErrorSpan adds error into span
func AddMessageCurrentSpan ¶
AddMessageCurrentSpan get current span from context and adds message into it
func AddMessageSpan ¶
AddMessageSpan adds message into span
func AlwaysGRPC ¶
AlwaysGRPC for each call returns true
func CurrentSpan ¶
CurrentSpan returns current span
func NewMiddleware ¶
func NewMiddleware(ops ...HTTPOption) func(http.Handler) http.Handler
NewMiddleware wrap handler
func SamplerForFraction ¶
SamplerForFraction init sampler for specified fraction
func SpanContextAnnotator ¶
SpanContextAnnotator retrieve information about current span from context or HTTP headers and propagate in binary format to gRPC service
func TagCurrentSpan ¶
TagCurrentSpan get current span from context and tag it
Types ¶
type GRPCOption ¶
type GRPCOption func(*gRPCOptions)
GRPCOption allows extending handler with additional functionality
func WithGRPCPayloadAnnotation ¶
WithGRPCPayloadAnnotation add Inbound/Outbound payload as an attribute to span if f returns true
func WithGRPCPayloadLimit ¶
func WithGRPCPayloadLimit(limit int) GRPCOption
WithGRPCPayloadLimit limit payload size propogated to span in case payload exceeds limit, payload truncated and annotation payload.truncated=true added into span
func WithMetadataAnnotation ¶
WithMetadataAnnotation annotate span with request metadata
func WithMetadataMatcher ¶
func WithMetadataMatcher(f func(string) (string, bool)) GRPCOption
WithMetadataMatcher set metadata matcher to filterout or preprocess metadata
type HTTPOption ¶
type HTTPOption func(*httpOptions)
HTTPOption allows extending handler with additional functionality
func WithHTTPPayloadSize ¶
func WithHTTPPayloadSize(maxSize int) HTTPOption
WithHTTPPayloadSize limit payload size propagated to span in case payload exceeds limit, payload truncated and annotation payload.truncated=true added into span
func WithHeaderMatcher ¶
func WithHeaderMatcher(f func(string) (string, bool)) HTTPOption
WithHeaderMatcher set header matcher to filterout or preprocess headers
func WithHeadersAnnotation ¶
func WithHeadersAnnotation(f func(*http.Request) bool) HTTPOption
WithHeadersAnnotation annotate span with http headers
func WithPayloadAnnotation ¶
func WithPayloadAnnotation(f func(*http.Request) bool) HTTPOption
WithPayloadAnnotation add request/response body as an attribute to span if f returns true
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a opencensus http plugin wrapper which do some useful things to reach traces
type ServerHandler ¶
type ServerHandler struct { ocgrpc.ServerHandler // contains filtered or unexported fields }
ServerHandler is a wrapper over ocgrpc.ServerHandler wrapper extends metadata added into the span
func NewServerHandler ¶
func NewServerHandler(ops ...GRPCOption) *ServerHandler
NewServerHandler returns wrapper over ocgrpc.ServerHandler