OpenTelemetry from the GitOps controller¶
Maturity: experimental
The controller’s OpenTelemetry is new in 0.16.0. Span, event, attribute and metric names may change in a minor release, with a changelog entry. See the Roadmap for every feature’s status.
The composition controller (GitOps: Piceli’s controller and manifest export) can send what it does to an OpenTelemetry Collector, or any backend that accepts OTLP: one trace per deploy with a span per stage, events (log records) for approvals, rollouts, rollbacks, failed checks, failed builds and stops, and metrics for run durations, results, builds, checks and the controller’s heartbeat. A dashboard can then place a deploy marker on the workloads a run changed, show where its time went, and alert on failures or a silent controller.
It is off unless you configure it, it never blocks or fails a
deploy, and it never exports a secret. The names follow the
OpenTelemetry semantic conventions
v1.43.0 (CI/CD, VCS, deployment, Kubernetes and events); where no
convention exists the attribute is piceli.*.
For piceli deploy and piceli release on a laptop or in CI, see
Deploy events to OpenTelemetry (a different, SDK-free export of one run).
Turn it on¶
Declare where to send it on the controller of the composition’s cluster:
from piceli.infra import Cluster, Controller, Otlp
cluster = Cluster(
"my-cluster",
api="https://10.0.0.1:6443",
credentials="my-cluster",
controller=Controller(
on="node-a",
telemetry=Otlp(
"https://collector.observability:4317",
protocol="grpc", # or "http/protobuf" (port 4318)
headers_secret="otlp-auth", # optional: auth headers
ca_secret="otlp-ca", # optional: the endpoint's CA
),
),
)
Then create the Secrets in the controller’s namespace (piceli-system by
default) and run piceli gitops enable as usual (plan, then approve):
# One key per header; the value is read from a file, never typed on the command line.
kubectl -n piceli-system create secret generic otlp-auth \
--from-file=authorization=./otlp-authorization.txt # e.g. "Bearer <token>"
kubectl -n piceli-system create secret generic otlp-ca --from-file=ca.crt=./ca.crt
piceli gitops enable infra.py … # plan, then --approve HASH
|
Meaning |
|---|---|
|
|
|
|
|
A Secret whose keys are header names and values header values ( |
|
A Secret with |
|
|
|
A CA file on the machine that exports, for a merge train (OpenTelemetry). The controller refuses it: give it |
gitops enable puts the setting in the controller’s configuration (only
when it is set, so the configuration hash of a controller without telemetry
does not change) and mounts the Secrets; their values never enter the
configuration, the plan, a log line or an attribute. A changed setting rolls
the controller. An invalid one is refused with cluster-invalid when the
composition is imported.
Without Controller(telemetry=...), the standard variables configure it
when the controller’s environment has them (OTEL_EXPORTER_OTLP_ENDPOINT
or a per-signal OTEL_EXPORTER_OTLP_TRACES_ENDPOINT /
_LOGS_ENDPOINT / _METRICS_ENDPOINT, with OTEL_EXPORTER_OTLP_PROTOCOL,
_HEADERS, _CERTIFICATE, _TIMEOUT read by the OpenTelemetry SDK; the
protocol defaults to http/protobuf). This is for piceli gitops run
outside the cluster. OTEL_SDK_DISABLED=true turns telemetry off either
way.
The controller image includes the telemetry extra (the OpenTelemetry SDK
and its OTLP gRPC and HTTP exporters). Installing Piceli yourself:
pip install "piceli[telemetry]".
Traces¶
One trace per pipeline run: one environment’s deploy of one revision,
from the step that starts it to its result. A run that waits for an
approval stays open: the approval wait is a span of it, and the deploy after
the approval continues the same trace. A run whose build a build host
still builds stays open the same way (0.74.0): the steps that find the
build in progress end no run, and the step after the delivery continues
the same trace. A retry after a failure is a run of its own
(piceli.run.attempt). A newer revision arriving while a run waits for its
approval or its build closes it as superseded (cancellation, status
unset, its unfinished builds cancellation).
Span |
Kind |
Parent |
When |
|---|---|---|---|
|
SERVER |
— |
The run ( |
|
INTERNAL |
root |
Each image built or mirrored ( |
|
INTERNAL |
root |
From the plan asking for approval to |
|
INTERNAL |
root |
The deploy’s plan stage. |
|
INTERNAL |
root |
Restore points ( |
|
INTERNAL |
root |
Pre-rollout and upgrade checks (Pre-rollout checks). |
|
INTERNAL |
root |
The release applied. |
|
INTERNAL |
|
Objects the release no longer declares, deleted (only when there were). |
|
INTERNAL |
root |
The post-deploy checks ( |
|
INTERNAL |
|
One check: its outcome and, when it failed, its detail line. |
|
INTERNAL |
root |
The previous release re-applied after failed checks. |
|
SERVER |
— |
A named environment stopped (or a branch environment stopped when idle). |
|
SERVER |
— |
A stopped environment started. |
|
SERVER |
— |
A branch environment removed (or a placement leaving a cluster). |
A span’s status is OK when its task succeeded, ERROR (with the error
code as message) when it failed, and unset for a skipped stage or a
cancelled run or build. Only a build that failed carries
error.type = component-build-failed.
Times¶
Every start and end is a recorded time, never an estimate:
plan,restore point,pre-rollout,applyandchecks: the run journal’sstarted_atandfinished_atof that stage;build <image>: the controller’s clock when it started the build Job and when the image came back (one Job builds several images, so they share its start); a build entry’s ownstarted_at/finished_atwin when the record has them. A build that waited for a build host is one span from the first step that asked for it to its end (the start of the step that found it delivered);approval wait: when the plan asked and when the approval arrived;check <name>: laid out from thechecksstage’s start in the order the checks ran, each as long as its recorded duration;rollbackandprune: the journal’s ownstarted_at/finished_atof the rollback (in the checks stage’s output) and of the prune (in the apply’s execution). A journal without them (written before 0.16) gives the rollback the rest of thechecksstage after the last check, and the prune theapplywindow;the root: from the start of the run’s first step to the end of its last.
Root span attributes¶
Attribute |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
The registered error code when it did not succeed ( |
|
The environment. |
|
|
|
|
|
The first source (by name): its commit, branch or tag name, |
|
Every source of the revision, sorted by name, with its commit and followed ref at the same index. |
|
What started it ( |
|
Who approved: |
|
The release applied; the approved plan hash. |
|
|
|
The attempt of this revision; |
|
The environment’s namespace. |
|
The Deployment or StatefulSet the run created or changed, when it is one. |
|
All of them. |
|
The cluster of a placement, for an environment on several clusters. |
Stage spans carry cicd.pipeline.task.name, cicd.pipeline.task.run.id,
cicd.pipeline.task.run.result (success, failure, error, skip,
cancellation), cicd.pipeline.task.type, piceli.stage, error.type
and the run’s cicd.pipeline.name, cicd.pipeline.run.id,
deployment.environment.name and k8s.namespace.name. Build spans add
piceli.image and piceli.image.digest; check spans piceli.check.name,
piceli.check.type, piceli.check.attempts and, when failed,
piceli.check.detail (its short detail line, at most 300 characters);
rollback adds piceli.rollback.from, .to and .state; prune adds
piceli.pruned (Kind/name) and piceli.pruned.count; apply adds the
k8s.* workloads and piceli.release.id.
Events¶
Events are OpenTelemetry log records with an event name (the
EventName field of OTLP log records) and a short display body, emitted
when they happen and correlated to the run’s trace and to the span they
belong to. Severity is INFO, or ERROR for failures.
Event |
Span |
Attributes (besides the common ones) |
|---|---|---|
|
— |
|
|
root |
|
|
the stage’s span |
|
|
root |
|
|
root |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root |
Once per run, when its build waits for a build host: |
|
|
|
|
|
|
|
|
— |
|
root |
|
|
root |
The release marker of a deploy that applied a release (and of a published |
Common attributes: piceli.event.id, cicd.pipeline.name,
cicd.pipeline.run.id, deployment.environment.name,
k8s.namespace.name, piceli.cluster.
piceli.event.id is stable: <cluster>:<env>/<run>:<what> (for
example my-cluster:main/20261004T101500123Z:rolled:1;
<cluster>:controller/<start>:started for the controller). An event sent
again carries the same id, so a backend can drop the duplicate.
Metrics¶
Metric |
Type |
Unit |
Attributes |
|---|---|---|---|
|
Histogram |
|
|
|
UpDownCounter |
|
|
|
Counter |
|
|
|
UpDownCounter |
|
|
|
Histogram |
|
|
|
Counter |
|
|
|
Histogram |
|
|
|
Histogram |
|
time from a wanted revision to its deploy step; |
|
Gauge |
|
environments due for a deploy step |
|
Gauge |
|
seconds since the environment’s last successful deploy; |
|
Gauge |
|
Unix time of the controller’s last heartbeat |
|
Counter |
|
— |
The heartbeat comes from a background thread every 15 seconds, so it keeps
ticking while a step runs for minutes (a long build): alert when
piceli.controller.heartbeats stops increasing. Metrics are exported every
30 seconds.
The resource of every signal: service.name = piceli-controller,
service.version, service.namespace = piceli, service.instance.id (the
pod), k8s.cluster.uid (the kube-system namespace’s UID, when the
controller may read it), k8s.cluster.name (the composition’s cluster) and
piceli.controller.namespace.
Development runs¶
With development builds (0.18.0, Development builds), the controller runs their queue and sends each finished run as its own trace:
root span
DEV <profile> <requester>(from the run’s creation to its end; statusERRORunless it passed), withpiceli.dev.run,piceli.dev.requester,piceli.dev.priority,piceli.dev.profile,piceli.dev.state,piceli.dev.exit_code,error.type,piceli.dev.queue.wait(seconds),piceli.dev.cache.lineage,piceli.dev.cache.warm,piceli.dev.cache.crates_compiled,piceli.dev.cache.hit_ratio,piceli.dev.tests.passedandpiceli.dev.tests.failed;child spans
queue(created to started) and, one after the other from the start,sync,fetch,buildandtest(their durations as the run measured them);the event
piceli.dev.run.finishedon the root span (same attributes);histograms
piceli.dev.run.duration(by profile and state) andpiceli.dev.queue.wait(by priority).
Nix host releases¶
Each attempt of a NixRelease (0.25.0, see GitOps: Piceli’s controller and manifest export) that ends,
published or failed, is a trace of its own: the root span PUBLISH <name> <tag> (from the tag’s sight to the end; status ERROR unless published)
with piceli.nix.release, piceli.nix.tag, vcs.ref.head.revision,
piceli.nix.state, piceli.nix.builder, piceli.nix.build_host,
piceli.nix.trigger, piceli.nix.manifest_sha256 and error.type; a child
span per stage (approval, queue, fetch, build, publish); and the
event piceli.nix.release.finished on the root span. A published release also sends
the release marker piceli.release (0.38.0, Deploy events to OpenTelemetry).
A controller restart¶
The open run (its ids, start, stage marks and the events it sent) is kept
in the controller’s state volume (telemetry/runs.json); the heartbeat
writes its time there too. Trace and span ids are derived from the cluster,
the environment and the run (a SHA-256), so a run’s ids never change.
When the controller dies inside a run (a node lost, the pod killed), the
next controller closes that run at start as interrupted
(cicd.pipeline.result = error), in the same trace, ending at the last
heartbeat (a run journal marked interrupted gives the same result); the run’s events are sent again (same piceli.event.id) with a
piceli.deploy.interrupted event, then the environment’s deploy runs again
as a new run. A run waiting for an approval is not interrupted: it continues
after the restart.
Failure behaviour¶
Telemetry is off the deploy path:
spans and events go to bounded in-memory queues (2048 per signal); the SDK exports them in background threads in batches, each export bounded to 5 seconds with the exporter’s own retries inside that time; when the queue is full, new data is dropped;
spans and events the endpoint refuses are spooled (0.17.0): each refused batch is written as its OTLP request to the controller’s state volume (
telemetry/spool/traces,telemetry/spool/logs; at most 64 MiB per signal, the oldest dropped first) and sent again, oldest first and with its original timestamps, after the next successful export and on the heartbeat (at most every 30 seconds while the endpoint stays away). A controller whose deploy stops its own receiver (an app that observes the cluster) no longer loses that deploy’s trace. Metrics are not spooled: the next reading carries the totals;every hook catches its own errors: a telemetry problem logs one line per kind (
telemetry: step end skipped (…)) and the deploy goes on;a configuration that cannot work logs
telemetry: off (…)once at start and the controller runs without telemetry; failed exports log one error line per batch (retries are not logged);shutting down flushes for at most 5 seconds.
Header values and the CA are read from the mounted files at start. They are
never printed, logged, written to the configuration or put in an attribute;
the build log tail of piceli.build.failed is the redacted tail the status
already shows.
Semantic conventions¶
Followed: CI/CD spans and metrics
(cicd.pipeline.*, cicd.pipeline.run.*, cicd.pipeline.task.*,
cicd.worker.*), VCS
(vcs.ref.head.*, vcs.repository.name),
deployment
(deployment.environment.name, deployment.id, deployment.status),
Kubernetes resource attributes (k8s.cluster.*, k8s.namespace.name,
k8s.deployment.name, k8s.statefulset.name) and
events
(log records with an event name), all at v1.43.0, schema URL
https://opentelemetry.io/schemas/1.43.0. As the Collector’s GitHub
receiver does for workflow runs, trace and span ids are derived from the
run’s identity.
Choices where the conventions leave room:
a run has several sources: the
vcs.*attributes name the first one, andpiceli.sources/.source.revisions/.source.refslist all;task spans have no
cicd.pipeline.task.run.url.full(the controller serves no URL per task);a run changes several workloads:
k8s.deployment.name/k8s.statefulset.nameonly when there is one,piceli.k8s.*lists all;events use the log record’s event name field (the
event.nameattribute is deprecated in these conventions);UIDs of the workloads are not looked up (one more API read per object).