telemetry

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagGoroutine          = "goroutine"
	TagHostname           = "hostname"
	TagJob                = "job"
	TagRepository         = "repository"
	TagRepositoryID       = "repository_id"
	TagVCSServer          = "vcs_server"
	TagVCSServerID        = "vcs_server_id"
	TagPercentil          = "percentil"
	TagPermission         = "permission"
	TagPipeline           = "pipeline"
	TagPipelineDeep       = "pipeline_deep"
	TagPipelineID         = "pipeline_id"
	TagProjectKey         = "project_key"
	TagRegion             = "region"
	TagServiceName        = "service_name"
	TagServiceType        = "service_type"
	TagStatus             = "status"
	TagStorage            = "storage"
	TagType               = "type"
	TagWorker             = "worker"
	TagWorkerModel        = "worker_model"
	TagWorkflow           = "workflow"
	TagWorkflowNode       = "workflow_node"
	TagWorkflowNodeJobRun = "workflow_node_job_run"
	TagWorkflowNodeRun    = "workflow_node_run"
	TagWorkflowRun        = "workflow_run"
	TagWorkflowRunNumber  = "run_number"
	TagEventID            = "event_id"
)

Tags contants

View Source
const (
	HostAttribute      = "http.host"
	MethodAttribute    = "http.method"
	PathAttribute      = "http.path"
	UserAgentAttribute = "http.user_agent"
)

Attributes recorded on the span for the requests. Only trace exporters will need them.

View Source
const (
	Host       = "http.host"
	StatusCode = "http.status"
	Path       = "http.path"
	Method     = "http.method"
	Handler    = "http.handler"
	RequestID  = "http.request-id"
)
View Source
const (
	TraceIDHeader = "X-B3-TraceId"
	SpanIDHeader  = "X-B3-SpanId"
	SampledHeader = "X-B3-Sampled"

	ContextTraceIDHeader contextKey = iota
	ContextSpanIDHeader
	ContextSampledHeader
	ContextMainSpan
)

B3 headers that OpenCensus understands.

Variables

View Source
var (
	// DefaultSizeDistribution 25k, 100k, 250, 500, 1M, 1.5M, 5M, 10M,
	DefaultSizeDistribution = view.Distribution(25*1024, 100*1024, 250*1024, 500*1024, 1024*1024, 1.5*1024*1024, 5*1024*1024, 10*1024*1024)
	// DefaultLatencyDistribution 100ms, ...
	DefaultLatencyDistribution = view.Distribution(100, 200, 300, 400, 500, 750, 1000, 2000, 5000)
)

DefaultFormat used by observability as: observability.DefaultFormat.SpanContextToRequest

Functions

func ContextGetTags

func ContextGetTags(ctx context.Context, s ...string) []tag.Mutator

func ContextToSpanContext

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

ContextToSpanContext instanciates a span context from a context.Context

func ContextWithTag

func ContextWithTag(ctx context.Context, s ...interface{}) context.Context

func ContextWithTelemetry

func ContextWithTelemetry(from, to context.Context) context.Context

func Current

func Current(ctx context.Context, tags ...trace.Attribute) *trace.Span

Current return the current span

func DumpContext

func DumpContext(ctx context.Context) string

DumpContext is an helper function

func End

End may close a tracing span

func FindAndRegisterViewLast

func FindAndRegisterViewLast(nameInput string, tags []tag.Key) (*view.View, error)

FindAndRegisterViewLast begins collecting data for the given views

func FindAndRegisterViewLastFloat64

func FindAndRegisterViewLastFloat64(nameInput string, tags []tag.Key) (*view.View, error)

FindAndRegisterViewLastFloat64 begins collecting data for the given views

func Init

Init the opencensus exporter

func LinkTo

func LinkTo(ctx context.Context, traceID [16]byte)

LinkTo a traceID

func MainSpan

func MainSpan(ctx context.Context) *trace.Span

func MustNewKey

func MustNewKey(s string) tag.Key

func New

func New(ctx context.Context, s Service, name string, sampler trace.Sampler, spanKind int) context.Context

New may start a tracing span

func NewViewCount

func NewViewCount(name string, s *stats.Int64Measure, tags []tag.Key) *view.View

NewViewCount creates a new view via aggregation Count()

