tracing

package module
v0.0.0-...-6a0c478 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 16 Imported by: 1

Documentation

Overview

Package tracing provides a simple utility for including opentelemetry and zipkin tracing instrumentation in vHive and Knative workloads

Package tracing provides a simple utility for including opentelemetry and zipkin tracing instrumentation in vHive and Knative workloads

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialGRPCWithUnaryInterceptor

func DialGRPCWithUnaryInterceptor(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialGRPCWithUnaryInterceptor creates a connection to the provided address, which is instrumented with an opentelemetry client interceptor enabling the tracing to client grpc messages.

func GetGRPCServerWithUnaryInterceptor

func GetGRPCServerWithUnaryInterceptor() *grpc.Server

GetGRPCServerWithUnaryInterceptor returns a grpc server instrumented with an opentelemetry interceptor which enables tracing of grpc requests.

func InitBasicTracer

func InitBasicTracer(url string, serviceName string) (func(), error)

InitBasicTracer initialises a basic OpenTelemetry tracer using a zipkin exporter. The exporter sends span and trace information to the provided URL. The tracer uses the name provided, concatenated with the name of the host (e.g., Knative pod name or docker container), and all nodes / functions which use this tracer will be labeled with "-FU" to denote that they are functions, which distinguishes them from knative queue proxies if used in a cluster.

func InitCustomTracer

func InitCustomTracer(url string, traceRate float64, logger *log.Logger, attr ...attribute.KeyValue) (func(), error)

InitCustomTracer initialises an OpenTelemetry tracer. It uses a zipkin exporter which exports to the given URL and logger, and samples traces at the specified traceRate. Any number of additional attributes (attr) can be provided. Note that this tracer uses the default name, which will be the name of the process according to the OS, so to name your tracer provide a "service.name" attribute.

func IsTracingEnabled

func IsTracingEnabled() bool

Types

type Span

type Span struct {
	SpanName, TracerName string
	// contains filtered or unexported fields
}

Span is an abstraction for making multiple custom OpenTelemetry spans within a single component (e.g., within processing a single request by a server). Spans can be used to indicate what a process is working on as time progresses, and can be given a name to distinguish them. Spans are used in a hierarchy, whereby one "parent" span can have many "child" spans, and typially the parent span will be "running" for the duration of all its children spans (or potentially longer). This hierarchy is visible within zipkin.

func (*Span) EndSpan

func (s *Span) EndSpan()

EndSpan marks the span as finished at the time when this function is called.

func (*Span) StartSpan

func (s *Span) StartSpan(ctx context.Context) context.Context

StartSpan starts the span. A context, ctx, is used here to determine any parent spans, IDs, etc. A context is also returned, and it should be given as input to other spans if they should be marked as the chidlren of this span. This is how a parent / child hierarchy can be built between multiple spans in your functions.

Jump to

Keyboard shortcuts

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