OpenTelemetry
Send metrics, traces and logs from a script to an OpenTelemetry collector or any backend that reads OTLP over HTTP, in the JSON encoding of the specification: gauges, counters and histograms built from raw values, spans of a job linked to their parent, and log lines linked to a trace. The tokens of a backend stay in environment variables of the server, partial success answers are reported, and W3C traceparent headers can be read and built to follow a request across services. Typical uses: publish business indicators to Grafana or Datadog, trace a nightly job step by step, link the logs of a web service to its traces.
otel metricsotel metricsotel tracesotel tracesotel logsotel logsotel trace_idotel span_idotel traceparentotel traceparentotel traceparent_parseotel traceparent_parse

otel metrics <endpoint> <json_metrics>


Description

    Send metrics to an OTLP/HTTP receiver. Result: {signal, sent, status, host, path, items, bytes, rejected, partial_success, message}: rejected and message come from a partial success answer of the receiver (the items it refused and why)

Parameters

    endpoint:   The OTLP/HTTP endpoint of the collector, ex: http://127.0.0.1:4318 (/v1/metrics, /v1/traces or /v1/logs is added); empty with dry_run - String - required
    json_metrics:   The metrics: a JSON array of {name, type, value, ...} (or one object), or a request already in OTLP JSON ({"resourceMetrics": [...]}, sent as it is) - String - required
admin
otel metrics "http://127.0.0.1:14318" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]"
mentdb
{"signal": "metrics", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/metrics", "items": 3, "bytes": 898, "rejected": 0, "partial_success": false}
Fixed result from a local test receiver on 127.0.0.1 that answers this way on purpose: partial success: the receiver refused 2 data points
admin
otel metrics "http://127.0.0.1:14319/partial" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]"
mentdb
{"signal": "metrics", "sent": true, "status": 200, "host": "127.0.0.1:14319", "path": "/partial/v1/metrics", "items": 3, "bytes": 898, "rejected": 2, "partial_success": true, "message": "data point 3 has no value"}
Fixed result from a local test receiver on 127.0.0.1 that answers this way on purpose: a 400 answer with the message of the receiver
admin
otel metrics "http://127.0.0.1:14319/bad" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]"
mentdb
Sorry, an error appears (otel metrics: HTTP 400 from 127.0.0.1:14319 (the receiver refused the data): metric orders.processed: unsupported unit).
Fixed result from a local test receiver on 127.0.0.1 that answers this way on purpose: rate limited
admin
otel metrics "http://127.0.0.1:14319/limit" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]"
mentdb
Sorry, an error appears (otel metrics: HTTP 429 from 127.0.0.1:14319 (rate limited, retry after 30 seconds): too many).
Fixed result from a local test receiver on 127.0.0.1 that answers this way on purpose: a wrong path
admin
otel metrics "http://127.0.0.1:14319/nothing" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]"
mentdb
Sorry, an error appears (otel metrics: HTTP 404 from 127.0.0.1:14319 (not found: check the endpoint (the path ends with /v1/metrics unless path_as_is is true)): 404 page not found).

otel metrics <endpoint> <json_metrics> <json_params>


Description

    Send metrics with parameters: resource (the attributes of the service: {"service.name": "billing", "service.version": "4.2", ...}; service.name is mentdb when it is not given), scope_name (mentdb) and scope_version, secret_headers (the name of a secret (secret set) of the server that holds the headers, as OTEL_EXPORTER_OTLP_HEADERS: api-key=abc,x-tenant=a%20b), bearer_token (a variable that holds a token sent as Authorization: Bearer), headers (headers without secrets, ex: {"X-Scope-OrgID": "tenant-1"}; a name that looks like a secret is refused), allow_plain (false: a secret header is refused on plain http to a host that is not this machine), compression (none or gzip), timeout_ms (10000, 100 to 120000), path_as_is (false: true sends to the URL exactly as given), dry_run (false: true sends nothing, reads no secret, and gives the exact OTLP JSON), start_time (the default start of the sums and histograms). Result: {signal, sent, status, host, path, items, bytes, rejected, partial_success, message}: rejected and message come from a partial success answer of the receiver (the items it refused and why)

