khone/koʊ.neɪ/
Experimental

Observability

Use traces and metrics together. Gateway latency, batch size, target invocation duration, and 429 sources can move independently, especially when LMI scales out into multiple independent execution environments.

OpenTelemetry traces

Tracing is enabled when either endpoint variable is set:

  • OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
  • OTEL_EXPORTER_OTLP_ENDPOINT

Supported protocols:

  • http/protobuf
  • grpc

Protocol can be set explicitly via OTEL_EXPORTER_OTLP_TRACES_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL. Otherwise the gateway defaults to grpc when OTEL_EXPORTER_OTLP_ENDPOINT contains localhost:4317, and http/protobuf otherwise.

Common variables:

  • OTEL_SERVICE_NAME
  • KHONE_OBSERVABILITY_VENDOR=AWSXRAY (exact match, case-sensitive)
  • OTEL_PROPAGATORS (defaults to xray,tracecontext,baggage)
  • OTEL_EXPORTER_OTLP_HEADERS or OTEL_EXPORTER_OTLP_TRACES_HEADERS
  • KHONE_OTEL_HEADERS_JSON - JSON object of header names to string values. The gateway encodes it into OTEL_EXPORTER_OTLP_HEADERS at startup if neither headers variable is already set.

The gateway does not export OpenTelemetry metrics. When OpenTelemetry tracing is enabled, it sets OTEL_METRICS_EXPORTER=none if the variable is unset.

CloudWatch EMF metrics

Enable EMF by setting KHONE_EMF_METRICS to a truthy value. The truthy parser accepts 1, true/TRUE, yes/YES, or on/ON.

  • KHONE_EMF_METRICS=1 enables EMF emission.
  • KHONE_EMF_NAMESPACE=KhoneGateway sets the CloudWatch namespace. The default is KhoneGateway.
  • KHONE_EMF_HIGH_RES=1 requests high storage resolution.

Dimension sets:

  • no dimensions
  • http.route + khone.invoke.mode
  • http.route + http.request.method + http.response.status_code

Metric inventory

Metric nameDimensionsUnit (EMF)
http.server.active_requestsnoneCount
http.server.request.counthttp.route, http.request.method, http.response.status_codeCount
http.server.request.durationhttp.route, http.request.method, http.response.status_codeMillisecond
khone.lambda.invoke.batch.sizehttp.route, khone.invoke.modeCount
khone.lambda.invoke.batch.waithttp.route, khone.invoke.modeMillisecond
khone.lambda.invoke.durationhttp.route, khone.invoke.modeMillisecond
khone.lambda.invoke.billed_durationhttp.route, khone.invoke.modeMillisecond
khone.lambda.invoke.init_durationhttp.route, khone.invoke.modeMillisecond
khone.lambda.memory.sizehttp.route, khone.invoke.modeCount 1
khone.lambda.memory.max_usedhttp.route, khone.invoke.modeCount 1
khone.batching.invocation_queue.depthnoneCount
khone.batching.invocation_queue.rejectionsnoneCount
khone.batching.plan.splitshttp.route, khone.invoke.modeCount
khone.batching.responses.missinghttp.route, khone.invoke.modeCount
khone.batching.probe.successnoneCount
khone.batching.probe.failurenoneCount

Profiling metrics (billed_duration, init_duration, memory.size, memory.max_used) require route-level x-khone.profiling: true. Profiling asks Lambda for the last 4 KB of invoke logs and adds overhead.

Debug response headers

Setting KHONE_DEBUG_RESPONSE_HEADERS to a truthy value adds these headers to every gateway response:

  • x-khone-batch-size
  • x-khone-target-elapsed-ms

Use debug headers during integration or load testing only; they leak internal scheduling information.

Footnotes

  1. Values are in megabytes but emitted without an EMF unit annotation. 2