Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Baselime/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lastin committed Oct 23, 2023
2 parents 960a79e + 9bb839f commit 2070c2b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Binary file added assets/images/logos/render.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/logos/vector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion retype.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "3.1.0",
"created": "2023-10-19T15:00:29Z",
"created": "2023-10-19T16:19:25Z",
"files": [
{
"path": ".nojekyll"
Expand Down
26 changes: 23 additions & 3 deletions sending-data/opentelemetry/node.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ npm i --save \

### Step 2: Initialise the tracer

Create a `tracing.cjs` file inside your application working directory.
Create a `tracing.js` file

``` javascript # :icon-code: src/tracing.cjs
``` javascript # :icon-code: src/tracing.js
const { BaselimeSDK } = require('@baselime/node-opentelemetry');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');

Expand All @@ -56,14 +56,34 @@ Set the environment variables of your comntainer service to include the Baselime
| Key | Value | Description |
| ------------ | --------------------------------------------- | ----------------------------------------------------------------------------------- |
| BASELIME_KEY | `your-api-key` | Get this key from the [Baselime console](https://console.baselime.io) or the [Baselime CLI](https://github.com/Baselime/cli) |
| NODE_OPTIONS | `-r ./src/tracing.cjs --experimental-loader=import-in-the-middle/hook.mjs` | Preloads the OpenTelemetry SDK at startup |
| NODE_OPTIONS | `-r ./src/tracing.js` | Preloads the OpenTelemetry SDK at startup |

Once these steps are completed, distributed traces from your Node.js container applications should be available in Baselime to query via the console or the Baselime CLI.

![Example OpenTelemetry Trace](../../assets/images/illustrations/sending-data/opentelemetry/trace.png)

---

## Instrumentation

### Logging

You can correlate your logs and traces in Baselime by Including the requestId in your trace and by including the traceId and spanId in your logs.

OpenTelemetry has support for [winston](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-winston/README.md), and [pino](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-pino/README.md).

Or you can implement a custom logger

```
import { contenxt } as api from '@opentelemetry/api';
const { traceId, spanId } = context.active();
console.info(JSON.stringify({ traceId, spanId, msg: "Hello", data }))
```


## Configuration

The `BaselimeSDK` class of the [Baselime Node.js OpenTelemetry SDK](https://github.com/baselime/node-opentelemetry) takes the following configuration options.
Expand Down

0 comments on commit 2070c2b

Please sign in to comment.