@saidsef/tracing-node 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,120 +1,74 @@
1
- # Opentelemetry Wrapper for Tracing Node Applications
1
+ # OpenTelemetry Wrapper for Tracing Node Applications
2
2
 
3
- [![CI](https://github.com/saidsef/tracing-node/actions/workflows/pr.yml/badge.svg)](#Instalation)
4
- [![Release](https://github.com/saidsef/tracing-node/actions/workflows/release.yml/badge.svg)](#Instalation)
3
+ [![CI](https://github.com/saidsef/tracing-node/actions/workflows/pr.yml/badge.svg)](https://github.com/saidsef/tracing-node/actions/workflows/pr.yml)
4
+ [![Release](https://github.com/saidsef/tracing-node/actions/workflows/release.yml/badge.svg)](https://github.com/saidsef/tracing-node/actions/workflows/release.yml)
5
+ [![Documentation](https://readthedocs.org/projects/tracing-node/badge/?version=latest)](https://tracing-node.readthedocs.io/en/latest/)
5
6
  ![GitHub issues](https://img.shields.io/github/issues/saidsef/tracing-node)
6
7
  ![npm](https://img.shields.io/npm/v/%40saidsef%2Ftracing-node) ![npm](https://img.shields.io/npm/dt/%40saidsef/tracing-node)
7
8
  ![GitHub release(latest by date)](https://img.shields.io/github/v/release/saidsef/tracing-node)
8
9
  ![Commits](https://img.shields.io/github/commits-since/saidsef/tracing-node/latest.svg)
9
10
 
10
- Get telemetry for your app in less than 3 minutes!
11
-
12
- Effortlessly supercharge your applications with world-class distributed tracing! This OpenTelemetry wrapper delivers seamless, lightning-fast observability, empowering developers to monitor, debug, and optimise microservices with ease. Designed for modern cloud-native environments, it's the smart choice for engineers who demand reliability, scalability, and actionable insights. Get started in minutes and unlock the full potential of your service architecture—no fuss, just results. This is to make instrumentation (more) idempotent.
13
-
14
- ## Features
15
- | Feature | Description |
16
- |---------|-------------|
17
- | HTTP/HTTPS instrumentation | Automatic service detection |
18
- | fetch/undici instrumentation | Outgoing `globalThis.fetch` calls |
19
- | Express.js support | Framework instrumentation |
20
- | Elasticsearch client | Database instrumentation |
21
- | IORedis client | Cache instrumentation |
22
- | AWS SDK | Cloud service instrumentation |
23
- | Pino logger | Integration with trace/span IDs |
24
- | Node runtime metrics | Event loop, garbage collection, heap |
25
- | Log export | Pino records over OTLP, correlated by trace |
26
- | RED metrics | Request duration histograms over OTLP |
27
- | DNS/FS instrumentation | Optional monitoring |
28
- | Resource detection | Host, OS, process, container |
29
- | W3C Trace Context | Standard propagation |
11
+ **Traces, metrics and logs from one function call.** Add two lines to a service, and its requests, its calls to Redis, Elasticsearch, AWS and other services, its runtime counters and its Pino log records all arrive at your collector, already correlated by trace id and stitched into a service graph.
12
+
13
+ `@saidsef/tracing-node` wraps the OpenTelemetry Node SDK. One call to `setupTracing` builds the tracer, meter and logger providers, registers them globally, and turns on a fixed set of instrumentations, so an application gets all three signals without assembling exporters, span processors, resource detectors and instrumentation packages itself. A second call logs a warning and returns the tracer that already exists, which makes initialisation idempotent.
14
+
15
+ Full documentation: [tracing-node.readthedocs.io](https://tracing-node.readthedocs.io/).
30
16
 
31
17
  ## Prerequisites
32
- - NodeJS
18
+ - NodeJS >= 24.0.0
33
19
  - Observability
34
20
  - ...
35
21
  - Profit?
36
22
 
37
- ## Where the traces go
38
-
39
- `setupTracing` exports OTLP over gRPC, so any OpenTelemetry-compatible collector or backend will take it - point `url` at yours.
40
-
41
- If you do not have one yet, [grafana-loki-on-k8s](https://github.com/saidsef/grafana-loki-on-k8s) is a companion project that deploys the full LGTM+ stack - Grafana, Prometheus, Mimir, Loki, Tempo, Pyroscope, Alloy and Beyla - to Kubernetes with `kubectl apply -k ./deployment`, broken into small composable manifests rather than a single opaque chart. Send traces to its Alloy OTLP receiver and they land in Tempo, with the metrics-generator turning them into RED and service-graph metrics in Mimir:
23
+ ## Installation
42
24
 
43
- ```javascript
44
- setupTracing({serviceName: 'my-service', url: 'http://alloy:4317'});
25
+ ```shell
26
+ npm install @saidsef/tracing-node --save
45
27
  ```
46
28
 
47
- The W3C Trace Context propagation this library registers is what lets Tempo pair a caller's client span with the callee's server span, which is what a service graph is built from.
48
-
49
- Metrics go to the same endpoint by default and land in Mimir. They are recorded before the sampler runs, so they stay complete however far trace volume is turned down.
50
-
51
- Pino log records go to the same endpoint and land in Loki, each carrying the trace and span id of the request that wrote it. No log agent or file scraping sits in between.
29
+ ## Usage
52
30
 
53
- ## Instalation
31
+ ```javascript
32
+ import { setupTracing } from '@saidsef/tracing-node';
54
33
 
55
- ```
56
- npm install @saidsef/tracing-node --save
34
+ setupTracing({hostname: 'hostname', serviceName: 'service_name', url: 'endpoint'});
57
35
  ```
58
36
 
59
- ## Upgrading
60
-
61
- Breaking changes and the attribute renames they bring are recorded in the [release notes](https://github.com/saidsef/tracing-node/releases) for the version concerned.
37
+ `serviceName` and `url` are required, and both fall back to the `SERVICE_NAME` and `ENDPOINT` environment variables. `setupTracing` has to run before the application imports the libraries being traced.
62
38
 
63
- ## Usage
39
+ ## Collector and backend
64
40
 
65
- You can set required params via env variables or function:
41
+ The exporter speaks OTLP over gRPC, so any OpenTelemetry-compatible collector accepts all three signals. Point `url` at yours.
66
42
 
67
- Env vars:
68
- | Environment Variable | Description | Required |
69
- |-----------------------|----------------------------| --------- |
70
- | CONTAINER_NAME/HOSTNAME| Container or pod hostname | No |
71
- | ENDPOINT | Tracing collector endpoint | Yes |
72
- | SERVICE_NAME | Service/application name | Yes |
43
+ [**grafana-loki-on-k8s**](https://github.com/saidsef/grafana-loki-on-k8s) is the companion stack, and the one the end to end harness in [`test/e2e/`](./test/e2e) targets. It deploys Grafana, Prometheus, Mimir, Loki, Tempo, Pyroscope, Alloy and Beyla to Kubernetes as small composable manifests.
73
44
 
74
- Function args
75
- ```
76
- import { setupTracing } from '@saidsef/tracing-node';
77
- setupTracing({hostname: 'hostname', serviceName: 'service_name', url: 'endpoint'});
45
+ ```shell
46
+ git clone https://github.com/saidsef/grafana-loki-on-k8s
47
+ kubectl apply -k grafana-loki-on-k8s/deployment
78
48
  ```
79
49
 
80
- ### Required Parameters are
81
-
82
- | Name | Type | Description| Required | Default |
83
- |----- | ---- | ------------- | ----- | ---- |
84
- | hostname | string | container / pod hostname | No | `hostname` |
85
- | serviceName | string | service / application name | Yes | `n/a` |
86
- | url | string | tracing endpoint i.e. `<schema>://<host>:<port>` | Yes | `n/a` |
87
- | enableFsInstrumentation | boolean | enable FS instrumentation | No | `false` |
88
- | enableDnsInstrumentation | boolean | enable DNS instrumentation | No | `false` |
89
- | enableMetrics | boolean | export metrics as well as traces | No | `true` |
90
- | metricsUrl | string | metrics endpoint, when it differs from `url` | No | `url` |
91
- | metricExportIntervalMillis | number | how often metrics are exported | No | `60000` |
92
- | enableLogs | boolean | send Pino log records over OTLP | No | `true` |
93
- | logsUrl | string | logs endpoint, when it differs from `url` | No | `url` |
50
+ Traces sent to its Alloy OTLP receiver on port 4317 land in Tempo, log records in Loki and metrics in Mimir. Tempo's metrics generator turns the spans into RED and service graph metrics, which is what the `peer.service` attribute this library sets exists to feed.
94
51
 
95
52
  ## Documentation
96
53
 
97
- Full documentation is in the [`docs/`](./docs) directory and built with [MkDocs Material](https://squidfunk.github.io/mkdocs-material/).
98
-
99
- Live docs: [tracing-node.readthedocs.io](https://tracing-node.readthedocs.io/)
54
+ The pages below are the manual. Their sources are in [`docs/`](./docs), and `npm run build-docs` renders the site into `site/`.
100
55
 
101
56
  | Page | Contents |
102
57
  |------|----------|
103
- | [Architecture](./docs/architecture.md) | The pipeline `setupTracing` builds, and how the service graph is fed |
104
- | [Configuration](./docs/usage.md) | Options, environment variables, initialisation order and shutdown |
105
- | [Instrumentation](./docs/instrumentation.md) | Each instrumentation, and the attributes it emits |
106
- | [Deployment](./docs/deployment.md) | Running instrumented services in containers and Kubernetes |
107
- | [Testing](./docs/testing.md) | The unit tests and the end to end harness |
108
- | [Troubleshooting](./docs/troubleshooting.md) | Symptoms, causes and fixes |
109
-
110
- Build them locally with `npm run build-docs`, which renders the site into `site/`.
58
+ | [Overview](https://tracing-node.readthedocs.io/en/latest/) | What the library does, the feature set and the requirements |
59
+ | [Architecture](https://tracing-node.readthedocs.io/en/latest/architecture/) | The pipeline `setupTracing` builds, and how the service graph is fed |
60
+ | [Configuration](https://tracing-node.readthedocs.io/en/latest/usage/) | Every option, the environment variables, initialisation order and shutdown |
61
+ | [Instrumentation](https://tracing-node.readthedocs.io/en/latest/instrumentation/) | Each instrumentation, and the attributes it emits |
62
+ | [Deployment](https://tracing-node.readthedocs.io/en/latest/deployment/) | Running instrumented services in containers and Kubernetes |
63
+ | [Testing](https://tracing-node.readthedocs.io/en/latest/testing/) | The unit tests and the end to end harness |
64
+ | [Troubleshooting](https://tracing-node.readthedocs.io/en/latest/troubleshooting/) | Symptoms, causes and fixes |
111
65
 
112
- ## Source
66
+ ## Upgrading
113
67
 
114
- Our latest and greatest source of `tracing-node` can be found on [GitHub](https://github.com/saidsef/tracing-node/fork). Fork us!
68
+ Breaking changes and the attribute renames they bring are recorded in the [release notes](https://github.com/saidsef/tracing-node/releases) for the version concerned.
115
69
 
116
70
  ## Contributing
117
71
 
118
- We would :heart: you to contribute by making a [pull request](https://github.com/saidsef/tracing-node/pulls).
72
+ Our latest and greatest source of `tracing-node` can be found on [GitHub](https://github.com/saidsef/tracing-node/fork). Fork us!
119
73
 
120
- Please read the official [Contribution Guide](./CONTRIBUTING.md) for more information on how you can contribute.
74
+ We would :heart: you to contribute by making a [pull request](https://github.com/saidsef/tracing-node/pulls). Please read the official [Contribution Guide](./CONTRIBUTING.md) for more information on how you can contribute.
@@ -12,7 +12,7 @@ spec:
12
12
  preemptionPolicy: PreemptLowerPriority
13
13
  containers:
14
14
  - name: tracing-node
15
- image: docker.io/node:20-alpine3.19
15
+ image: docker.io/node:24-alpine
16
16
  workingDir: "/app"
17
17
  command:
18
18
  - /bin/sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saidsef/tracing-node",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "tracing NodeJS - Wrapper for OpenTelemetry instrumentation packages",
5
5
  "main": "libs/index.mjs",
6
6
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  "author": "Said Sef <saidsef@gmail.com>",
26
26
  "license": "Apache-2.0",
27
27
  "engines": {
28
- "node": ">= 20.6.0"
28
+ "node": ">= 24.0.0"
29
29
  },
30
30
  "bugs": {
31
31
  "url": "https://github.com/saidsef/tracing-node/issues"