diagnostics

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 28 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Delete                   = "delete"
	Get                      = "get"
	Set                      = "set"
	StateQuery               = "query"
	ConfigurationSubscribe   = "subscribe"
	ConfigurationUnsubscribe = "unsubscribe"
	StateTransaction         = "transaction"
	BulkGet                  = "bulk_get"
	BulkDelete               = "bulk_delete"
)
View Source
const (
	GRPCTraceContextKey = "grpc-trace-bin"
	GRPCProxyAppIDKey   = "dapr-app-id"
)
View Source
const (
	TraceparentHeader = "traceparent"
	TracestateHeader  = "tracestate"
)

We have leveraged the code from opencensus-go plugin to adhere the w3c trace context. Reference : https://github.com/census-instrumentation/opencensus-go/blob/master/plugin/ochttp/propagation/tracecontext/propagation.go

Variables

View Source
var (
	KeyServerMethod = tag.MustNewKey("grpc_server_method")
	KeyServerStatus = tag.MustNewKey("grpc_server_status")

	KeyClientMethod = tag.MustNewKey("grpc_client_method")
	KeyClientStatus = tag.MustNewKey("grpc_client_status")
)

Tag key definitions for http requests.

View Source
var (
	// DefaultReportingPeriod is the default view reporting period.
	DefaultReportingPeriod = 1 * time.Minute

	// DefaultMonitoring holds service monitoring metrics definitions.
	DefaultMonitoring = newServiceMetrics()
	// DefaultGRPCMonitoring holds default gRPC monitoring handlers and middlewares.
	DefaultGRPCMonitoring = newGRPCMetrics()
	// DefaultHTTPMonitoring holds default HTTP monitoring handlers and middlewares.
	DefaultHTTPMonitoring = newHTTPMetrics()
	// DefaultComponentMonitoring holds component specific metrics.
	DefaultComponentMonitoring = newComponentMetrics()
	// DefaultResiliencyMonitoring holds resiliency specific metrics.
	DefaultResiliencyMonitoring = newResiliencyMetrics()
	// Rules holds regex expressions for metrics labels
	Rules map[string]string
)

Functions

func AddAttributesToSpan added in v0.8.0

func AddAttributesToSpan(span trace.Span, attributes map[string]string)

AddAttributesToSpan adds the given attributes in the span.

func ConstructInputBindingSpanAttributes added in v0.8.0

func ConstructInputBindingSpanAttributes(bindingName, url string) map[string]string

ConstructInputBindingSpanAttributes creates span attributes for InputBindings.

func ConstructSubscriptionSpanAttributes added in v0.8.0

func ConstructSubscriptionSpanAttributes(topic string) map[string]string

ConstructSubscriptionSpanAttributes creates span attributes for Pubsub subscription.

func ElapsedSince added in v1.7.0

func ElapsedSince(start time.Time) float64

func GRPCTraceStreamServerInterceptor added in v1.3.0

func GRPCTraceStreamServerInterceptor(appID string, spec config.TracingSpec) grpc.StreamServerInterceptor

GRPCTraceStreamServerInterceptor sets the trace context or starts the trace client span based on request. This is used by proxy requests too.

func GRPCTraceUnaryServerInterceptor added in v0.8.0

func GRPCTraceUnaryServerInterceptor(appID string, spec config.TracingSpec) grpc.UnaryServerInterceptor

GRPCTraceUnaryServerInterceptor sets the trace context or starts the trace client span based on request.

func HTTPTraceMiddleware added in v0.8.0

func HTTPTraceMiddleware(next fasthttp.RequestHandler, appID string, spec config.TracingSpec) fasthttp.RequestHandler

HTTPTraceMiddleware sets the trace context or starts the trace client span based on request.

func InitMetrics added in v0.5.0

func InitMetrics(appID, namespace string, rules []config.MetricsRule) error

InitMetrics initializes metrics.

func SpanContextFromIncomingGRPCMetadata added in v0.9.0

