Перейти до вмісту

Цю сторінку ще не перекладено, тому її показано англійською.

OpenTelemetry configuration

Configure Elide's OpenTelemetry export with the elide.pkl opentelemetry block, OTEL_* and ELIDE_OTEL_* environment variables, and --otel-* flags, and how they combine.

На цій сторінці

Telemetry is configured from three places. Higher rows win:

SourceScopeExample
--otel-* flagsOne runelide run --otel-endpoint=http://localhost:4318 app.ts
OTEL_* and ELIDE_OTEL_* variablesOne process and its environmentOTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
opentelemetry block in elide.pklA projectdestinations { ["collector"] { … } }
DefaultsOff until a destination exists

Telemetry stays off until a destination exists in one of them. With no destination, Elide starts no telemetry threads, opens no connections, and the OpenTelemetry APIs in your code do nothing.

When each source is read

Commandelide.pkl blockVariables and flags
elide run (project entrypoint), elide serveyesyes
elide run file.ts, elide file.py inside a projectyes, when the project’s elide.pkl contains opentelemetryyes
elide run file.ts outside a projectnoyes
elide build, elide test, elide installyesyes

A one-shot run looks for the word opentelemetry in the project’s elide.pkl before evaluating it, so a block inherited from another module is not seen by elide run file.ts; projects without telemetry pay nothing.

The elide.pkl block

amends "elide:project.pkl"

name = "checkout"

opentelemetry {
  service { name = "checkout"; version = "1.4.2"; environment = "production" }
  resource { ["cloud.region"] = "us-east-1" }

  destinations {
    ["collector"] { endpoint = "http://localhost:4317"; protocol = "grpc" }
    ["sentry"] { provider = "sentry" }
  }

  traces { sampler = "parentbased_traceidratio"; ratio = 0.25 }
  metrics { interval = 30.s }
  logs { level = "info" }
  runtime { logs = "warn" }
}

Credentials never go in elide.pkl. A destination names the environment variable that holds them (credential, dsn, headerEnv), and Elide reads it at startup.

Top level

PropertyMeaningDefault
enabledfalse turns telemetry off, whatever the environment says.—
service.nameservice.name resource attribute.unknown_service:elide
service.version, .namespaceservice.version, service.namespace.—
service.environmentdeployment.environment.name.—
resourceExtra resource attributes: strings, booleans, integers, floats.—
destinationsNamed places to send telemetry; see below.none
shutdownTimeoutLongest the final export may take at exit; see At exit.5.s

Signals

PropertyMeaningDefault
traces.enabledRecord spans your code creates.true
traces.sampleralways_on, always_off, traceidratio, parentbased_always_on, parentbased_always_off, parentbased_traceidratio.parentbased_always_on
traces.ratioRatio for the ratio samplers, 0 to 1.1.0
traces.propagatorstracecontext, baggage, none: what the OpenTelemetry API in your code injects and extracts.tracecontext, baggage
metrics.enabledRecord instruments your code creates.true
metrics.intervalExport interval.60.s
metrics.temporalitycumulative or delta.cumulative; delta when Datadog receives metrics
logs.enabledExport log records your code emits.true
logs.levelMinimum severity: trace, debug, info, warn, error, fatal, off.info
logs.consoleExport console.* and Python logging output as log records.true
profiles.enabledSample guest CPU profiles (experimental).false
profiles.frequencySamples per second, 1 to 10000.100
runtime.tracesElide’s server and client HTTP spans.true
runtime.metricsElide’s HTTP, process, and error metrics.true
runtime.logsMinimum severity of Elide’s own log records to export.warn
propagation.baggageW3C baggage on Elide’s HTTP server and clients; see Baggage.off

Destinations

Each entry in destinations is one place telemetry goes. The name is yours; it appears in error messages.

PropertyMeaningDefault
providerotlp, sentry, datadog, posthog, honeycomb, grafana. See Providers.otlp
endpointBase URL. HTTP protocols append /v1/traces, /v1/metrics, /v1/logs. For a provider, replaces its host.http://localhost:4318, or http://localhost:4317 for gRPC
protocolgrpc, http/protobuf, http/json.http/protobuf
headersLiteral, non-secret request headers.—
headerEnvHeaders read from environment variables: ["authorization"] = "COLLECTOR_TOKEN".—
credentialVariable holding a provider’s API key or token.per provider
dsnVariable holding a Sentry DSN.SENTRY_DSN
siteDatadog site.DD_SITE, then datadoghq.com
regionPostHog or Honeycomb region (us, eu), or a Grafana Cloud zone.us
signalstraces, metrics, logs, profiles.every signal the provider takes by default
compressiongzip or none.gzip
timeoutPer-request deadline, retries included.10.s
perSignalPer-signal endpoint (used as given), protocol, headers, headerEnv, compression, timeout.—

Several destinations can be active at once. Each receives only the signals it lists, or that its provider takes by default:

opentelemetry {
  destinations {
    ["collector"] { endpoint = "http://otel-collector:4318" }
    ["errors"] { provider = "sentry" }
    ["metrics"] { provider = "datadog"; site = "us5"; signals { "metrics" } }
  }
}

A collector that needs a token:

opentelemetry {
  destinations {
    ["collector"] {
      endpoint = "https://otel.example.com"
      headerEnv { ["authorization"] = "OTEL_COLLECTOR_AUTH" }
      perSignal { ["metrics"] { endpoint = "https://metrics.example.com/otlp/v1/metrics" } }
    }
  }
}

The complete schema, with every other elide.pkl block, is in the elide.pkl reference.

Environment variables

Elide reads the standard OpenTelemetry SDK variables. An invalid value is ignored, and the setting keeps its manifest or default value.

