Skip to content

Conversation

nyannyacha
Copy link
Contributor

@nyannyacha nyannyacha commented Jul 8, 2025

What kind of change does this PR introduce?

Feature, Enhancement

Description

This PR adds OpenTelemetry support

Usage

OTEL_EXPORTER_OTLP_ENDPOINT:
It is an OTLP endpoint that receives various trace data.
Please note that due to limitations in the current implementation of Deno Otel, only the HTTP protocol is supported.
An example of a valid value is http://127.0.0.1:4318/.

OTEL_SERVICE_NAME:
It is the service name used to identify various trace data.
It is not required, but please note that it will be displayed as unknown_service in tools such as SigNoz.

In addition to these environment variables, two CLI flags have been added. These are separate from user workers (otel settings for user workers can be configured in the main script) and are related to Otel settings in main and event workers.

--enable-otel[=<worker kind>...]:
Enables Otel (not user worker).
Otel is disabled by default for main and event worker.

If only the flag is specified, Otel is enabled for both main and event worker.
In addition, if you only want to enable Otel for the event worker, use --enable-otel=event

--otel-console[=<ignore, capture, replace>]:
Enables auto instrumentation for console.* in main and event workers.
The default value is ignore.
For more information about this value, see https://docs.deno.com/runtime/fundamentals/open_telemetry/#logs.

Enable Otel in the user worker:

When creating a user worker from the main worker, you can pass otelConfig as a parameter to EdgeRuntime.userWorkers.create().

await EdgeRuntime.userWorkers.create({
  ...
  otelConfig: {
    // Specify whether to enable tracing in this user worker. If not specified or set to false, instrumentation will not be performed.
    tracing_enabled: true,
    // Specify the propagators to be used to extract or inject from (in this case, HTTP requests or responses) the carrier.
    // TraceContext: https://www.w3.org/TR/trace-context
    // Baggage: https://www.w3.org/TR/baggage
    // "TraceContext" | "Baggage"[]
    propagators: ["TraceContext", "Baggage"],
    // See https://docs.deno.com/runtime/fundamentals/open_telemetry/#logs
    // "Ignore" | "Capture" | "Replace"
    console: "Ignore"
  },
});

(Detailed options for otelConfig can be found in types/global.d.ts in PR.)

Closes FUNC-254

@nyannyacha nyannyacha force-pushed the ny/support-otel branch 2 times, most recently from bb66f41 to ab66401 Compare August 14, 2025 10:12
@nyannyacha nyannyacha requested a review from laktek August 14, 2025 11:33
@nyannyacha nyannyacha merged commit 55d2378 into develop Aug 18, 2025
4 checks passed
@nyannyacha nyannyacha deleted the ny/support-otel branch August 18, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants