Skip to content

Commit a391811

Browse files
committed
Comments on README, fix variable
1 parent aafbe9d commit a391811

File tree

5 files changed

+1085
-107
lines changed

5 files changed

+1085
-107
lines changed

.changeset/small-moments-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"logfire": patch
3+
---
4+
5+
Fix for a peer package

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,44 @@ This repo contains the JavaScript SDK for `logfire` and its documentation; the s
1818

1919
Depending on your environment, you can integrate Logfire in several ways. Follow the specific instructions below:
2020

21+
### Basic Node.js script
22+
23+
Using logfire from your Node.js script is as simple as [getting a write token](https://logfire.pydantic.dev/docs/how-to-guides/create-write-tokens/), installing the package, calling configure, and using the provided API. Let's create an empty project:
24+
25+
```sh
26+
mkdir test-logfire-js;
27+
cd test-logfire-js;
28+
npm init -y es6 # makes the package.json with `type: module`
29+
npm install logfire
30+
```
31+
32+
Then, create the following `hello.js` script in the directory:
33+
34+
35+
```js
36+
import * as logfire from 'logfire'
37+
38+
logfire.configure({
39+
token: 'test-e2e-write-token',
40+
advanced: {
41+
baseUrl: 'http://localhost:8000'
42+
},
43+
serviceName: 'example-node-script',
44+
serviceVersion: '1.0.0',
45+
})
46+
47+
48+
logfire.info('Hello from Node.js', {
49+
'attribute-key': 'attribute-value'
50+
}, {
51+
tags: ['example', 'example2']
52+
})
53+
```
54+
55+
Run the script above with `node hello.js`, and you should see the span being logged in the live view of your Logfire project.
56+
57+
58+
2159
### Cloudflare Workers
2260

2361
First, install the `@microlabs/otel-cf-workers` [NPM package](https://github.com/evanderkoogh/otel-cf-workers) and the `@pydantic/logfire-cf-workers @pydantic/logfire-api` NPM package:

0 commit comments

Comments
 (0)