@unireq/otel 0.0.1 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +80 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @unireq/otel
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@unireq/otel.svg)](https://www.npmjs.com/package/@unireq/otel)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ OpenTelemetry instrumentation for Unireq HTTP clients. Automatic tracing with W3C Trace Context propagation following OpenTelemetry semantic conventions.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pnpm add @unireq/otel
12
+
13
+ # Peer dependencies
14
+ pnpm add @opentelemetry/api @opentelemetry/semantic-conventions
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { client } from '@unireq/core';
21
+ import { http, parse } from '@unireq/http';
22
+ import { otel } from '@unireq/otel';
23
+ import { trace } from '@opentelemetry/api';
24
+
25
+ const tracer = trace.getTracer('my-service', '1.0.0');
26
+
27
+ const api = client(
28
+ http('https://api.example.com'),
29
+ otel({ tracer }),
30
+ parse.json(),
31
+ );
32
+
33
+ // All requests create spans
34
+ const response = await api.get('/users');
35
+ ```
36
+
37
+ ## Features
38
+
39
+ | Symbol | Description |
40
+ | --- | --- |
41
+ | `otel(options)` | Creates a tracing policy for HTTP requests |
42
+ | `OtelOptions` | Tracer, span name formatter, custom attributes |
43
+
44
+ ## Configuration
45
+
46
+ ```typescript
47
+ otel({
48
+ tracer,
49
+ spanNameFormatter: (ctx) => `${ctx.method} ${new URL(ctx.url).pathname}`,
50
+ recordRequestBodySize: true,
51
+ recordResponseBodySize: true,
52
+ customAttributes: {
53
+ 'service.name': 'user-service',
54
+ 'deployment.environment': 'production',
55
+ },
56
+ propagateContext: true, // W3C Trace Context headers
57
+ });
58
+ ```
59
+
60
+ ## Span Attributes
61
+
62
+ | Attribute | Description |
63
+ | --- | --- |
64
+ | `http.request.method` | HTTP method |
65
+ | `url.full` | Full request URL |
66
+ | `server.address` | Server hostname |
67
+ | `http.response.status_code` | Response status |
68
+ | `error.type` | Error type on failure |
69
+
70
+ ## Trace Context Propagation
71
+
72
+ Automatically injects `traceparent` and `tracestate` headers for distributed tracing.
73
+
74
+ ## Documentation
75
+
76
+ Full documentation available at [unireq.dev](https://oorabona.github.io/unireq/)
77
+
78
+ ## License
79
+
80
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unireq/otel",
3
- "version": "0.0.1",
3
+ "version": "1.0.1",
4
4
  "description": "OpenTelemetry instrumentation for unireq HTTP clients",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "author": "Olivier Orabona",
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
- "@unireq/core": "0.0.1"
28
+ "@unireq/core": "1.0.1"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@opentelemetry/api": "^1.9.0",