Describe where an operation is running¶
Source: R/observability.R ยท Help: ?operation_context
An operation context records where a failure happened, separately from what
failed. It is the R counterpart of the Python package's OperationContext,
with the same fields and the same rules, so a failure event from an R job
and one from a Python service can be filtered and correlated together.
Usage¶
operation_context(
system = NULL,
component = NULL,
operation = NULL,
request_id = NULL,
job_id = NULL,
correlation_id = NULL,
trace_id = NULL,
span_id = NULL
)
operation_index_fields(context)
Arguments¶
system,component,operation- Low-cardinality labels: the system, the component within it, and the operation being performed.
request_id,job_id,correlation_id- Identifiers of this run.
trace_id,span_id- Trace identifiers. To fill them from the active
OpenTelemetry span, use
operation_context_from_otel(). context- An operation context.
Value¶
operation_context() returns an object of class
dataexcept_operation_context: a named list holding only the fields that
were given, in the order above. operation_index_fields() returns the
same with only the label fields.
Details¶
The fields fall into two groups:
system,componentandoperationare labels. They should stay low-cardinality -- a route template such as"POST /users/{id}", a job name, a workflow step -- so they are safe to filter and group by.operation_index_fields()returns only these.request_id,job_id,correlation_id,trace_idandspan_ididentify one run. They are for correlating a specific execution and should not become metric dimensions or indexed tags.
Every field is optional: a missing identifier stays missing rather than being invented. URLs in any field lose their credentials and their path.
Examples¶
context <- operation_context(
system = "batch",
component = "billing",
operation = "settle_invoices",
job_id = "job-42"
)
context
operation_index_fields(context)
See also¶
condition_to_event(), which pairs a context with a condition.