@bigfootai/sdk 1.21.0 → 1.22.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/dist/otel-config.d.ts +4 -0
- package/dist/otel-config.d.ts.map +1 -0
- package/dist/otel-config.js +4 -0
- package/dist/otel-config.js.map +1 -0
- package/dist/otel.d.ts +5 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/otel.js +68 -0
- package/dist/otel.js.map +1 -0
- package/dist/otel.test.d.ts +2 -0
- package/dist/otel.test.d.ts.map +1 -0
- package/dist/otel.test.js +12 -0
- package/dist/otel.test.js.map +1 -0
- package/package.json +23 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel-config.d.ts","sourceRoot":"","sources":["../src/otel-config.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD,eAAO,MAAM,oBAAoB,SAAS,MAAM,CAAC,UAAU,KAAiB,OAA2C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel-config.js","sourceRoot":"","sources":["../src/otel-config.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAEpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAyB,OAAO,CAAC,GAAG,EAAW,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,MAAM,CAAC"}
|
package/dist/otel.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
2
|
+
export declare const startTelemetry: () => NodeSDK | undefined;
|
|
3
|
+
export { SDK_DISABLED_VAR, shouldStartTelemetry } from './otel-config.js';
|
|
4
|
+
export declare const telemetry: NodeSDK;
|
|
5
|
+
//# sourceMappingURL=otel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAqBlD,eAAO,MAAM,cAAc,QAAO,OAAO,GAAG,SAqB3C,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,eAAO,MAAM,SAAS,SAAmB,CAAC"}
|
package/dist/otel.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starts OpenTelemetry for a provider, before the app and before anything it instruments:
|
|
3
|
+
*
|
|
4
|
+
* node --import @bigfootai/sdk/otel dist/index.js
|
|
5
|
+
*
|
|
6
|
+
* The ESM loader hook is only needed for ESM dependencies; express, pino, http and undici are
|
|
7
|
+
* CommonJS, so the require hook patches them without it.
|
|
8
|
+
*
|
|
9
|
+
* Logs go to the collector one record at a time, so a line written before an invocation hangs still
|
|
10
|
+
* leaves the process. Traces and metrics batch, and are flushed on shutdown: a timeout freezes the
|
|
11
|
+
* process with no shutdown, so that tail is lost.
|
|
12
|
+
*
|
|
13
|
+
* The collector receives all three at OTEL_EXPORTER_OTLP_ENDPOINT, which defaults to
|
|
14
|
+
* http://localhost:4318. Setting OTEL_SDK_DISABLED=true starts no SDK at all, which is what a local
|
|
15
|
+
* run without a collector wants.
|
|
16
|
+
*/
|
|
17
|
+
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
18
|
+
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
|
|
19
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
20
|
+
import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
|
|
21
|
+
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
|
|
22
|
+
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
|
|
23
|
+
import { MongoDBInstrumentation } from '@opentelemetry/instrumentation-mongodb';
|
|
24
|
+
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
|
|
25
|
+
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
|
|
26
|
+
import { SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
27
|
+
import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
|
|
28
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
29
|
+
import { shouldStartTelemetry } from './otel-config.js';
|
|
30
|
+
/**
|
|
31
|
+
* Instrumentations are chosen one at a time rather than taken as a bundle: each costs start-up time
|
|
32
|
+
* and patched surface, and a provider only needs the call paths it uses. http covers axios and the
|
|
33
|
+
* node client; undici covers fetch.
|
|
34
|
+
*/
|
|
35
|
+
const instrumentations = () => [
|
|
36
|
+
new HttpInstrumentation(),
|
|
37
|
+
new UndiciInstrumentation(),
|
|
38
|
+
new ExpressInstrumentation(),
|
|
39
|
+
new PinoInstrumentation(),
|
|
40
|
+
// enhancedDatabaseReporting adds query parameters and results to the span; off is the default,
|
|
41
|
+
// stated so that turning it on has to be deliberate.
|
|
42
|
+
new MongoDBInstrumentation({ enhancedDatabaseReporting: false }),
|
|
43
|
+
// DynamoDB commands are not serialised at all unless dynamoDBStatementSerializer is set, so item
|
|
44
|
+
// values never reach a span. suppressInternalInstrumentation hides the duplicate http span.
|
|
45
|
+
new AwsInstrumentation({ suppressInternalInstrumentation: true }),
|
|
46
|
+
];
|
|
47
|
+
export const startTelemetry = () => {
|
|
48
|
+
if (!shouldStartTelemetry())
|
|
49
|
+
return undefined;
|
|
50
|
+
const sdk = new NodeSDK({
|
|
51
|
+
instrumentations: instrumentations(),
|
|
52
|
+
// One record at a time: a batch processor holds records the process may never flush.
|
|
53
|
+
logRecordProcessors: [new SimpleLogRecordProcessor({ exporter: new OTLPLogExporter() })],
|
|
54
|
+
metricReaders: [new PeriodicExportingMetricReader({ exporter: new OTLPMetricExporter() })],
|
|
55
|
+
traceExporter: new OTLPTraceExporter(),
|
|
56
|
+
});
|
|
57
|
+
sdk.start();
|
|
58
|
+
// A SIGTERM is the one shutdown Lambda describes; a timeout does not send one.
|
|
59
|
+
const shutdown = () => {
|
|
60
|
+
void sdk.shutdown().catch(() => undefined);
|
|
61
|
+
};
|
|
62
|
+
process.once('SIGTERM', shutdown);
|
|
63
|
+
process.once('SIGINT', shutdown);
|
|
64
|
+
return sdk;
|
|
65
|
+
};
|
|
66
|
+
export { SDK_DISABLED_VAR, shouldStartTelemetry } from './otel-config.js';
|
|
67
|
+
export const telemetry = startTelemetry();
|
|
68
|
+
//# sourceMappingURL=otel.js.map
|
package/dist/otel.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel.js","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAA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E,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,MAAM,CAAC,MAAM,SAAS,GAAG,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel.test.d.ts","sourceRoot":"","sources":["../src/otel.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { SDK_DISABLED_VAR, shouldStartTelemetry } from './otel-config.js';
|
|
3
|
+
describe('shouldStartTelemetry', () => {
|
|
4
|
+
it('starts when the switch is absent or not true', () => {
|
|
5
|
+
expect(shouldStartTelemetry({})).toBe(true);
|
|
6
|
+
expect(shouldStartTelemetry({ [SDK_DISABLED_VAR]: 'false' })).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it('stays off only for an explicit true', () => {
|
|
9
|
+
expect(shouldStartTelemetry({ [SDK_DISABLED_VAR]: 'true' })).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=otel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel.test.js","sourceRoot":"","sources":["../src/otel.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigfootai/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.22.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"LICENSE",
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@bigfootai/bigfoot-types": "^5.4.302",
|
|
13
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.300.0",
|
|
14
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.300.0",
|
|
15
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.300.0",
|
|
16
|
+
"@opentelemetry/instrumentation-aws-sdk": "^0.79.0",
|
|
17
|
+
"@opentelemetry/instrumentation-express": "^0.72.0",
|
|
18
|
+
"@opentelemetry/instrumentation-http": "^0.300.0",
|
|
19
|
+
"@opentelemetry/instrumentation-mongodb": "^0.77.0",
|
|
20
|
+
"@opentelemetry/instrumentation-pino": "^0.70.0",
|
|
21
|
+
"@opentelemetry/instrumentation-undici": "^0.34.0",
|
|
22
|
+
"@opentelemetry/sdk-logs": "^3.0.0",
|
|
23
|
+
"@opentelemetry/sdk-metrics": "^3.0.0",
|
|
24
|
+
"@opentelemetry/sdk-node": "^0.300.0",
|
|
13
25
|
"body-parser": "^2.2.2",
|
|
14
26
|
"compression": "^1.8.1",
|
|
15
27
|
"express": "^5.0.1",
|
|
@@ -28,6 +40,16 @@
|
|
|
28
40
|
"typescript": "^5.7.3",
|
|
29
41
|
"vitest": "^3.0.0"
|
|
30
42
|
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"default": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./otel": {
|
|
49
|
+
"types": "./dist/otel.d.ts",
|
|
50
|
+
"default": "./dist/otel.js"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
31
53
|
"scripts": {
|
|
32
54
|
"build": "tsc",
|
|
33
55
|
"release": "pnpm build && pnpm version minor --no-git-checks --message 'chore: Published @bigfootai/sdk v%s' && pnpm publish --no-git-checks",
|