telemetry

package
v0.0.0-...-f0cf5fe Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDeploymentRequestSpanAttributes

func AddDeploymentRequestSpanAttributes(span otrace.Span, request *pb.DeploymentRequest)

Copies interesting values from the deployment request onto the span, so it can be filtered in Grafana.

func New

func New(ctx context.Context, serviceName string, collectorEndpointURL string) (*trace.TracerProvider, error)

Initialize the OpenTelemetry library.

You MUST call `Shutdown()` on the tracer provider before exiting, lest traces are not sent to the collector.

func TraceID

func TraceID(ctx context.Context) string

TraceID extracts the trace ID from the context. If the context does not embed a trace, an empty string is returned.

func TraceParentHeader

func TraceParentHeader(ctx context.Context) string

TraceParentHeader extracts the trace parent header value from the context.

A trace parent header contains the following data:

Version - Trace ID - Span ID - Flags

00-3b03c24a4efad25e514890c874dc9e33-59c10f1945da62ca-01

func Tracer

func Tracer() otrace.Tracer

Returns the top-level tracer.

"Library Name" in Grafana will be set to the default value, which currently is the path to the Go OpenTelemetry library.

Panics when `New()` has not been called or returned with an error.

func WithTraceParent

func WithTraceParent(ctx context.Context, traceParent string) context.Context

Given a context and a trace parent header value, returns a new context that can be used to set up nested tracing.

Types

type PipelineTimings

type PipelineTimings struct {
	LatestCommit time.Time
	Start        time.Time
	BuildStart   time.Time
	AttestStart  time.Time
	End          time.Time
}

Holds timestamps from pipeline indicating when certain steps were started or finished. If `Validate()` returns nil, this object is safe to use and contains chronologically ordered timestamps for every field.

func ParsePipelineTelemetry

func ParsePipelineTelemetry(s string) (*PipelineTimings, error)

Parse pipeline build timings.

Uses the following input format:

latest_commit=1726040395,pipeline_start=1726050395,pipeline_end=1726050512,build_start=1726050400,attest_start=1726050492

This output usually comes from `docker-build-push.steps.output.telemetry`.

If there is no timing data, both return values will be nil. If all timing data is valid, returns a timings object and nil error.

func (*PipelineTimings) StartTracing

func (pt *PipelineTimings) StartTracing(ctx context.Context) (context.Context, otrace.Span)

Imports tracing data from the build pipeline and starts a new top-level trace.

The tracing data is generated by the GitHub action `docker-build-push`.

Callers MUST call `span.End()` in order to send traces to the collector.

func (*PipelineTimings) Validate

func (pt *PipelineTimings) Validate() error

Jump to

Keyboard shortcuts

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