How can opscotch partake in the OpenTelemetry flow?
· One min read
Version 3.1.0 adds OpenTelemetry support so opscotch can join your existing traces. Enable it with an environment variable and annotate traces from JavaScript processors.
- Enable OTEL by setting
OPSCOTCH_OTEL_PROPERTIES:- Format:
endpoint=<http endpoint>;type=grpc;environment=<env> endpointandtype=grpcare required;environmentis optional.
- Format:
- All step triggers have
noTrace(boolean) to exclude those executions from OTEL. - opscotch HTTP will accept incoming OTEL trace headers and propagate/emit trace headers on outgoing HTTP.
- In JavaScript processors, use
context.diagnostic()to add attributes/events or mark errors on the current trace.
Example: add attributes and events from a processor
let diag = context.diagnostic();
diag.setAttribute("workflow.id", context.getWorkflowId());
diag.setAttribute("payload.size", 1234); // int
diag.setAttribute("latency_ms", 12.5); // double
diag.event("processing_started");
try {
// your logic here
} catch (e) {
diag.errored("processor_error", e.message);
context.addSystemError("Processing failed: " + e.message); // see error-handling post
throw e;
}
Want structured error handling inside the workflow too? See How can I work with errors in JavaScript processors?.
Skipping trace for a trigger
{
"steps": [
{
"trigger": {
"http": {
"server": "myServer",
"path": "/healthz",
"noTrace": true
}
}
}
]
}
With OTEL enabled, opscotch will accept and propagate trace headers, and you can enrich traces directly in processors using context.diagnostic().