|
2 | 2 |
|
3 | 3 | From the team behind [Pydantic Validation](https://pydantic.dev/), **Pydantic Logfire** is an observability platform built on the same belief as our open source library — that the most powerful tools can be easy to use. |
4 | 4 |
|
5 | | -Check the [Github Repository README](https://github.com/pydantic/logfire-js) for more information on how to use the SDK. |
| 5 | +What sets Logfire apart: |
| 6 | + |
| 7 | +- **Simple and Powerful:** Logfire's dashboard is simple relative to the power it provides, ensuring your entire engineering team will actually use it. |
| 8 | +- **SQL:** Query your data using standard SQL — all the control and (for many) nothing new to learn. Using SQL also means you can query your data with existing BI tools and database querying libraries. |
| 9 | +- **OpenTelemetry:** Logfire is an opinionated wrapper around OpenTelemetry, allowing you to leverage existing tooling, infrastructure, and instrumentation for many common packages, and enabling support for virtually any language. |
| 10 | + |
| 11 | +See the [documentation](https://logfire.pydantic.dev/docs/) for more information. |
| 12 | + |
| 13 | +**Feel free to report issues and ask any questions about Logfire in this repository!** |
| 14 | + |
| 15 | +This repo contains the JavaScript Node.js SDK; the server application for recording and displaying data is closed source. |
| 16 | + |
| 17 | +If you need to instrument your browser application, see the [Logfire Browser package](https://www.npmjs.com/package/@pydantic/logfire-browser). |
| 18 | +If you're instrumenting Cloudflare, see the [Logfire CF workers package](https://www.npmjs.com/package/@pydantic/logfire-cf-workers). |
| 19 | + |
| 20 | +## Basic usage |
| 21 | + |
| 22 | +Using Logfire from your Node.js script is as simple as |
| 23 | +[getting a write token](https://logfire.pydantic.dev/docs/how-to-guides/create-write-tokens/), |
| 24 | +installing the package, calling configure, and using the provided API. Let's |
| 25 | +create an empty project: |
| 26 | + |
| 27 | +```sh |
| 28 | +mkdir test-logfire-js |
| 29 | +cd test-logfire-js |
| 30 | +npm init -y es6 # creates package.json with `type: module` |
| 31 | +npm install logfire |
| 32 | +``` |
| 33 | + |
| 34 | +Then, create the following `hello.js` script in the directory: |
| 35 | + |
| 36 | +```js |
| 37 | +import * as logfire from 'logfire' |
| 38 | + |
| 39 | +logfire.configure({ |
| 40 | + token: 'my-write-token', // replace with your write token |
| 41 | + serviceName: 'example-node-script', |
| 42 | + serviceVersion: '1.0.0', |
| 43 | +}) |
| 44 | + |
| 45 | +logfire.info( |
| 46 | + 'Hello from Node.js', |
| 47 | + { |
| 48 | + 'attribute-key': 'attribute-value', |
| 49 | + }, |
| 50 | + { |
| 51 | + tags: ['example', 'example2'], |
| 52 | + } |
| 53 | +) |
| 54 | +``` |
| 55 | + |
| 56 | +Run the script with `node hello.js`, and you should see the span being logged in |
| 57 | +the live view of your Logfire project. |
| 58 | + |
| 59 | +## Contributing |
| 60 | + |
| 61 | +See [CONTRIBUTING.md](https://github.com/pydantic/logfire-js/blob/main/CONTRIBUTING.md) for development instructions. |
| 62 | + |
| 63 | +## License |
| 64 | + |
| 65 | +MIT |
0 commit comments