func SpanContextFromIncomingGRPCMetadata(ctx context.Context) (trace.SpanContext, bool)

SpanContextFromIncomingGRPCMetadata returns the SpanContext stored in incoming metadata of context, or empty if there isn't one.

func SpanContextFromRequest added in v0.7.0

func SpanContextFromRequest(req *fasthttp.Request) (sc trace.SpanContext, ok bool)

SpanContextFromRequest extracts a span context from incoming requests.

func SpanContextFromW3CString added in v0.8.0

func SpanContextFromW3CString(h string) (sc trace.SpanContext, ok bool)

SpanContextFromW3CString extracts a span context from given string which got earlier from SpanContextToW3CString format.

func SpanContextToGRPCMetadata added in v0.8.0

func SpanContextToGRPCMetadata(ctx context.Context, spanContext trace.SpanContext) context.Context

SpanContextToGRPCMetadata appends binary serialized SpanContext to the outgoing GRPC context.

func SpanContextToHTTPHeaders added in v0.8.0

func SpanContextToHTTPHeaders(sc trace.SpanContext, setHeader func(string, string))

SpanContextToHTTPHeaders adds the spancontext in traceparent and tracestate headers.

func SpanContextToW3CString added in v0.8.0

func SpanContextToW3CString(sc trace.SpanContext) string

SpanContextToW3CString returns the SpanContext string representation.

func StartGRPCProducerSpanChildFromParent added in v1.10.0

func StartGRPCProducerSpanChildFromParent(ct context.Context, parentSpan trace.Span, spanName string) (context.Context, trace.Span)

func StartInternalCallbackSpan added in v0.8.0

func StartInternalCallbackSpan(ctx context.Context, spanName string, parent trace.SpanContext, spec config.TracingSpec) (context.Context, trace.Span)

StartInternalCallbackSpan starts trace span for internal callback such as input bindings and pubsub subscription.

func StartProducerSpanChildFromParent added in v1.10.0

func StartProducerSpanChildFromParent(ctx *fasthttp.RequestCtx, parentSpan trace.Span) trace.Span

func TraceStateFromW3CString added in v0.8.0

func TraceStateFromW3CString(h string) *trace.TraceState

TraceStateFromW3CString extracts a span tracestate from given string which got earlier from TraceStateFromW3CString format.

func TraceStateToW3CString added in v0.10.0

func TraceStateToW3CString(sc trace.SpanContext) string

TraceStateToW3CString extracts the TraceState from given SpanContext and returns its string representation.

func UpdateSpanStatusFromGRPCError added in v0.8.0

func UpdateSpanStatusFromGRPCError(span trace.Span, err error)

UpdateSpanStatusFromGRPCError updates tracer span status based on error object.

func UpdateSpanStatusFromHTTPStatus added in v0.8.0

func UpdateSpanStatusFromHTTPStatus(span trace.Span, code int)

UpdateSpanStatusFromHTTPStatus updates trace span status based on response code.

Types

type DaprTraceSampler added in v1.9.3

type DaprTraceSampler struct {
	sdktrace.Sampler
	ProbabilitySampler sdktrace.Sampler
	SamplingRate       float64
}

func NewDaprTraceSampler added in v1.9.3

func NewDaprTraceSampler(samplingRateString string) *DaprTraceSampler

func (*DaprTraceSampler) Description added in v1.9.3

func (d *DaprTraceSampler) Description() string

func (*DaprTraceSampler) ShouldSample added in v1.9.3

*

  • Decisions for the Dapr sampler are as follows:
  • - parent has sample flag turned on -> sample
  • - parent has sample turned off -> fall back to probability-based sampling

type PolicyType added in v1.9.0

type PolicyType string
var (
	CircuitBreakerPolicy PolicyType = "circuitbreaker"
	RetryPolicy          PolicyType = "retry"
	TimeoutPolicy        PolicyType = "timeout"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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