Parameters

    endpoint:   The OTLP/HTTP endpoint of the collector, ex: http://127.0.0.1:4318 (/v1/metrics, /v1/traces or /v1/logs is added); empty with dry_run - String - required
    json_metrics:   The metrics - String - required
    json_params:   The parameters - String - required
admin
otel metrics "" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"http.server.duration\", \"type\": \"histogram\", \"unit\": \"ms\", \"bounds\": [100, 500], \"counts\": [40, 7, 1], \"sum\": 6320, \"time\": \"2026-11-11T10:00:00Z\"}]" "{\"dry_run\": true, \"resource\": {\"service.name\": \"billing\"}}"
mentdb
{"signal": "metrics", "dry_run": true, "items": 2, "bytes": 693, "payload": {"resourceMetrics": [{"resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "billing"}}]}, "scopeMetrics": [{"scope": {"name": "mentdb"}, "metrics": [{"name": "orders.processed", "sum": {"dataPoints": [{"attributes": [{"key": "shop", "value": {"stringValue": "Paris"}}], "startTimeUnixNano": "1794355200000000000", "timeUnixNano": "1794391200000000000", "asInt": "1250"}], "aggregationTemporality": 2, "isMonotonic": true}}, {"name": "http.server.duration", "unit": "ms", "histogram": {"dataPoints": [{"timeUnixNano": "1794391200000000000", "count": "48", "sum": 6320, "bucketCounts": ["40", "7", "1"], "explicitBounds": [100, 500]}], "aggregationTemporality": 2}}]}]}]}}
dry_run: several points of one metric, with common attributes
admin
otel metrics "" "[{\"name\": \"stock.level\", \"type\": \"gauge\", \"unit\": \"{item}\", \"attributes\": {\"warehouse\": \"north\"}, \"time\": \"2026-11-11T10:00:00Z\", \"points\": [{\"value\": 120, \"attributes\": {\"sku\": \"A1\"}}, {\"value\": 7.5, \"attributes\": {\"sku\": \"B2\"}}]}]" "{\"dry_run\": true}"
mentdb
{"signal": "metrics", "dry_run": true, "items": 2, "bytes": 603, "payload": {"resourceMetrics": [{"resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "mentdb"}}]}, "scopeMetrics": [{"scope": {"name": "mentdb"}, "metrics": [{"name": "stock.level", "unit": "{item}", "gauge": {"dataPoints": [{"attributes": [{"key": "warehouse", "value": {"stringValue": "north"}}, {"key": "sku", "value": {"stringValue": "A1"}}], "timeUnixNano": "1794391200000000000", "asInt": "120"}, {"attributes": [{"key": "warehouse", "value": {"stringValue": "north"}}, {"key": "sku", "value": {"stringValue": "B2"}}], "timeUnixNano": "1794391200000000000", "asDouble": 7.5}]}}]}]}]}}
Fixed result from a real OpenTelemetry Collector 0.165.0 on 127.0.0.1 (OTLP/HTTP receiver): resource of the service
admin
otel metrics "http://127.0.0.1:14318" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]" "{\"resource\": {\"service.name\": \"billing\", \"service.version\": \"4.2\", \"deployment.environment.name\": \"production\"}}"
mentdb
{"signal": "metrics", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/metrics", "items": 3, "bytes": 1040, "rejected": 0, "partial_success": false}
Fixed result from a real OpenTelemetry Collector 0.165.0 on 127.0.0.1 (OTLP/HTTP receiver): gzip and a header without secret
admin
otel metrics "http://127.0.0.1:14318" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]" "{\"compression\": \"gzip\", \"headers\": {\"X-Scope-OrgID\": \"tenant-1\"}}"
mentdb
{"signal": "metrics", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/metrics", "items": 3, "bytes": 898, "sent_bytes": 403, "rejected": 0, "partial_success": false}
Fixed result from a local test receiver on 127.0.0.1 that answers this way on purpose: the headers come from the variable OTEL_EXPORTER_OTLP_HEADERS of the server (an api key): the key appears nowhere
admin
otel metrics "http://127.0.0.1:14319/partial" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]" "{\"secret_headers\": \"otel_exporter_otlp_headers\"}"
mentdb
{"signal": "metrics", "sent": true, "status": 200, "host": "127.0.0.1:14319", "path": "/partial/v1/metrics", "items": 3, "bytes": 898, "rejected": 2, "partial_success": true, "message": "data point 3 has no value"}
Nothing listens on this port (fixed result)
admin
otel metrics "http://127.0.0.1:14399" "[{\"name\": \"orders.processed\", \"type\": \"counter\", \"unit\": \"{order}\", \"description\": \"Orders processed since the start\", \"value\": 1250, \"attributes\": {\"shop\": \"Paris\"}, \"start_time\": \"2026-11-11T00:00:00Z\", \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"queue.size\", \"type\": \"gauge\", \"value\": 17, \"time\": \"2026-11-11T10:00:00Z\"}, {\"name\": \"import.duration\", \"type\": \"histogram\", \"unit\": \"s\", \"bounds\": [1, 5, 10, 30], \"values\": [0.8, 2.5, 4, 12, 45], \"time\": \"2026-11-11T10:00:00Z\"}]" "{\"timeout_ms\": 2000}"
mentdb
Sorry, an error appears (otel metrics: cannot connect to 127.0.0.1:14399 (refused)).
A counter cannot go down
admin
otel metrics "" "[{\"name\": \"orders\", \"type\": \"counter\", \"value\": -3}]" "{\"dry_run\": true}"
mentdb
ERROR: Sorry, an error appears (the value of the metric 'orders' is negative: a counter only goes up (use updown_counter or gauge)).
Used in use cases (1 recipe)

    System administrator & DevOps › Send the orders of the day to Grafana or Datadog as OpenTelemetry metrics

otel traces <endpoint> <json_spans>


Description

    Send spans to an OTLP/HTTP receiver. Result: {signal, sent, status, host, path, items, bytes, rejected, partial_success, message}: rejected and message come from a partial success answer of the receiver (the items it refused and why), and spans: the name, trace_id, span_id and parent_span_id of each span (1000 at most)

Parameters

    endpoint:   The OTLP/HTTP endpoint of the collector, ex: http://127.0.0.1:4318 (/v1/metrics, /v1/traces or /v1/logs is added); empty with dry_run - String - required
    json_spans:   The spans: a JSON array of {name, start_time, duration_ms, ...} (or one object), or a request already in OTLP JSON ({"resourceSpans": [...]}) - String - required
admin
otel traces "http://127.0.0.1:14318" "[{\"ref\": \"job\", \"name\": \"nightly import\", \"trace_id\": \"4bf92f3577b34da6a3ce929d0e0e4736\", \"span_id\": \"a3ce929d0e0e4736\", \"start_time\": \"2026-11-11T02:00:00Z\", \"duration_ms\": 3500, \"status\": \"ok\", \"attributes\": {\"rows\": 1200}}, {\"parent_ref\": \"job\", \"name\": \"SELECT orders\", \"span_id\": \"00f067aa0ba902b7\", \"kind\": \"client\", \"start_time\": \"2026-11-11T02:00:00.100Z\", \"duration_ms\": 1200, \"attributes\": {\"db.system\": \"mysql\"}}, {\"parent_ref\": \"job\", \"name\": \"POST /api/stock\", \"span_id\": \"b7ad6b7169203331\", \"kind\": \"client\", \"start_time\": \"2026-11-11T02:00:01.400Z\", \"duration_ms\": 900, \"status\": {\"code\": \"error\", \"message\": \"HTTP 503\"}, \"events\": [{\"name\": \"retry\", \"time\": \"2026-11-11T02:00:01.800Z\", \"attributes\": {\"attempt\": 2}}]}]"
mentdb
{"signal": "traces", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/traces", "items": 3, "bytes": 1188, "rejected": 0, "partial_success": false, "spans": [{"name": "nightly import", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "a3ce929d0e0e4736", "parent_span_id": null}, {"name": "SELECT orders", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "00f067aa0ba902b7", "parent_span_id": "a3ce929d0e0e4736"}, {"name": "POST /api/stock", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "b7ad6b7169203331", "parent_span_id": "a3ce929d0e0e4736"}]}

otel traces <endpoint> <json_spans> <json_params>


Description

    Send spans with parameters: resource (the attributes of the service: {"service.name": "billing", "service.version": "4.2", ...}; service.name is mentdb when it is not given), scope_name (mentdb) and scope_version, secret_headers (the name of a secret (secret set) of the server that holds the headers, as OTEL_EXPORTER_OTLP_HEADERS: api-key=abc,x-tenant=a%20b), bearer_token (a variable that holds a token sent as Authorization: Bearer), headers (headers without secrets, ex: {"X-Scope-OrgID": "tenant-1"}; a name that looks like a secret is refused), allow_plain (false: a secret header is refused on plain http to a host that is not this machine), compression (none or gzip), timeout_ms (10000, 100 to 120000), path_as_is (false: true sends to the URL exactly as given), dry_run (false: true sends nothing, reads no secret, and gives the exact OTLP JSON), traceparent (a W3C traceparent header: the spans join that trace). Result: {signal, sent, status, host, path, items, bytes, rejected, partial_success, message}: rejected and message come from a partial success answer of the receiver (the items it refused and why), and spans

Parameters

    endpoint:   The OTLP/HTTP endpoint of the collector, ex: http://127.0.0.1:4318 (/v1/metrics, /v1/traces or /v1/logs is added); empty with dry_run - String - required
    json_spans:   The spans - String - required
    json_params:   The parameters - String - required
admin
otel traces "" "[{\"ref\": \"req\", \"name\": \"GET /orders\", \"kind\": \"server\", \"span_id\": \"a3ce929d0e0e4736\", \"start_time\": \"2026-11-11T10:00:00Z\", \"duration_ms\": 85, \"attributes\": {\"http.request.method\": \"GET\", \"http.response.status_code\": 200}}, {\"parent_ref\": \"req\", \"name\": \"SELECT orders\", \"kind\": \"client\", \"span_id\": \"b7ad6b7169203331\", \"start_time\": \"2026-11-11T10:00:00.010Z\", \"duration_ms\": 40}]" "{\"dry_run\": true, \"traceparent\": \"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01\"}"
mentdb
{"signal": "traces", "dry_run": true, "items": 2, "bytes": 791, "spans": [{"name": "GET /orders", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "a3ce929d0e0e4736", "parent_span_id": "00f067aa0ba902b7"}, {"name": "SELECT orders", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "b7ad6b7169203331", "parent_span_id": "a3ce929d0e0e4736"}], "payload": {"resourceSpans": [{"resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "mentdb"}}]}, "scopeSpans": [{"scope": {"name": "mentdb"}, "spans": [{"traceId": "4bf92f3577b34da6a3ce929d0e0e4736", "spanId": "a3ce929d0e0e4736", "parentSpanId": "00f067aa0ba902b7", "name": "GET /orders", "kind": 2, "startTimeUnixNano": "1794391200000000000", "endTimeUnixNano": "1794391200085000000", "attributes": [{"key": "http.request.method", "value": {"stringValue": "GET"}}, {"key": "http.response.status_code", "value": {"intValue": "200"}}]}, {"traceId": "4bf92f3577b34da6a3ce929d0e0e4736", "spanId": "b7ad6b7169203331", "parentSpanId": "a3ce929d0e0e4736", "name": "SELECT orders", "kind": 3, "startTimeUnixNano": "1794391200010000000", "endTimeUnixNano": "1794391200050000000"}]}]}]}}
A child whose parent_ref is unknown
admin
otel traces "" "[{\"name\": \"child\", \"parent_ref\": \"nobody\"}]" "{\"dry_run\": true}"
mentdb
ERROR: Sorry, an error appears (the parent_ref 'nobody' of the span 0 is not the ref of a span of this call).
Fixed result from a real OpenTelemetry Collector 0.165.0 on 127.0.0.1 (OTLP/HTTP receiver): with the resource of the service
admin
otel traces "http://127.0.0.1:14318" "[{\"ref\": \"job\", \"name\": \"nightly import\", \"trace_id\": \"4bf92f3577b34da6a3ce929d0e0e4736\", \"span_id\": \"a3ce929d0e0e4736\", \"start_time\": \"2026-11-11T02:00:00Z\", \"duration_ms\": 3500, \"status\": \"ok\", \"attributes\": {\"rows\": 1200}}, {\"parent_ref\": \"job\", \"name\": \"SELECT orders\", \"span_id\": \"00f067aa0ba902b7\", \"kind\": \"client\", \"start_time\": \"2026-11-11T02:00:00.100Z\", \"duration_ms\": 1200, \"attributes\": {\"db.system\": \"mysql\"}}, {\"parent_ref\": \"job\", \"name\": \"POST /api/stock\", \"span_id\": \"b7ad6b7169203331\", \"kind\": \"client\", \"start_time\": \"2026-11-11T02:00:01.400Z\", \"duration_ms\": 900, \"status\": {\"code\": \"error\", \"message\": \"HTTP 503\"}, \"events\": [{\"name\": \"retry\", \"time\": \"2026-11-11T02:00:01.800Z\", \"attributes\": {\"attempt\": 2}}]}]" "{\"resource\": {\"service.name\": \"billing\", \"service.version\": \"4.2\", \"deployment.environment.name\": \"production\"}}"
mentdb
{"signal": "traces", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/traces", "items": 3, "bytes": 1330, "rejected": 0, "partial_success": false, "spans": [{"name": "nightly import", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "a3ce929d0e0e4736", "parent_span_id": null}, {"name": "SELECT orders", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "00f067aa0ba902b7", "parent_span_id": "a3ce929d0e0e4736"}, {"name": "POST /api/stock", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "b7ad6b7169203331", "parent_span_id": "a3ce929d0e0e4736"}]}
Used in use cases (2 recipes)

    Backend & web service developer › Trace a nightly job and link its log lines to the trace
    Web service developer › Continue the trace of the caller in a web service (W3C Trace Context)
Often used with

    not  ·  otel logs  ·  otel span_id  ·  otel trace_id  ·  otel traceparent  ·  otel traceparent_parse  ·  string contains  ·  string length

otel logs <endpoint> <json_records>


Description

    Send log records to an OTLP/HTTP receiver. Result: {signal, sent, status, host, path, items, bytes, rejected, partial_success, message}: rejected and message come from a partial success answer of the receiver (the items it refused and why)

Parameters

    endpoint:   The OTLP/HTTP endpoint of the collector, ex: http://127.0.0.1:4318 (/v1/metrics, /v1/traces or /v1/logs is added); empty with dry_run - String - required
    json_records:   The records: a JSON array of {body, severity, time, attributes, ...} (or one object), one text (any text that is not a JSON array or object is one record, such as [ERROR] disk full or {user} logged in), or a request already in OTLP JSON ({"resourceLogs": [...]}) - String - required
admin
otel logs "http://127.0.0.1:14318" "Backup started"
mentdb
{"signal": "logs", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/logs", "items": 1, "bytes": 349, "rejected": 0, "partial_success": false}

otel logs <endpoint> <json_records> <json_params>


Description

    Send log records with parameters: resource (the attributes of the service: {"service.name": "billing", "service.version": "4.2", ...}; service.name is mentdb when it is not given), scope_name (mentdb) and scope_version, secret_headers (the name of a secret (secret set) of the server that holds the headers, as OTEL_EXPORTER_OTLP_HEADERS: api-key=abc,x-tenant=a%20b), bearer_token (a variable that holds a token sent as Authorization: Bearer), headers (headers without secrets, ex: {"X-Scope-OrgID": "tenant-1"}; a name that looks like a secret is refused), allow_plain (false: a secret header is refused on plain http to a host that is not this machine), compression (none or gzip), timeout_ms (10000, 100 to 120000), path_as_is (false: true sends to the URL exactly as given), dry_run (false: true sends nothing, reads no secret, and gives the exact OTLP JSON), severity (info: the default severity), traceparent (the records without trace_id are linked to that trace). Result: {signal, sent, status, host, path, items, bytes, rejected, partial_success, message}: rejected and message come from a partial success answer of the receiver (the items it refused and why)

Parameters

    endpoint:   The OTLP/HTTP endpoint of the collector, ex: http://127.0.0.1:4318 (/v1/metrics, /v1/traces or /v1/logs is added); empty with dry_run - String - required
    json_records:   The records - String - required
    json_params:   The parameters - String - required
admin
otel logs "" "[{\"body\": {\"order\": 1042, \"reason\": \"card refused\"}, \"severity\": \"error\", \"time\": \"2026-11-11T10:00:00Z\", \"observed_time\": \"2026-11-11T10:00:00Z\", \"trace_id\": \"4bf92f3577b34da6a3ce929d0e0e4736\", \"span_id\": \"00f067aa0ba902b7\", \"attributes\": {\"customer.id\": \"C-77\"}}]" "{\"dry_run\": true}"
mentdb
{"signal": "logs", "dry_run": true, "items": 1, "bytes": 608, "payload": {"resourceLogs": [{"resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "mentdb"}}]}, "scopeLogs": [{"scope": {"name": "mentdb"}, "logRecords": [{"timeUnixNano": "1794391200000000000", "observedTimeUnixNano": "1794391200000000000", "severityNumber": 17, "severityText": "ERROR", "body": {"kvlistValue": {"values": [{"key": "order", "value": {"intValue": "1042"}}, {"key": "reason", "value": {"stringValue": "card refused"}}]}}, "attributes": [{"key": "customer.id", "value": {"stringValue": "C-77"}}], "traceId": "4bf92f3577b34da6a3ce929d0e0e4736", "spanId": "00f067aa0ba902b7"}]}]}]}}
Fixed result from a real OpenTelemetry Collector 0.165.0 on 127.0.0.1 (OTLP/HTTP receiver): two records, one linked to a span
admin
otel logs "http://127.0.0.1:14318" "[{\"body\": \"Import finished: 1200 rows\", \"severity\": \"info\", \"time\": \"2026-11-11T10:00:00Z\", \"attributes\": {\"job\": \"nightly-import\"}}, {\"body\": \"3 rows rejected\", \"severity\": \"warn\", \"time\": \"2026-11-11T10:00:00Z\", \"trace_id\": \"4bf92f3577b34da6a3ce929d0e0e4736\", \"span_id\": \"a3ce929d0e0e4736\"}]" "{\"resource\": {\"service.name\": \"billing\", \"service.version\": \"4.2\", \"deployment.environment.name\": \"production\"}}"
mentdb
{"signal": "logs", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/logs", "items": 2, "bytes": 834, "rejected": 0, "partial_success": false}
Fixed result from a real OpenTelemetry Collector 0.165.0 on 127.0.0.1 (OTLP/HTTP receiver): one text linked to the trace of an incoming request
admin
otel logs "http://127.0.0.1:14318" "Backup started" "{\"traceparent\": \"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01\"}"
mentdb
{"signal": "logs", "sent": true, "status": 200, "host": "127.0.0.1:14318", "path": "/v1/logs", "items": 1, "bytes": 438, "rejected": 0, "partial_success": false}
A severity that does not exist
admin
otel logs "" "[{\"body\": \"x\", \"severity\": \"loud\"}]" "{\"dry_run\": true}"
mentdb
ERROR: Sorry, an error appears (the 'severity' of the record 0 must be trace, debug, info, warn, error, fatal (also info2 to info4...) or a number from 1 to 24).
Used in use cases (1 recipe)

    Backend & web service developer › Trace a nightly job and link its log lines to the trace
Often used with

    otel trace_id  ·  otel traces

otel trace_id


Description

    A new random trace id: 32 hexadecimal characters (16 bytes from a secure random generator, never all zeros), for otel traces, otel logs and traceparent headers

admin
otel trace_id
mentdb
9832fd51d04f6e81135a4fe53d7f617c
Used in use cases (1 recipe)

    Backend & web service developer › Trace a nightly job and link its log lines to the trace
Often used with

    otel logs  ·  otel traces

otel span_id


Description

    A new random span id: 16 hexadecimal characters (8 bytes, never all zeros)

admin
otel span_id
mentdb
b856ea6e369e9176
Used in use cases (1 recipe)

    Web service developer › Continue the trace of the caller in a web service (W3C Trace Context)
Often used with

    not  ·  otel traceparent  ·  otel traceparent_parse  ·  otel traces  ·  string contains  ·  string length

otel traceparent


Description

    A W3C Trace Context traceparent header for a new trace: {traceparent, trace_id, span_id, sampled}. Put it in the header traceparent of an HTTP call (rest request) so that the called service joins the trace

admin
otel traceparent
mentdb
{"traceparent": "00-01e0ce908a5504f1414182b00544e26c-dae67c93d3a772fb-01", "trace_id": "01e0ce908a5504f1414182b00544e26c", "span_id": "dae67c93d3a772fb", "sampled": true}

otel traceparent <json>


Description

    Build a traceparent from given ids, generating the missing ones. JSON object: trace_id, span_id (the id of the calling span), sampled (true), tracestate (a text vendor=value,... or an object; checked: 32 members, 512 characters). Result: {traceparent, tracestate, trace_id, span_id, sampled}

Parameters

    json:   The ids and options - String - required
admin
otel traceparent "{\"trace_id\": \"4bf92f3577b34da6a3ce929d0e0e4736\", \"span_id\": \"00f067aa0ba902b7\", \"tracestate\": {\"congo\": \"t61rcWkgMzE\", \"rojo\": \"00f067aa0ba902b7\"}}"
mentdb
{"traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", "tracestate": "congo=t61rcWkgMzE,rojo=00f067aa0ba902b7", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "00f067aa0ba902b7", "sampled": true}
Not sampled
admin
otel traceparent "{\"trace_id\": \"4bf92f3577b34da6a3ce929d0e0e4736\", \"span_id\": \"00f067aa0ba902b7\", \"sampled\": false}"
mentdb
{"traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "00f067aa0ba902b7", "sampled": false}
A trace id that is not hexadecimal
admin
otel traceparent "{\"trace_id\": \"xyz\"}"
mentdb
ERROR: Sorry, an error appears (the field 'trace_id' must be 32 hexadecimal characters).
Used in use cases (1 recipe)

    Web service developer › Continue the trace of the caller in a web service (W3C Trace Context)
Often used with

    not  ·  otel span_id  ·  otel traceparent_parse  ·  otel traces  ·  string contains  ·  string length

otel traceparent_parse <header>


Description

    Read a traceparent header received by a web service: {valid, version, trace_id, span_id, flags, sampled}. An invalid header is not an error: valid is false with the reason (upper case hexadecimal, all-zero id, version ff, wrong length...), and a receiver then starts a new trace, as the recommendation says. A later version (01...) is read for its first fields

Parameters

    header:   The value of the traceparent header - String - required
admin
otel traceparent_parse "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
mentdb
{"valid": true, "version": "00", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "00f067aa0ba902b7", "flags": "01", "sampled": true}
Upper case is not valid
admin
otel traceparent_parse "00-4BF92F3577B34DA6A3CE929D0E0E4736-00F067AA0BA902B7-01"
mentdb
{"valid": false, "reason": "upper case hexadecimal is not allowed"}
An all-zero trace id
admin
otel traceparent_parse "00-00000000000000000000000000000000-00f067aa0ba902b7-01"
mentdb
{"valid": false, "reason": "the trace id is all zeros"}

otel traceparent_parse <header> <json_params>


Description

    Read a traceparent with parameters: tracestate (the value of the tracestate header: its members are returned as an object, or tracestate_error when it is not valid; the traceparent stays valid)

Parameters

    header:   The value of the traceparent header - String - required
    json_params:   The parameters - String - required
admin
otel traceparent_parse "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01" "{\"tracestate\": \"rojo=00f067aa0ba902b7,congo=t61rcWkgMzE\"}"
mentdb
{"valid": true, "version": "00", "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736", "span_id": "00f067aa0ba902b7", "flags": "01", "sampled": true, "tracestate": {"rojo": "00f067aa0ba902b7", "congo": "t61rcWkgMzE"}}
Used in use cases (1 recipe)

    Web service developer › Continue the trace of the caller in a web service (W3C Trace Context)
Often used with

    not  ·  otel span_id  ·  otel traceparent  ·  otel traces  ·  string contains  ·  string length