Skip to main content

Send Telemetry to Datadog from WebAssembly in Deno

Observability in Datadog from WebAssembly


Enables the extraction of traces/spans from Wasm modules executing in a Deno environment and emits them to a Datadog agent.


Deno will install the package if it detects that you've imported it in your source code. See the example below.


A basic Typescript program that loads a Wasm module and executes it using the native WebAssembly runtime.

import datadog from "npm:@dylibso/observe-sdk-datadog";
const { DatadogAdapter } = datadog;

import Context from "";

// create a new instance of the Datadog adapter
// this assumes you have a datadog agent running on localhost, you may also pass a config
const adapter = new DatadogAdapter();

// load up a Wasm module
const bytes = await Deno.readFile("your_module.wasm");

// create an optional filter that instructs the adapter to throw away any
// spans below a configured threshold
const opts = {
spanFilter: {
minDurationMicroseconds: 100,

// start the adapter with the Wasm module bytes and options
const traceContext = await adapter.start(bytes, opts);

// load, instantiate and run the Wasm module
const module = new WebAssembly.Module(bytes);
const runtime = new Context({
stdin: Deno.stdin.rid,
stdout: Deno.stdout.rid,
const instance = new WebAssembly.Instance(
"wasi_snapshot_preview1": runtime.exports,

// instruct the adapter to stop the trace

Adapter Configuration

You may modify the behavior of your adapter by passing in a configuration when initializing the adapter. A configuration has the following fields:

const config = {
// the URL of the Datadog agent
agentHost: new URL(""),
// the service name to group your observability data under
serviceName: "my-wasm-service",
// default metadata that apply to every trace
defaultTags: new Map<string, string>(),
// the type of trace being captured
traceType: DatadogTraceType.Web,
// how often to send new traces to the agent
emitTracesInterval: 1000,
// the maximum number of traces to send to the agent per request
traceBatchMax: 100,
const adapter = new DatadogAdapter(config);