Skip to content

Commit c468b09

Browse files
committed
Add deno example
1 parent 30e5c05 commit c468b09

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ The `logfire.configure` call should happen before the actual express module impo
195195
},
196196
```
197197

198+
## Deno
199+
200+
Deno has [built-in support for OpenTelemetry](https://docs.deno.com/runtime/fundamentals/open_telemetry/). The examples directory includes a `Hello world` example that configures Deno OTel export to Logfire through environment variables.
201+
202+
Optionally, you can use the Logfire API package for creating manual spans. Install the `@pydantic/logfire-api` NPM package and call the respective methods from your code.
203+
198204
#### Configuring the instrumentation
199205

200206
The `logfire.configure` function accepts a set of configuration options that control the behavior of the instrumentation. Alternatively, you can [use environment variables](https://logfire.pydantic.dev/docs/reference/configuration/#programmatically-via-configure) to configure the instrumentation.

examples/deno-project/deno.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"tasks": {
3+
"dev": "deno run --allow-net main.ts"
4+
},
5+
"imports": {
6+
"@std/assert": "jsr:@std/assert@1"
7+
}
8+
}

examples/deno-project/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Deno.serve({ port: 4242 }, (_req) => {
2+
return new Response("Hello, World!");
3+
});

examples/deno-project/start.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
OTEL_DENO=true \
3+
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://logfire-api.pydantic.dev/v1/traces \
4+
OTEL_EXPORTER_OTLP_HEADERS='Authorization=your-token' \
5+
deno run --unstable-otel --allow-net main.ts

0 commit comments

Comments
 (0)