op

package
v0.19.921 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package op provides the primitive used to wrap individual tool / SDK call sites so the runner can build a tool-call graph for each job execution.

Each Start call opens a span as a child of whatever span is already on the context (typically the per-step span opened in jobloop, which is itself a child of the per-execution root span). The returned context has:

  1. The span installed via otel trace context (so any nested op.Start uses it as a parent automatically).
  2. A logger derived from the contextual logger that injects the *Go context* itself as a zap field. The otelzap bridge inspects fields and, when one carries a context.Context, uses it as the emit context. That is the documented mechanism for promoting trace_id / span_id into the dedicated OTLP log record fields (otel_log_records.trace_id / otel_log_records.span_id) instead of the Map fallback.

Stamp every span with runner_job_id / runner_job_execution_id / step name from pkgctx.JobMetadata: OTEL span attributes do not inherit from parents, so the CH ingest path can only populate the dedicated columns when each span carries them directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, tool, operation string, fn func(ctx context.Context) error, attrs ...attribute.KeyValue) error

Run is sugar around Start for the common case where the caller does not need the wrapped context for anything other than the closure body.

Types

type EndFunc

type EndFunc func(err error)

EndFunc finalizes the span. Pass the final error (or nil); status code is set to Error iff err != nil so dashboards can colorize failed nodes.

func Runner

func Runner(ctx context.Context, operation string, attrs ...attribute.KeyValue) (context.Context, EndFunc)

Runner wraps Start for runner-internal operations (jobloop helpers, calls into the ctl-api runner client, monitor goroutines). nuon.tool is fixed to "runner" so every runner-internal span lands under one filter value in the dashboard.

func Start

func Start(ctx context.Context, tool, operation string, attrs ...attribute.KeyValue) (context.Context, EndFunc)

Start opens a child span named "<tool>.<operation>" and returns a context that carries (a) the span and (b) a logger whose emit context is the same context — see package doc for why that matters.

Callers should always defer the returned EndFunc with the final error:

ctx, end := op.Start(ctx, "terraform", "plan")
defer end(err)

func Tool

func Tool(ctx context.Context, tool, operation string, attrs ...attribute.KeyValue) (context.Context, EndFunc)

Tool wraps Start for tool callsites (terraform, helm, kubernetes_manifest, job, git, oci, docker, action). Functionally identical to Start; use it at tool sites so the intent reads at the callsite and stays symmetric with Runner / Cloud below.

Jump to

Keyboard shortcuts

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