Documentation ¶
Index ¶
- Constants
- Variables
- func ContextGetTags(ctx context.Context, s ...string) []tag.Mutator
- func ContextToSpanContext(ctx context.Context) (trace.SpanContext, bool)
- func ContextWithTag(ctx context.Context, s ...interface{}) context.Context
- func ContextWithTelemetry(from, to context.Context) context.Context
- func Current(ctx context.Context, tags ...trace.Attribute) *trace.Span
- func DumpContext(ctx context.Context) string
- func End(ctx context.Context, _ http.ResponseWriter, _ *http.Request) (context.Context, error)
- func FindAndRegisterViewLast(nameInput string, tags []tag.Key) (*view.View, error)
- func FindAndRegisterViewLastFloat64(nameInput string, tags []tag.Key) (*view.View, error)
- func Init(ctx context.Context, cfg Configuration, s Service) (context.Context, error)
- func LinkTo(ctx context.Context, traceID [16]byte)
- func MainSpan(ctx context.Context) *trace.Span
- func MustNewKey(s string) tag.Key
- func New(ctx context.Context, s Service, name string, sampler trace.Sampler, ...) context.Context
- func NewViewCount(name string, s *stats.Int64Measure, tags []tag.Key) *view.View
- func NewViewLast(name string, s *stats.Int64Measure, tags []tag.Key) *view.View
- func NewViewLastFloat64(name string, s *stats.Float64Measure, tags []tag.Key) *view.View
- func NewWithRequest(ctx context.Context, s Service, w http.ResponseWriter, req *http.Request, ...) (context.Context, error)
- func ParseSampled(sampled string) (trace.TraceOptions, bool)
- func ParseSpanID(sid string) (spanID trace.SpanID, ok bool)
- func ParseTraceID(tid string) (trace.TraceID, bool)
- func Record(ctx context.Context, m stats.Measure, v int64)
- func RecordFloat64(ctx context.Context, m stats.Measure, v float64)
- func RegisterView(ctx context.Context, views ...*view.View) error
- func Span(ctx context.Context, name string, tags ...trace.Attribute) (context.Context, func())
- func SpanContextToContext(ctx context.Context, sc trace.SpanContext) context.Context
- func SpanFromMain(ctx context.Context, name string, tags ...trace.Attribute) (context.Context, func())
- func Tag(key string, value interface{}) trace.Attribute
- func TraceExporter(ctx context.Context) trace.Exporter
- type Configuration
- type ExposedView
- type HTTPExporter
- type HTTPExporterView
- type Options
- type Service
Constants ¶
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
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.
const ( Host = "http.host" StatusCode = "http.status" Path = "http.path" Method = "http.method" Handler = "http.handler" RequestID = "http.request-id" )
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 ¶
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) )
var DefaultFormat propagation.HTTPFormat = &b3.HTTPFormat{}
DefaultFormat used by observability as: observability.DefaultFormat.SpanContextToRequest
Functions ¶
func ContextToSpanContext ¶
func ContextToSpanContext(ctx context.Context) (trace.SpanContext, bool)
ContextToSpanContext instanciates a span context from a context.Context
func FindAndRegisterViewLast ¶
FindAndRegisterViewLast begins collecting data for the given views
func FindAndRegisterViewLastFloat64 ¶
FindAndRegisterViewLastFloat64 begins collecting data for the given views
func MustNewKey ¶
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 ¶
NewViewCount creates a new view via aggregation Count()
func NewViewLast ¶
NewViewLast creates a new view via aggregation LastValue()
func NewViewLastFloat64 ¶
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 ¶
ParseSpanID parses the value of the X-B3-SpanId or X-B3-ParentSpanId headers.
func ParseTraceID ¶
ParseTraceID parses the value of the X-B3-TraceId header.
func RecordFloat64 ¶
RecordFloat64 a float64 measure
func RegisterView ¶
RegisterView begins collecting data for the given views
func SpanContextToContext ¶
SpanContextToContext merge a span context in a context
func SpanFromMain ¶
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 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)