@spinajs/log-otlp 2.0.482

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 +32 -0
  2. package/package.json +62 -0
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # `@spinajs/log-otlp`
2
+
3
+ OTLP/HTTP log export target for `@spinajs/log`. Exports SpinaJS logs to any
4
+ OTLP-compatible backend ( the OpenTelemetry Collector, Grafana / Tempo / Loki
5
+ via OTel, Datadog, ... ) over OTLP/HTTP-JSON, POSTing to `${endpoint}/v1/logs`.
6
+
7
+ Entries are mapped to the OTLP Logs model ( `severityNumber` from the OTel
8
+ mapping, `body`, resource + record attributes, `traceId` / `spanId` from the
9
+ request trace context, structured errors to `exception.*` semantic attributes ),
10
+ buffered with a `BatchQueue`, and retried with the `@spinajs/util` resilience
11
+ pipeline ( exponential backoff + jitter, retryable-only, honoring `Retry-After` ).
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ {
17
+ logger: {
18
+ targets: [
19
+ {
20
+ name: "Otlp",
21
+ type: "OtlpLogTarget",
22
+ options: {
23
+ endpoint: "http://localhost:4318",
24
+ headers: { Authorization: "Bearer <token>" },
25
+ resource: { "service.name": "my-service" },
26
+ },
27
+ },
28
+ ],
29
+ rules: [{ name: "*", level: "trace", target: "Otlp" }],
30
+ },
31
+ }
32
+ ```
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "version": "2.0.482",
3
+ "description": "OTLP/HTTP log export target for @spinajs/log ( OpenTelemetry Protocol )",
4
+ "main": "lib/cjs/index.js",
5
+ "module": "lib/mjs/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./lib/mjs/index.d.ts",
9
+ "import": "./lib/mjs/index.js",
10
+ "require": "./lib/cjs/index.js"
11
+ }
12
+ },
13
+ "type": "module",
14
+ "private": false,
15
+ "engines": {
16
+ "node": ">=16.11"
17
+ },
18
+ "scripts": {
19
+ "build": "npm run clean && npm run compile",
20
+ "compile": "tsc -b tsconfig.mjs.json",
21
+ "compile:cjs": "tsc -b tsconfig.cjs.json",
22
+ "rimraf": "./node_modules/rimraf/bin.js",
23
+ "clean": "rimraf lib/ && rimraf tsconfig.tsbuildinfo",
24
+ "test": "ts-mocha --exit -p tsconfig.json test/**/*.test.ts",
25
+ "coverage": "nyc npm run test",
26
+ "build-docs": "rimraf docs && typedoc --options typedoc.json src/",
27
+ "format": "prettier --write \"src/**/*.ts\"",
28
+ "lint": "eslint -c .eslintrc.cjs --ext .ts src --fix",
29
+ "preversion": "npm run lint",
30
+ "version": "npm run format && git add -A src"
31
+ },
32
+ "author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/log)",
33
+ "license": "MIT",
34
+ "name": "@spinajs/log-otlp",
35
+ "homepage": "https://github.com/spinajs/main#readme",
36
+ "directories": {
37
+ "lib": "lib",
38
+ "test": "__tests__"
39
+ },
40
+ "files": [
41
+ "lib"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/spinajs/main.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/spinajs/main/issues"
52
+ },
53
+ "dependencies": {
54
+ "@spinajs/configuration-common": "^2.0.482",
55
+ "@spinajs/di": "^2.0.482",
56
+ "@spinajs/log": "^2.0.482",
57
+ "@spinajs/log-common": "^2.0.482",
58
+ "@spinajs/util": "^2.0.482",
59
+ "axios": "^1.2.3",
60
+ "lodash": "^4.17.21"
61
+ }
62
+ }