tracing

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tracing carries OpenTelemetry trace context and baggage through the engine, as the other platform services do with gin-middleware/otelx: incoming requests, outgoing requests to platform services, log records and the background execution of instances.

Index

Constants

View Source
const (
	KeyInstanceId   = "automation_instance_id"
	KeyDeploymentId = "automation_deployment_id"
	KeyNamespace    = "automation_namespace"
	KeyUserId       = "user_id"
)

Baggage keys of the engine; the prefix keeps them apart from ids of other services, e.g. the smart_service_instance_id of smart-service-repository. user_id and username come from otelx.

View Source
const Off = "off"

Off disables tracing as value of the otel endpoint.

View Source
const ServiceName = "automation-engine"

ServiceName is the OpenTelemetry service name of the engine.

Variables

This section is empty.

Functions

func End

func End(span trace.Span, err error)

End records err on span and ends it.

func Handler

func Handler(endpoint string, handler http.Handler) http.Handler

Handler traces incoming requests and takes over trace context and baggage of the caller; otelx adds user_id and username of the token to the baggage. With Off, handler is returned unchanged: otelx would set up its exporter on the first call.

func Init

func Init(ctx context.Context, endpoint string) error

Init sets up the OpenTelemetry exporter once per process. An empty endpoint selects the platform default of otelx; Off leaves tracing disabled, spans are then dropped.

func Inject

func Inject(ctx context.Context, req *http.Request) error

Inject writes trace context and baggage of ctx into a request to another platform service. Requests to targets outside the platform must not carry them, the baggage holds user ids.

func Start

func Start(ctx context.Context, name string, instance Instance, attributes ...attribute.KeyValue) (context.Context, trace.Span)

Start begins a span of background work for an instance, e.g. a task execution, and puts the instance into the baggage. Background work has no caller, so the span starts a trace of its own unless ctx carries one.

func WithBaggage

func WithBaggage(ctx context.Context, key string, value string) context.Context

WithBaggage returns ctx with key=value in its baggage and adds it to the active span. Values with spaces or invalid characters are left out, the baggage is a diagnostic aid and must not fail the work it describes.

Types

type Instance

type Instance struct {
	Namespace    string
	DeploymentId string
	InstanceId   string
	Owner        string
}

Instance identifies the work of an instance in the baggage, so that requests and log records caused by it can be traced back to it.

Jump to

Keyboard shortcuts

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