func NewViewLast

func NewViewLast(name string, s *stats.Int64Measure, tags []tag.Key) *view.View

NewViewLast creates a new view via aggregation LastValue()

func NewViewLastFloat64

func NewViewLastFloat64(name string, s *stats.Float64Measure, tags []tag.Key) *view.View

NewViewLastFloat64 creates a new view via aggregation LastValue()

func NewWithRequest added in v0.52.0

func NewWithRequest(ctx context.Context, s Service, w http.ResponseWriter, req *http.Request, opt Options) (context.Context, error)

Start may start a tracing span

func ParseSampled

func ParseSampled(sampled string) (trace.TraceOptions, bool)

ParseSampled parses the value of the X-B3-Sampled header.

func ParseSpanID

func ParseSpanID(sid string) (spanID trace.SpanID, ok bool)

ParseSpanID parses the value of the X-B3-SpanId or X-B3-ParentSpanId headers.

func ParseTraceID

func ParseTraceID(tid string) (trace.TraceID, bool)

ParseTraceID parses the value of the X-B3-TraceId header.

func Record

func Record(ctx context.Context, m stats.Measure, v int64)

Record an int64 measure

func RecordFloat64

func RecordFloat64(ctx context.Context, m stats.Measure, v float64)

RecordFloat64 a float64 measure

func RegisterView

func RegisterView(ctx context.Context, views ...*view.View) error

RegisterView begins collecting data for the given views

func Span

func Span(ctx context.Context, name string, tags ...trace.Attribute) (context.Context, func())

Span start a new span from the parent context

func SpanContextToContext

func SpanContextToContext(ctx context.Context, sc trace.SpanContext) context.Context

SpanContextToContext merge a span context in a context

func SpanFromMain

func SpanFromMain(ctx context.Context, name string, tags ...trace.Attribute) (context.Context, func())

func Tag

func Tag(key string, value interface{}) trace.Attribute

Tag is helper function to instantiate trace.Attribute

func TraceExporter

func TraceExporter(ctx context.Context) trace.Exporter

Types

type Configuration

type Configuration struct {
	TracingEnabled bool `toml:"tracingEnabled" json:"tracingEnabled"`
	Exporters      struct {
		Jaeger struct {
			ServiceName         string  `toml:"serviceName" default:"" json:"serviceName"`
			CollectorEndpoint   string  `toml:"collectorEndpoint" default:"http://localhost:14268/api/traces" json:"collectorEndpoint"`
			SamplingProbability float64 `toml:"samplingProbability" json:"metricSamplingProbability"`
		} `json:"jaeger"`
		Prometheus struct {
			ReporteringPeriod int `toml:"ReporteringPeriod" default:"10" json:"reporteringPeriod"`
		} `json:"prometheus"`
	} `json:"exporter"`
}

Configuration is the global tracing configuration

type ExposedView

type ExposedView struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`
	Dimension   string   `json:"dimension"`
	Aggregation string   `json:"aggregagtion"`
}

type HTTPExporter

type HTTPExporter struct {
	*prometheus.Exporter `json:"-"`
	ExposedViews         []ExposedView `json:"-"`

	Views []HTTPExporterView
	// contains filtered or unexported fields
}

func StatsExporter

func StatsExporter(ctx context.Context) *HTTPExporter

func (*HTTPExporter) ExportView

func (e *HTTPExporter) ExportView(vd *view.Data)

func (*HTTPExporter) GetView

func (e *HTTPExporter) GetView(name string, tags map[string]string) *HTTPExporterView

func (*HTTPExporter) NewView

func (e *HTTPExporter) NewView(name string, tags map[string]string) *HTTPExporterView

type HTTPExporterView

type HTTPExporterView struct {
	Name  string            `json:"name"`
	Tags  map[string]string `json:"tags"`
	Value float64           `json:"value"`
	Date  time.Time         `json:"date"`
}

func (*HTTPExporterView) Record

func (v *HTTPExporterView) Record(data view.AggregationData)

type Options

type Options struct {
	Init     bool
	Name     string
	SpanKind int
}

Options is the options struct for a new tracing span

type Service

type Service interface {
	Name() string
	Type() string
}

Jump to

Keyboard shortcuts

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