VariableEffectDefault
OTEL_SDK_DISABLEDtrue turns telemetry off. Only a --otel-* flag turns it back on.false
OTEL_SERVICE_NAMEservice.name.unknown_service:elide
OTEL_RESOURCE_ATTRIBUTESExtra resource attributes, key=value,key=value, values percent-encoded.—
OTEL_EXPORTER_OTLP_ENDPOINTBase URL for otlp destinations; creates one named otlp when there is none.—
OTEL_EXPORTER_OTLP_PROTOCOLgrpc, http/protobuf, http/json.http/protobuf
OTEL_EXPORTER_OTLP_HEADERSRequest headers, key=value,…. Treated as secrets.—
OTEL_EXPORTER_OTLP_COMPRESSIONgzip or none.gzip
OTEL_EXPORTER_OTLP_TIMEOUTRequest deadline in milliseconds.10000
OTEL_EXPORTER_OTLP_CERTIFICATEPEM file of trusted CA certificates; replaces the system trust store.system
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE, OTEL_EXPORTER_OTLP_CLIENT_KEYPEM client certificate and key for mutual TLS.—
OTEL_EXPORTER_OTLP_{TRACES,METRICS,LOGS}_ENDPOINTFull URL for one signal, used as given.—
OTEL_EXPORTER_OTLP_{TRACES,METRICS,LOGS}_{PROTOCOL,HEADERS,COMPRESSION,TIMEOUT,CERTIFICATE,CLIENT_CERTIFICATE,CLIENT_KEY}The same settings for one signal.—
OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTERnone turns that signal off, for your code and for Elide. otlp with no destination anywhere sends that signal to http://localhost:4318.—
OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARGSampler and ratio, as traces.sampler and traces.ratio.parentbased_always_on
OTEL_PROPAGATORStracecontext, baggage, none for the API in your code. Does not turn on baggage for Elide’s HTTP server and clients.tracecontext,baggage
OTEL_METRIC_EXPORT_INTERVALMetric export interval in milliseconds.60000
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCEcumulative or delta.cumulative
OTEL_METRICS_EXEMPLAR_FILTERtrace_based, always_on, always_off. See Exemplars.trace_based
OTEL_SEMCONV_EXCEPTION_SIGNAL_OPT_INlogs records errors as log records only; logs/dup also adds exception span events.logs/dup

Elide adds shorthands for providers and for settings the standard variables do not cover:

VariableEffectDefault
ELIDE_OTEL_PROVIDERAdds a destination for a provider, named after it.—
ELIDE_OTEL_REGIONThat destination’s site or region: us5 (Datadog), eu (PostHog, Honeycomb), prod-us-east-0 (Grafana).provider default
ELIDE_OTEL_SIGNALSThat destination’s signals, e.g. traces,logs.provider default
ELIDE_OTEL_PROFILEStrue samples guest CPU profiles at 100 per second; a number sets the frequency.off
ELIDE_OTEL_BAGGAGE_INBOUNDtrue admits served requests’ baggage headers.false
ELIDE_OTEL_BAGGAGE_OUTBOUNDtrue sends the current baggage on outgoing requests.false
ELIDE_OTEL_BAGGAGE_ALLOWBaggage keys allowed in both directions, comma-separated.all keys
ELIDE_OTEL_SHUTDOWNHow the final export leaves at exit: sidecar, inline, drop. See At exit.sidecar

OTEL_EXPORTER_OTLP_* apply to every destination that uses the otlp provider, including ones named in elide.pkl. Provider credentials come from the variables listed on Providers.

Flags

FlagEffect
--otel-endpoint=URLAdds or updates a destination with this endpoint.
--otel-provider=PROVIDERNames that destination’s provider; otlp when omitted.
--otel-protocol=PROTOCOLgrpc, http/protobuf, or http/json for that destination.
--otel-shutdown=MODEsidecar, inline, or drop; see At exit.
--no-otelTurns telemetry off for this run, whatever the manifest and environment say.

The flags take = and apply to run, serve, test, build, and install:

elide run --otel-endpoint=http://localhost:4317 --otel-protocol=grpc app.ts
elide test --no-otel

At exit

When a program ends, Elide still holds telemetry it has not sent: the last log records and spans, and a final collection of metrics. The shutdown mode decides how that leaves the process:

ModeAt exitExit waits
sidecarHands the final export to a background exporter, which sends it.under 250 ms, never on the network
inlineSends the final export from the exiting process.up to shutdownTimeout
dropDiscards the final export and counts it.no

sidecar is the default on Linux and macOS. The exporter is a small elide process, one per user, started by the first exit that needs it. It accepts requests only from processes of the same user, keeps them in memory only, sends each one once with the usual retries, and exits once no Elide process of that user is left and its queue is sent or has expired. It never runs longer than 15 minutes. If the exporter cannot be started or reached in time, the final export is dropped and counted, never sent from the exiting process.

On Windows, inline is the only mode; sidecar falls back to it with a warning. Choose inline to have the exiting process send the data itself, for example when nothing may outlive the program:

elide run --otel-shutdown=inline app.ts
ELIDE_OTEL_SHUTDOWN=drop elide run app.ts

How sources combine

  • Destinations merge by name. A destination from --otel-provider=honeycomb and one named honeycomb in elide.pkl are the same destination; the flag’s fields win.
  • OTEL_EXPORTER_OTLP_* settings apply to every otlp destination. With no otlp destination, an endpoint variable creates one named otlp.
  • elide.pkl and flag values are checked strictly: a bad value leaves telemetry off for the run, with a warning; see Configuration errors. Bad variable values are skipped.
  • A destination left with no enabled signal is skipped. When no destination receives anything, telemetry stays off.
  • Configuration is read once, at startup. Your code cannot change destinations, headers, or the resource.

Samples

Чи була ця сторінка корисною?