@softprobe/softprobe-js 2.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/LICENSE +21 -0
- package/README.md +202 -0
- package/bin/softprobe +15 -0
- package/dist/api/baggage.d.ts +13 -0
- package/dist/api/baggage.d.ts.map +1 -0
- package/dist/api/baggage.js +32 -0
- package/dist/api/baggage.js.map +1 -0
- package/dist/api/compare.d.ts +16 -0
- package/dist/api/compare.d.ts.map +1 -0
- package/dist/api/compare.js +77 -0
- package/dist/api/compare.js.map +1 -0
- package/dist/api.d.ts +63 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +104 -0
- package/dist/api.js.map +1 -0
- package/dist/bindings/http-span.d.ts +6 -0
- package/dist/bindings/http-span.d.ts.map +1 -0
- package/dist/bindings/http-span.js +11 -0
- package/dist/bindings/http-span.js.map +1 -0
- package/dist/bindings/postgres-span.d.ts +6 -0
- package/dist/bindings/postgres-span.d.ts.map +1 -0
- package/dist/bindings/postgres-span.js +11 -0
- package/dist/bindings/postgres-span.js.map +1 -0
- package/dist/bindings/redis-span.d.ts +6 -0
- package/dist/bindings/redis-span.d.ts.map +1 -0
- package/dist/bindings/redis-span.js +11 -0
- package/dist/bindings/redis-span.js.map +1 -0
- package/dist/bindings/test-span.d.ts +6 -0
- package/dist/bindings/test-span.d.ts.map +1 -0
- package/dist/bindings/test-span.js +9 -0
- package/dist/bindings/test-span.js.map +1 -0
- package/dist/bootstrap/otel/framework-mutator.d.ts +20 -0
- package/dist/bootstrap/otel/framework-mutator.d.ts.map +1 -0
- package/dist/bootstrap/otel/framework-mutator.js +144 -0
- package/dist/bootstrap/otel/framework-mutator.js.map +1 -0
- package/dist/bootstrap/otel/inject.d.ts +17 -0
- package/dist/bootstrap/otel/inject.d.ts.map +1 -0
- package/dist/bootstrap/otel/inject.js +28 -0
- package/dist/bootstrap/otel/inject.js.map +1 -0
- package/dist/bootstrap/otel/mutator.d.ts +17 -0
- package/dist/bootstrap/otel/mutator.d.ts.map +1 -0
- package/dist/bootstrap/otel/mutator.js +51 -0
- package/dist/bootstrap/otel/mutator.js.map +1 -0
- package/dist/capture/express.d.ts +6 -0
- package/dist/capture/express.d.ts.map +1 -0
- package/dist/capture/express.js +11 -0
- package/dist/capture/express.js.map +1 -0
- package/dist/capture/fastify.d.ts +5 -0
- package/dist/capture/fastify.d.ts.map +1 -0
- package/dist/capture/fastify.js +9 -0
- package/dist/capture/fastify.js.map +1 -0
- package/dist/capture/framework-mutator.d.ts +20 -0
- package/dist/capture/framework-mutator.d.ts.map +1 -0
- package/dist/capture/framework-mutator.js +144 -0
- package/dist/capture/framework-mutator.js.map +1 -0
- package/dist/capture/http-inbound.d.ts +28 -0
- package/dist/capture/http-inbound.d.ts.map +1 -0
- package/dist/capture/http-inbound.js +40 -0
- package/dist/capture/http-inbound.js.map +1 -0
- package/dist/capture/inject.d.ts +17 -0
- package/dist/capture/inject.d.ts.map +1 -0
- package/dist/capture/inject.js +28 -0
- package/dist/capture/inject.js.map +1 -0
- package/dist/capture/mutator.d.ts +17 -0
- package/dist/capture/mutator.d.ts.map +1 -0
- package/dist/capture/mutator.js +51 -0
- package/dist/capture/mutator.js.map +1 -0
- package/dist/capture/postgres.d.ts +6 -0
- package/dist/capture/postgres.d.ts.map +1 -0
- package/dist/capture/postgres.js +11 -0
- package/dist/capture/postgres.js.map +1 -0
- package/dist/capture/redis.d.ts +5 -0
- package/dist/capture/redis.d.ts.map +1 -0
- package/dist/capture/redis.js +10 -0
- package/dist/capture/redis.js.map +1 -0
- package/dist/capture/store-accessor.d.ts +11 -0
- package/dist/capture/store-accessor.d.ts.map +1 -0
- package/dist/capture/store-accessor.js +19 -0
- package/dist/capture/store-accessor.js.map +1 -0
- package/dist/capture/stream-tap.d.ts +5 -0
- package/dist/capture/stream-tap.d.ts.map +1 -0
- package/dist/capture/stream-tap.js +9 -0
- package/dist/capture/stream-tap.js.map +1 -0
- package/dist/cli/diff-reporter.d.ts +26 -0
- package/dist/cli/diff-reporter.d.ts.map +1 -0
- package/dist/cli/diff-reporter.js +163 -0
- package/dist/cli/diff-reporter.js.map +1 -0
- package/dist/cli/diff.d.ts +18 -0
- package/dist/cli/diff.d.ts.map +1 -0
- package/dist/cli/diff.js +105 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +84 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/config-manager.d.ts +20 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +46 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/context.d.ts +98 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +198 -0
- package/dist/context.js.map +1 -0
- package/dist/core/bindings/http-span.d.ts +39 -0
- package/dist/core/bindings/http-span.d.ts.map +1 -0
- package/dist/core/bindings/http-span.js +55 -0
- package/dist/core/bindings/http-span.js.map +1 -0
- package/dist/core/bindings/index.d.ts +12 -0
- package/dist/core/bindings/index.d.ts.map +1 -0
- package/dist/core/bindings/index.js +21 -0
- package/dist/core/bindings/index.js.map +1 -0
- package/dist/core/bindings/postgres-span.d.ts +41 -0
- package/dist/core/bindings/postgres-span.d.ts.map +1 -0
- package/dist/core/bindings/postgres-span.js +57 -0
- package/dist/core/bindings/postgres-span.js.map +1 -0
- package/dist/core/bindings/redis-span.d.ts +40 -0
- package/dist/core/bindings/redis-span.d.ts.map +1 -0
- package/dist/core/bindings/redis-span.js +65 -0
- package/dist/core/bindings/redis-span.js.map +1 -0
- package/dist/core/bindings/test-span.d.ts +15 -0
- package/dist/core/bindings/test-span.d.ts.map +1 -0
- package/dist/core/bindings/test-span.js +24 -0
- package/dist/core/bindings/test-span.js.map +1 -0
- package/dist/core/cassette/capture-store-accessor.d.ts +11 -0
- package/dist/core/cassette/capture-store-accessor.d.ts.map +1 -0
- package/dist/core/cassette/capture-store-accessor.js +19 -0
- package/dist/core/cassette/capture-store-accessor.js.map +1 -0
- package/dist/core/cassette/context-request-storage.d.ts +14 -0
- package/dist/core/cassette/context-request-storage.d.ts.map +1 -0
- package/dist/core/cassette/context-request-storage.js +24 -0
- package/dist/core/cassette/context-request-storage.js.map +1 -0
- package/dist/core/cassette/index.d.ts +8 -0
- package/dist/core/cassette/index.d.ts.map +1 -0
- package/dist/core/cassette/index.js +16 -0
- package/dist/core/cassette/index.js.map +1 -0
- package/dist/core/cassette/ndjson-cassette.d.ts +22 -0
- package/dist/core/cassette/ndjson-cassette.d.ts.map +1 -0
- package/dist/core/cassette/ndjson-cassette.js +56 -0
- package/dist/core/cassette/ndjson-cassette.js.map +1 -0
- package/dist/core/cassette/request-storage.d.ts +16 -0
- package/dist/core/cassette/request-storage.d.ts.map +1 -0
- package/dist/core/cassette/request-storage.js +22 -0
- package/dist/core/cassette/request-storage.js.map +1 -0
- package/dist/core/context/index.d.ts +5 -0
- package/dist/core/context/index.d.ts.map +1 -0
- package/dist/core/context/index.js +9 -0
- package/dist/core/context/index.js.map +1 -0
- package/dist/core/contracts/index.d.ts +5 -0
- package/dist/core/contracts/index.d.ts.map +1 -0
- package/dist/core/contracts/index.js +3 -0
- package/dist/core/contracts/index.js.map +1 -0
- package/dist/core/identifier.d.ts +20 -0
- package/dist/core/identifier.d.ts.map +1 -0
- package/dist/core/identifier.js +31 -0
- package/dist/core/identifier.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +27 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/matcher/extract-key.d.ts +41 -0
- package/dist/core/matcher/extract-key.d.ts.map +1 -0
- package/dist/core/matcher/extract-key.js +80 -0
- package/dist/core/matcher/extract-key.js.map +1 -0
- package/dist/core/matcher/index.d.ts +9 -0
- package/dist/core/matcher/index.d.ts.map +1 -0
- package/dist/core/matcher/index.js +24 -0
- package/dist/core/matcher/index.js.map +1 -0
- package/dist/core/matcher/matcher.d.ts +25 -0
- package/dist/core/matcher/matcher.d.ts.map +1 -0
- package/dist/core/matcher/matcher.js +83 -0
- package/dist/core/matcher/matcher.js.map +1 -0
- package/dist/core/matcher/softprobe-matcher.d.ts +41 -0
- package/dist/core/matcher/softprobe-matcher.d.ts.map +1 -0
- package/dist/core/matcher/softprobe-matcher.js +92 -0
- package/dist/core/matcher/softprobe-matcher.js.map +1 -0
- package/dist/core/matcher/store-accessor.d.ts +14 -0
- package/dist/core/matcher/store-accessor.d.ts.map +1 -0
- package/dist/core/matcher/store-accessor.js +25 -0
- package/dist/core/matcher/store-accessor.js.map +1 -0
- package/dist/core/matcher/topology.d.ts +37 -0
- package/dist/core/matcher/topology.d.ts.map +1 -0
- package/dist/core/matcher/topology.js +72 -0
- package/dist/core/matcher/topology.js.map +1 -0
- package/dist/core/runtime/architecture-guard.d.ts +9 -0
- package/dist/core/runtime/architecture-guard.d.ts.map +1 -0
- package/dist/core/runtime/architecture-guard.js +131 -0
- package/dist/core/runtime/architecture-guard.js.map +1 -0
- package/dist/core/runtime/index.d.ts +6 -0
- package/dist/core/runtime/index.d.ts.map +1 -0
- package/dist/core/runtime/index.js +11 -0
- package/dist/core/runtime/index.js.map +1 -0
- package/dist/identifier.d.ts +5 -0
- package/dist/identifier.d.ts.map +1 -0
- package/dist/identifier.js +11 -0
- package/dist/identifier.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +21 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +51 -0
- package/dist/init.js.map +1 -0
- package/dist/instrumentations/common/http/context-headers.d.ts +9 -0
- package/dist/instrumentations/common/http/context-headers.d.ts.map +1 -0
- package/dist/instrumentations/common/http/context-headers.js +16 -0
- package/dist/instrumentations/common/http/context-headers.js.map +1 -0
- package/dist/instrumentations/common/http/inbound-capture.d.ts +17 -0
- package/dist/instrumentations/common/http/inbound-capture.d.ts.map +1 -0
- package/dist/instrumentations/common/http/inbound-capture.js +41 -0
- package/dist/instrumentations/common/http/inbound-capture.js.map +1 -0
- package/dist/instrumentations/common/http/inbound-record.d.ts +28 -0
- package/dist/instrumentations/common/http/inbound-record.d.ts.map +1 -0
- package/dist/instrumentations/common/http/inbound-record.js +40 -0
- package/dist/instrumentations/common/http/inbound-record.js.map +1 -0
- package/dist/instrumentations/common/http/span-adapter.d.ts +6 -0
- package/dist/instrumentations/common/http/span-adapter.d.ts.map +1 -0
- package/dist/instrumentations/common/http/span-adapter.js +12 -0
- package/dist/instrumentations/common/http/span-adapter.js.map +1 -0
- package/dist/instrumentations/common/http/stream-tap.d.ts +28 -0
- package/dist/instrumentations/common/http/stream-tap.d.ts.map +1 -0
- package/dist/instrumentations/common/http/stream-tap.js +61 -0
- package/dist/instrumentations/common/http/stream-tap.js.map +1 -0
- package/dist/instrumentations/express/capture.d.ts +26 -0
- package/dist/instrumentations/express/capture.d.ts.map +1 -0
- package/dist/instrumentations/express/capture.js +80 -0
- package/dist/instrumentations/express/capture.js.map +1 -0
- package/dist/instrumentations/express/index.d.ts +7 -0
- package/dist/instrumentations/express/index.d.ts.map +1 -0
- package/dist/instrumentations/express/index.js +15 -0
- package/dist/instrumentations/express/index.js.map +1 -0
- package/dist/instrumentations/express/replay.d.ts +10 -0
- package/dist/instrumentations/express/replay.d.ts.map +1 -0
- package/dist/instrumentations/express/replay.js +16 -0
- package/dist/instrumentations/express/replay.js.map +1 -0
- package/dist/instrumentations/fastify/capture.d.ts +13 -0
- package/dist/instrumentations/fastify/capture.d.ts.map +1 -0
- package/dist/instrumentations/fastify/capture.js +65 -0
- package/dist/instrumentations/fastify/capture.js.map +1 -0
- package/dist/instrumentations/fastify/index.d.ts +7 -0
- package/dist/instrumentations/fastify/index.d.ts.map +1 -0
- package/dist/instrumentations/fastify/index.js +13 -0
- package/dist/instrumentations/fastify/index.js.map +1 -0
- package/dist/instrumentations/fastify/replay.d.ts +13 -0
- package/dist/instrumentations/fastify/replay.d.ts.map +1 -0
- package/dist/instrumentations/fastify/replay.js +24 -0
- package/dist/instrumentations/fastify/replay.js.map +1 -0
- package/dist/instrumentations/fetch/index.d.ts +5 -0
- package/dist/instrumentations/fetch/index.d.ts.map +1 -0
- package/dist/instrumentations/fetch/index.js +10 -0
- package/dist/instrumentations/fetch/index.js.map +1 -0
- package/dist/instrumentations/fetch/replay.d.ts +19 -0
- package/dist/instrumentations/fetch/replay.d.ts.map +1 -0
- package/dist/instrumentations/fetch/replay.js +259 -0
- package/dist/instrumentations/fetch/replay.js.map +1 -0
- package/dist/instrumentations/postgres/capture.d.ts +46 -0
- package/dist/instrumentations/postgres/capture.d.ts.map +1 -0
- package/dist/instrumentations/postgres/capture.js +68 -0
- package/dist/instrumentations/postgres/capture.js.map +1 -0
- package/dist/instrumentations/postgres/index.d.ts +6 -0
- package/dist/instrumentations/postgres/index.d.ts.map +1 -0
- package/dist/instrumentations/postgres/index.js +14 -0
- package/dist/instrumentations/postgres/index.js.map +1 -0
- package/dist/instrumentations/postgres/replay.d.ts +20 -0
- package/dist/instrumentations/postgres/replay.d.ts.map +1 -0
- package/dist/instrumentations/postgres/replay.js +163 -0
- package/dist/instrumentations/postgres/replay.js.map +1 -0
- package/dist/instrumentations/redis/capture.d.ts +20 -0
- package/dist/instrumentations/redis/capture.d.ts.map +1 -0
- package/dist/instrumentations/redis/capture.js +61 -0
- package/dist/instrumentations/redis/capture.js.map +1 -0
- package/dist/instrumentations/redis/index.d.ts +6 -0
- package/dist/instrumentations/redis/index.d.ts.map +1 -0
- package/dist/instrumentations/redis/index.js +13 -0
- package/dist/instrumentations/redis/index.js.map +1 -0
- package/dist/instrumentations/redis/replay.d.ts +24 -0
- package/dist/instrumentations/redis/replay.d.ts.map +1 -0
- package/dist/instrumentations/redis/replay.js +173 -0
- package/dist/instrumentations/redis/replay.js.map +1 -0
- package/dist/replay/express.d.ts +5 -0
- package/dist/replay/express.d.ts.map +1 -0
- package/dist/replay/express.js +9 -0
- package/dist/replay/express.js.map +1 -0
- package/dist/replay/extract-key.d.ts +41 -0
- package/dist/replay/extract-key.d.ts.map +1 -0
- package/dist/replay/extract-key.js +80 -0
- package/dist/replay/extract-key.js.map +1 -0
- package/dist/replay/fastify.d.ts +5 -0
- package/dist/replay/fastify.d.ts.map +1 -0
- package/dist/replay/fastify.js +9 -0
- package/dist/replay/fastify.js.map +1 -0
- package/dist/replay/http.d.ts +5 -0
- package/dist/replay/http.d.ts.map +1 -0
- package/dist/replay/http.js +10 -0
- package/dist/replay/http.js.map +1 -0
- package/dist/replay/matcher.d.ts +25 -0
- package/dist/replay/matcher.d.ts.map +1 -0
- package/dist/replay/matcher.js +83 -0
- package/dist/replay/matcher.js.map +1 -0
- package/dist/replay/postgres.d.ts +5 -0
- package/dist/replay/postgres.d.ts.map +1 -0
- package/dist/replay/postgres.js +10 -0
- package/dist/replay/postgres.js.map +1 -0
- package/dist/replay/redis.d.ts +5 -0
- package/dist/replay/redis.d.ts.map +1 -0
- package/dist/replay/redis.js +10 -0
- package/dist/replay/redis.js.map +1 -0
- package/dist/replay/softprobe-matcher.d.ts +41 -0
- package/dist/replay/softprobe-matcher.d.ts.map +1 -0
- package/dist/replay/softprobe-matcher.js +92 -0
- package/dist/replay/softprobe-matcher.js.map +1 -0
- package/dist/replay/store-accessor.d.ts +14 -0
- package/dist/replay/store-accessor.d.ts.map +1 -0
- package/dist/replay/store-accessor.js +26 -0
- package/dist/replay/store-accessor.js.map +1 -0
- package/dist/replay/topology.d.ts +37 -0
- package/dist/replay/topology.d.ts.map +1 -0
- package/dist/replay/topology.js +72 -0
- package/dist/replay/topology.js.map +1 -0
- package/dist/store/cassette-store.d.ts +36 -0
- package/dist/store/cassette-store.d.ts.map +1 -0
- package/dist/store/cassette-store.js +66 -0
- package/dist/store/cassette-store.js.map +1 -0
- package/dist/types/schema.d.ts +114 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +13 -0
- package/dist/types/schema.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleHttpReplayRequest = handleHttpReplayRequest;
|
|
4
|
+
exports.setupHttpReplayInterceptor = setupHttpReplayInterceptor;
|
|
5
|
+
const stream_1 = require("stream");
|
|
6
|
+
const interceptors_1 = require("@mswjs/interceptors");
|
|
7
|
+
const ClientRequest_1 = require("@mswjs/interceptors/ClientRequest");
|
|
8
|
+
const fetch_1 = require("@mswjs/interceptors/fetch");
|
|
9
|
+
const api_1 = require("@opentelemetry/api");
|
|
10
|
+
const context_1 = require("../../context");
|
|
11
|
+
const config_manager_1 = require("../../config/config-manager");
|
|
12
|
+
const identifier_1 = require("../../core/identifier");
|
|
13
|
+
const http_span_1 = require("../../core/bindings/http-span");
|
|
14
|
+
const stream_tap_1 = require("../common/http/stream-tap");
|
|
15
|
+
const DEFAULT_MAX_PAYLOAD_SIZE = 1048576;
|
|
16
|
+
let cachedMaxPayloadSize = null;
|
|
17
|
+
function getCaptureMaxPayloadSize() {
|
|
18
|
+
if (cachedMaxPayloadSize != null)
|
|
19
|
+
return cachedMaxPayloadSize;
|
|
20
|
+
try {
|
|
21
|
+
const cfg = new config_manager_1.ConfigManager();
|
|
22
|
+
const n = cfg.get().capture?.maxPayloadSize;
|
|
23
|
+
cachedMaxPayloadSize = typeof n === 'number' && n > 0 ? n : DEFAULT_MAX_PAYLOAD_SIZE;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
cachedMaxPayloadSize = DEFAULT_MAX_PAYLOAD_SIZE;
|
|
27
|
+
}
|
|
28
|
+
return cachedMaxPayloadSize;
|
|
29
|
+
}
|
|
30
|
+
let cachedConfig = null;
|
|
31
|
+
let cachedConfigInitFailed = false;
|
|
32
|
+
function shouldIgnoreFromConfig(url) {
|
|
33
|
+
if (cachedConfigInitFailed)
|
|
34
|
+
return false;
|
|
35
|
+
try {
|
|
36
|
+
if (cachedConfig == null)
|
|
37
|
+
cachedConfig = new config_manager_1.ConfigManager();
|
|
38
|
+
return cachedConfig.shouldIgnore(url);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
cachedConfigInitFailed = true;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function jsonErrorResponse(message, details) {
|
|
46
|
+
const payload = details ? { error: message, details } : { error: message };
|
|
47
|
+
return new Response(JSON.stringify(payload), {
|
|
48
|
+
status: 500,
|
|
49
|
+
headers: {
|
|
50
|
+
'x-softprobe-error': 'true',
|
|
51
|
+
'content-type': 'application/json',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Serializes body for mock response. Returns '{}' when body is missing so consumer .json() does not throw. */
|
|
56
|
+
function toTextBody(body) {
|
|
57
|
+
if (typeof body === 'string')
|
|
58
|
+
return body;
|
|
59
|
+
if (body == null)
|
|
60
|
+
return '{}';
|
|
61
|
+
return JSON.stringify(body);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* CAPTURE branch: perform request with bypass fetch, tap response body via tapReadableStream,
|
|
65
|
+
* build outbound record, saveRecord (fire-and-forget), respondWith(tapped response).
|
|
66
|
+
*/
|
|
67
|
+
async function handleCaptureRequest(request, controller, bypassFetch) {
|
|
68
|
+
const method = (request.method ?? 'GET').toUpperCase();
|
|
69
|
+
const url = typeof request.url === 'string' ? request.url : String(request.url);
|
|
70
|
+
const identifier = (0, identifier_1.httpIdentifier)(method, url);
|
|
71
|
+
const span = api_1.trace.getActiveSpan();
|
|
72
|
+
const ctx = span?.spanContext();
|
|
73
|
+
const traceId = ctx?.traceId ?? '';
|
|
74
|
+
const spanId = ctx?.spanId ?? '';
|
|
75
|
+
const parentSpanId = span && 'parentSpanId' in span ? span.parentSpanId : undefined;
|
|
76
|
+
const spanName = span && 'name' in span ? span.name : undefined;
|
|
77
|
+
// Capture cassette/traceId before any await so async callbacks (e.g. getCaptured().then) still have them (Task 13.11).
|
|
78
|
+
const cassette = context_1.SoftprobeContext.getCassette();
|
|
79
|
+
const softprobeTraceId = context_1.SoftprobeContext.getTraceId();
|
|
80
|
+
const urlString = typeof url === 'string' ? url : String(url);
|
|
81
|
+
let response;
|
|
82
|
+
try {
|
|
83
|
+
const input = urlString.startsWith('http:') || urlString.startsWith('https:') ? new URL(urlString) : urlString;
|
|
84
|
+
response = await bypassFetch(input, {
|
|
85
|
+
method: request.method ?? 'GET',
|
|
86
|
+
headers: request.headers,
|
|
87
|
+
body: request.body ?? undefined,
|
|
88
|
+
duplex: request.duplex,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
const details = err instanceof Error ? err.message : String(err);
|
|
93
|
+
controller.respondWith(jsonErrorResponse('Softprobe Capture fetch failed', details));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!response.body) {
|
|
97
|
+
controller.respondWith(response);
|
|
98
|
+
if (context_1.SoftprobeContext.getMode() === 'CAPTURE' && cassette) {
|
|
99
|
+
const rec = {
|
|
100
|
+
version: '4.1',
|
|
101
|
+
traceId,
|
|
102
|
+
spanId,
|
|
103
|
+
parentSpanId,
|
|
104
|
+
spanName,
|
|
105
|
+
timestamp: new Date().toISOString(),
|
|
106
|
+
type: 'outbound',
|
|
107
|
+
protocol: 'http',
|
|
108
|
+
identifier,
|
|
109
|
+
responsePayload: { statusCode: response.status },
|
|
110
|
+
};
|
|
111
|
+
void cassette.saveRecord(softprobeTraceId ? { ...rec, traceId: softprobeTraceId } : rec).catch(() => { });
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const maxPayloadSize = getCaptureMaxPayloadSize();
|
|
116
|
+
const fromWeb = stream_1.Readable.fromWeb;
|
|
117
|
+
const toWeb = stream_1.Readable.toWeb;
|
|
118
|
+
if (typeof fromWeb === 'function' && typeof toWeb === 'function') {
|
|
119
|
+
try {
|
|
120
|
+
const nodeReadable = fromWeb(response.body);
|
|
121
|
+
const { readable, getCaptured } = (0, stream_tap_1.tapReadableStream)(nodeReadable, { maxPayloadSize });
|
|
122
|
+
const webStream = toWeb(readable);
|
|
123
|
+
const newResponse = new Response(webStream, {
|
|
124
|
+
status: response.status,
|
|
125
|
+
statusText: response.statusText,
|
|
126
|
+
headers: response.headers,
|
|
127
|
+
});
|
|
128
|
+
controller.respondWith(newResponse);
|
|
129
|
+
getCaptured()
|
|
130
|
+
.then((captured) => {
|
|
131
|
+
if (context_1.SoftprobeContext.getMode() !== 'CAPTURE' || !cassette)
|
|
132
|
+
return;
|
|
133
|
+
const bodyStr = captured.body.toString('utf8');
|
|
134
|
+
const rec = {
|
|
135
|
+
version: '4.1',
|
|
136
|
+
traceId,
|
|
137
|
+
spanId,
|
|
138
|
+
parentSpanId,
|
|
139
|
+
spanName,
|
|
140
|
+
timestamp: new Date().toISOString(),
|
|
141
|
+
type: 'outbound',
|
|
142
|
+
protocol: 'http',
|
|
143
|
+
identifier,
|
|
144
|
+
responsePayload: {
|
|
145
|
+
statusCode: response.status,
|
|
146
|
+
body: bodyStr,
|
|
147
|
+
...(captured.truncated && { truncated: true }),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
void cassette.saveRecord(softprobeTraceId ? { ...rec, traceId: softprobeTraceId } : rec).catch(() => { });
|
|
151
|
+
})
|
|
152
|
+
.catch(() => { });
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
controller.respondWith(response);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
response
|
|
160
|
+
.clone()
|
|
161
|
+
.text()
|
|
162
|
+
.then((bodyText) => {
|
|
163
|
+
if (context_1.SoftprobeContext.getMode() !== 'CAPTURE' || !cassette)
|
|
164
|
+
return;
|
|
165
|
+
const capped = bodyText.length > maxPayloadSize ? bodyText.slice(0, maxPayloadSize) : bodyText;
|
|
166
|
+
const rec = {
|
|
167
|
+
version: '4.1',
|
|
168
|
+
traceId,
|
|
169
|
+
spanId,
|
|
170
|
+
parentSpanId,
|
|
171
|
+
spanName,
|
|
172
|
+
timestamp: new Date().toISOString(),
|
|
173
|
+
type: 'outbound',
|
|
174
|
+
protocol: 'http',
|
|
175
|
+
identifier,
|
|
176
|
+
responsePayload: {
|
|
177
|
+
statusCode: response.status,
|
|
178
|
+
body: capped,
|
|
179
|
+
...(bodyText.length > maxPayloadSize && { truncated: true }),
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
void cassette.saveRecord(softprobeTraceId ? { ...rec, traceId: softprobeTraceId } : rec).catch(() => { });
|
|
183
|
+
})
|
|
184
|
+
.catch(() => { });
|
|
185
|
+
controller.respondWith(response);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async function handleHttpReplayRequest(event, options = {}) {
|
|
189
|
+
const { request, controller } = event;
|
|
190
|
+
try {
|
|
191
|
+
const url = typeof request.url === 'string' ? request.url : String(request.url);
|
|
192
|
+
const shouldIgnore = options.shouldIgnoreUrl ?? shouldIgnoreFromConfig;
|
|
193
|
+
if (shouldIgnore(url))
|
|
194
|
+
return;
|
|
195
|
+
if (context_1.SoftprobeContext.getMode() === 'CAPTURE' && options.bypassFetch) {
|
|
196
|
+
await handleCaptureRequest(request, controller, options.bypassFetch);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
/** Task 18.2.2: use active context mode to decide MOCK vs PASSTHROUGH; only run matcher when REPLAY. */
|
|
200
|
+
if (context_1.SoftprobeContext.getMode() !== 'REPLAY')
|
|
201
|
+
return;
|
|
202
|
+
const method = (request.method ?? 'GET').toUpperCase();
|
|
203
|
+
const identifier = (0, identifier_1.httpIdentifier)(method, url);
|
|
204
|
+
http_span_1.HttpSpan.tagRequest(method, url, undefined, api_1.trace.getActiveSpan() ?? undefined);
|
|
205
|
+
const matcher = context_1.SoftprobeContext.active().matcher;
|
|
206
|
+
const match = matcher?.match?.bind(matcher);
|
|
207
|
+
if (!match) {
|
|
208
|
+
throw new Error('Softprobe replay matcher is required in REPLAY mode');
|
|
209
|
+
}
|
|
210
|
+
const result = match({
|
|
211
|
+
attributes: {
|
|
212
|
+
'softprobe.protocol': 'http',
|
|
213
|
+
'softprobe.identifier': identifier,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
if (result.action === 'MOCK') {
|
|
217
|
+
const payload = (result.payload ?? {});
|
|
218
|
+
controller.respondWith(new Response(toTextBody(payload.body), {
|
|
219
|
+
status: payload.status ?? payload.statusCode ?? 200,
|
|
220
|
+
headers: payload.headers,
|
|
221
|
+
}));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (result.action === 'PASSTHROUGH')
|
|
225
|
+
return;
|
|
226
|
+
if (context_1.SoftprobeContext.getStrictReplay()) {
|
|
227
|
+
controller.respondWith(jsonErrorResponse('[Softprobe] No recorded traces found for http request'));
|
|
228
|
+
}
|
|
229
|
+
// CONTINUE + DEV: leave request untouched (passthrough)
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
232
|
+
const details = err instanceof Error ? err.message : String(err);
|
|
233
|
+
event.controller.respondWith(jsonErrorResponse('Softprobe Replay Error', details));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function getBypassFetch() {
|
|
237
|
+
try {
|
|
238
|
+
const undici = require('undici');
|
|
239
|
+
if (typeof undici.fetch === 'function')
|
|
240
|
+
return undici.fetch;
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
/* undici not available */
|
|
244
|
+
}
|
|
245
|
+
return globalThis.fetch;
|
|
246
|
+
}
|
|
247
|
+
function setupHttpReplayInterceptor(options = {}) {
|
|
248
|
+
const bypassFetch = options.bypassFetch ?? getBypassFetch();
|
|
249
|
+
const interceptor = new interceptors_1.BatchInterceptor({
|
|
250
|
+
name: 'softprobe-http-replay',
|
|
251
|
+
interceptors: [new ClientRequest_1.ClientRequestInterceptor(), new fetch_1.FetchInterceptor()],
|
|
252
|
+
});
|
|
253
|
+
interceptor.on('request', ({ request, controller }) => {
|
|
254
|
+
void handleHttpReplayRequest({ request, controller }, { ...options, bypassFetch: options.bypassFetch ?? bypassFetch });
|
|
255
|
+
});
|
|
256
|
+
interceptor.apply();
|
|
257
|
+
return interceptor;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../src/instrumentations/fetch/replay.ts"],"names":[],"mappings":";;AAqMA,0DAkEC;AAYD,gEAgBC;AAnSD,mCAAkC;AAClC,sDAAuD;AACvD,qEAA6E;AAC7E,qDAA6D;AAC7D,4CAA2C;AAC3C,2CAAiD;AACjD,gEAA4D;AAC5D,sDAAuD;AAEvD,6DAAyD;AACzD,0DAA8D;AAK9D,MAAM,wBAAwB,GAAG,OAAS,CAAC;AAC3C,IAAI,oBAAoB,GAAkB,IAAI,CAAC;AAE/C,SAAS,wBAAwB;IAC/B,IAAI,oBAAoB,IAAI,IAAI;QAAE,OAAO,oBAAoB,CAAC;IAC9D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,8BAAa,EAAE,CAAC;QAChC,MAAM,CAAC,GAAI,GAAG,CAAC,GAAG,EAAE,CAAC,OAAmD,EAAE,cAAc,CAAC;QACzF,oBAAoB,GAAG,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC;IACvF,CAAC;IAAC,MAAM,CAAC;QACP,oBAAoB,GAAG,wBAAwB,CAAC;IAClD,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAQD,IAAI,YAAY,GAAyB,IAAI,CAAC;AAC9C,IAAI,sBAAsB,GAAG,KAAK,CAAC;AAEnC,SAAS,sBAAsB,CAAC,GAAY;IAC1C,IAAI,sBAAsB;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,CAAC;QACH,IAAI,YAAY,IAAI,IAAI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BAA0B;IAC5B,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC;AAC1B,CAAC;AAED,SAAgB,0BAA0B,CAAC,UAA6B,EAAE;IACxE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,cAAc,EAAE,CAAC;IAC5D,MAAM,WAAW,GAAG,IAAI,+BAAgB,CAAC;QACvC,IAAI,EAAE,uBAAuB;QAC7B,YAAY,EAAE,CAAC,IAAI,wCAAwB,EAAE,EAAE,IAAI,wBAAgB,EAAE,CAAC;KACvE,CAAC,CAAC;IAEH,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;QACpD,KAAK,uBAAuB,CAC1B,EAAE,OAAO,EAAE,UAAU,EAAE,EACvB,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,WAAW,EAAE,CAChE,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,KAAK,EAAE,CAAC;IACpB,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture hooks for Postgres. Pairs with replay/postgres.ts (same protocol & identifier).
|
|
3
|
+
* Design §3.1, §5.3: hooks align with @opentelemetry/instrumentation-pg contracts.
|
|
4
|
+
* Design §10.4: query result rows written to NDJSON outbound record via CassetteStore.
|
|
5
|
+
*
|
|
6
|
+
* Unlike Redis/undici where a single responseHook receives both request and response
|
|
7
|
+
* info, instrumentation-pg splits them into separate hooks:
|
|
8
|
+
* requestHook(span, { query: { text, values?, name? }, connection })
|
|
9
|
+
* responseHook(span, { data: { rows, rowCount, command, ... } })
|
|
10
|
+
*/
|
|
11
|
+
/** Query info passed to the pg requestHook. Contract: PgRequestHookInformation. */
|
|
12
|
+
export interface PgQueryInfo {
|
|
13
|
+
query: {
|
|
14
|
+
text: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
values?: unknown[];
|
|
17
|
+
};
|
|
18
|
+
connection?: {
|
|
19
|
+
database?: string;
|
|
20
|
+
host?: string;
|
|
21
|
+
port?: number;
|
|
22
|
+
user?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Result info passed to the pg responseHook. Contract: PgResponseHookInformation. */
|
|
26
|
+
export interface PgResultInfo {
|
|
27
|
+
data: {
|
|
28
|
+
rows?: unknown[];
|
|
29
|
+
rowCount?: number | null;
|
|
30
|
+
command?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare const PG_INSTRUMENTATION_NAME = "@opentelemetry/instrumentation-pg";
|
|
34
|
+
/**
|
|
35
|
+
* Builds the requestHook for Postgres instrumentation.
|
|
36
|
+
* Sets softprobe.protocol, softprobe.identifier (SQL text), and softprobe.request.body
|
|
37
|
+
* (query text + values) on the span.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildPostgresRequestHook(): (span: unknown, queryInfo: unknown) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Builds the responseHook for Postgres instrumentation.
|
|
42
|
+
* Sets softprobe.response.body on the span and, when a capture store is set,
|
|
43
|
+
* writes an outbound SoftprobeCassetteRecord with responsePayload.rows (Task 10.4.1).
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildPostgresResponseHook(): (span: unknown, result: unknown) => void;
|
|
46
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/postgres/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAC3D,UAAU,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjF;AAED,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxE;AAED,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAW3E;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAatF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CA8BpF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Capture hooks for Postgres. Pairs with replay/postgres.ts (same protocol & identifier).
|
|
4
|
+
* Design §3.1, §5.3: hooks align with @opentelemetry/instrumentation-pg contracts.
|
|
5
|
+
* Design §10.4: query result rows written to NDJSON outbound record via CassetteStore.
|
|
6
|
+
*
|
|
7
|
+
* Unlike Redis/undici where a single responseHook receives both request and response
|
|
8
|
+
* info, instrumentation-pg splits them into separate hooks:
|
|
9
|
+
* requestHook(span, { query: { text, values?, name? }, connection })
|
|
10
|
+
* responseHook(span, { data: { rows, rowCount, command, ... } })
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.PG_INSTRUMENTATION_NAME = void 0;
|
|
14
|
+
exports.buildPostgresRequestHook = buildPostgresRequestHook;
|
|
15
|
+
exports.buildPostgresResponseHook = buildPostgresResponseHook;
|
|
16
|
+
const context_1 = require("../../context");
|
|
17
|
+
exports.PG_INSTRUMENTATION_NAME = '@opentelemetry/instrumentation-pg';
|
|
18
|
+
/**
|
|
19
|
+
* Builds the requestHook for Postgres instrumentation.
|
|
20
|
+
* Sets softprobe.protocol, softprobe.identifier (SQL text), and softprobe.request.body
|
|
21
|
+
* (query text + values) on the span.
|
|
22
|
+
*/
|
|
23
|
+
function buildPostgresRequestHook() {
|
|
24
|
+
return (span, queryInfo) => {
|
|
25
|
+
const s = span;
|
|
26
|
+
const info = queryInfo;
|
|
27
|
+
const text = info?.query?.text ?? '';
|
|
28
|
+
s.setAttribute('softprobe.protocol', 'postgres');
|
|
29
|
+
s.setAttribute('softprobe.identifier', text);
|
|
30
|
+
s.setAttribute('softprobe.request.body', JSON.stringify({ text, values: info?.query?.values ?? [] }));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Builds the responseHook for Postgres instrumentation.
|
|
35
|
+
* Sets softprobe.response.body on the span and, when a capture store is set,
|
|
36
|
+
* writes an outbound SoftprobeCassetteRecord with responsePayload.rows (Task 10.4.1).
|
|
37
|
+
*/
|
|
38
|
+
function buildPostgresResponseHook() {
|
|
39
|
+
return (span, result) => {
|
|
40
|
+
const s = span;
|
|
41
|
+
const info = result;
|
|
42
|
+
const data = info?.data ?? {};
|
|
43
|
+
const responseBody = { rows: data.rows ?? [], rowCount: data.rowCount ?? 0, command: data.command };
|
|
44
|
+
if (s.setAttribute) {
|
|
45
|
+
s.setAttribute('softprobe.response.body', JSON.stringify(responseBody));
|
|
46
|
+
}
|
|
47
|
+
const ctx = s.spanContext?.() ?? { traceId: '', spanId: '' };
|
|
48
|
+
const attrs = s.attributes ?? {};
|
|
49
|
+
const record = {
|
|
50
|
+
version: '4.1',
|
|
51
|
+
traceId: ctx.traceId,
|
|
52
|
+
spanId: ctx.spanId,
|
|
53
|
+
parentSpanId: s.parentSpanId,
|
|
54
|
+
spanName: s.name,
|
|
55
|
+
timestamp: new Date().toISOString(),
|
|
56
|
+
type: 'outbound',
|
|
57
|
+
protocol: 'postgres',
|
|
58
|
+
identifier: attrs['softprobe.identifier'] ?? '',
|
|
59
|
+
responsePayload: { rows: data.rows ?? [], rowCount: data.rowCount ?? 0, command: data.command },
|
|
60
|
+
};
|
|
61
|
+
const cassette = context_1.SoftprobeContext.getCassette();
|
|
62
|
+
if (context_1.SoftprobeContext.getMode() === 'CAPTURE' && cassette) {
|
|
63
|
+
const tid = context_1.SoftprobeContext.getTraceId();
|
|
64
|
+
void cassette.saveRecord(tid ? { ...record, traceId: tid } : record).catch(() => { });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../../src/instrumentations/postgres/capture.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAgCH,4DAaC;AAOD,8DA8BC;AA/ED,2CAAiD;AAapC,QAAA,uBAAuB,GAAG,mCAAmC,CAAC;AAW3E;;;;GAIG;AACH,SAAgB,wBAAwB;IACtC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QACzB,MAAM,CAAC,GAAG,IAA+D,CAAC;QAC1E,MAAM,IAAI,GAAG,SAAwB,CAAC;QACtC,MAAM,IAAI,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC;QAErC,CAAC,CAAC,YAAY,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;QACjD,CAAC,CAAC,YAAY,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC,CAAC,YAAY,CACZ,wBAAwB,EACxB,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAC5D,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,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AAM,QAAQ,GAAG,0BAAgB,CAAC,WAAW,EAAE,CAAC;QAChD,IAAI,0BAAgB,CAAC,OAAO,EAAE,KAAK,SAAS,IAAI,QAAQ,EAAE,CAAC;YACzD,MAAM,GAAG,GAAG,0BAAgB,CAAC,UAAU,EAAE,CAAC;YAC1C,KAAK,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postgres instrumentation package entry point.
|
|
3
|
+
*/
|
|
4
|
+
export { PG_INSTRUMENTATION_NAME, buildPostgresRequestHook, buildPostgresResponseHook, } from './capture';
|
|
5
|
+
export { applyPostgresReplay, setupPostgresReplay } from './replay';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/postgres/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupPostgresReplay = exports.applyPostgresReplay = exports.buildPostgresResponseHook = exports.buildPostgresRequestHook = exports.PG_INSTRUMENTATION_NAME = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Postgres instrumentation package entry point.
|
|
6
|
+
*/
|
|
7
|
+
var capture_1 = require("./capture");
|
|
8
|
+
Object.defineProperty(exports, "PG_INSTRUMENTATION_NAME", { enumerable: true, get: function () { return capture_1.PG_INSTRUMENTATION_NAME; } });
|
|
9
|
+
Object.defineProperty(exports, "buildPostgresRequestHook", { enumerable: true, get: function () { return capture_1.buildPostgresRequestHook; } });
|
|
10
|
+
Object.defineProperty(exports, "buildPostgresResponseHook", { enumerable: true, get: function () { return capture_1.buildPostgresResponseHook; } });
|
|
11
|
+
var replay_1 = require("./replay");
|
|
12
|
+
Object.defineProperty(exports, "applyPostgresReplay", { enumerable: true, get: function () { return replay_1.applyPostgresReplay; } });
|
|
13
|
+
Object.defineProperty(exports, "setupPostgresReplay", { enumerable: true, get: function () { return replay_1.setupPostgresReplay; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentations/postgres/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,qCAImB;AAHjB,kHAAA,uBAAuB,OAAA;AACvB,mHAAA,wBAAwB,OAAA;AACxB,oHAAA,yBAAyB,OAAA;AAE3B,mCAAoE;AAA3D,6GAAA,mBAAmB,OAAA;AAAE,6GAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postgres replay: patches pg.Client.prototype.query so that under replay context
|
|
3
|
+
* calls are resolved by the SemanticMatcher (no live network). Pairs with capture
|
|
4
|
+
* Task 4.2; identifier = query text per design §3.1, §6.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Patches a pg module so connect is no-op and query uses matcher. Idempotent.
|
|
8
|
+
* Exported so init can call it from a require hook and patch whichever module first requires 'pg' (Task 16.3.1).
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyPostgresReplay(pg: {
|
|
11
|
+
Client: {
|
|
12
|
+
prototype: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
}): void;
|
|
15
|
+
/**
|
|
16
|
+
* Sets up Postgres replay. Called from init so patches are in place before OTel.
|
|
17
|
+
* Idempotent when already applied. OTel may wrap on top when sdk.start() runs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function setupPostgresReplay(): void;
|
|
20
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/postgres/replay.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE;IAAE,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAA;CAAE,GAAG,IAAI,CAuIhG;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAQ1C"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Postgres replay: patches pg.Client.prototype.query so that under replay context
|
|
4
|
+
* calls are resolved by the SemanticMatcher (no live network). Pairs with capture
|
|
5
|
+
* Task 4.2; identifier = query text per design §3.1, §6.
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.applyPostgresReplay = applyPostgresReplay;
|
|
12
|
+
exports.setupPostgresReplay = setupPostgresReplay;
|
|
13
|
+
const shimmer_1 = __importDefault(require("shimmer"));
|
|
14
|
+
const api_1 = require("@opentelemetry/api");
|
|
15
|
+
const context_1 = require("../../context");
|
|
16
|
+
const postgres_span_1 = require("../../core/bindings/postgres-span");
|
|
17
|
+
const SOFTPROBE_WRAPPED_MARKER = '__softprobeWrapped';
|
|
18
|
+
/**
|
|
19
|
+
* Patches a pg module so connect is no-op and query uses matcher. Idempotent.
|
|
20
|
+
* Exported so init can call it from a require hook and patch whichever module first requires 'pg' (Task 16.3.1).
|
|
21
|
+
*/
|
|
22
|
+
function applyPostgresReplay(pg) {
|
|
23
|
+
const existingQuery = pg.Client.prototype.query;
|
|
24
|
+
if (existingQuery[SOFTPROBE_WRAPPED_MARKER])
|
|
25
|
+
return;
|
|
26
|
+
const connectKey = 'connect';
|
|
27
|
+
const existingConnect = pg.Client.prototype[connectKey];
|
|
28
|
+
if (typeof pg.Client.prototype[connectKey] === 'function' && !existingConnect?.__softprobeConnect) {
|
|
29
|
+
const origConnect = pg.Client.prototype[connectKey];
|
|
30
|
+
// Use Object.defineProperty (NOT shimmer.wrap) so OTel does NOT detect __wrapped and strip us.
|
|
31
|
+
// OTel's isWrapped() checks __wrapped; without it, OTel wraps our function instead of
|
|
32
|
+
// replacing it. Call chain: OTel wrapper → our wrapper → original connect.
|
|
33
|
+
const patchedConnect = function wrappedConnect(...args) {
|
|
34
|
+
if (context_1.SoftprobeContext.getMode() === 'REPLAY')
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
return origConnect.apply(this, args);
|
|
37
|
+
};
|
|
38
|
+
patchedConnect.__softprobeConnect = true;
|
|
39
|
+
Object.defineProperty(pg.Client.prototype, connectKey, {
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: patchedConnect,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// end() must not touch the network when we never connected (Task 16.3.1). OTel does not wrap
|
|
46
|
+
// end(), so shimmer is safe here.
|
|
47
|
+
const endKey = 'end';
|
|
48
|
+
const existingEnd = pg.Client.prototype[endKey];
|
|
49
|
+
if (typeof pg.Client.prototype[endKey] === 'function' && !existingEnd?.__softprobeEndNoop) {
|
|
50
|
+
shimmer_1.default.wrap(pg.Client.prototype, endKey, (originalEnd) => function wrappedEnd(...args) {
|
|
51
|
+
if (context_1.SoftprobeContext.getMode() === 'REPLAY')
|
|
52
|
+
return Promise.resolve();
|
|
53
|
+
return originalEnd.apply(this, args);
|
|
54
|
+
});
|
|
55
|
+
pg.Client.prototype[endKey].__softprobeEndNoop = true;
|
|
56
|
+
}
|
|
57
|
+
// Use Object.defineProperty (NOT shimmer.wrap) so OTel does NOT detect __wrapped and strip us.
|
|
58
|
+
// OTel wraps our patchedQuery with its span-creating wrapper; our wrapper stays in the chain.
|
|
59
|
+
// Call chain: OTel query wrapper → our patchedQuery → original query.
|
|
60
|
+
const origQuery = pg.Client.prototype.query;
|
|
61
|
+
const patchedQuery = function wrappedQuery(...args) {
|
|
62
|
+
const matcher = context_1.SoftprobeContext.active().matcher;
|
|
63
|
+
const mode = context_1.SoftprobeContext.getMode();
|
|
64
|
+
const strictReplay = context_1.SoftprobeContext.getStrictReplay();
|
|
65
|
+
if (!matcher) {
|
|
66
|
+
if (mode === 'REPLAY' && strictReplay) {
|
|
67
|
+
const replayErr = new Error('Softprobe replay: no match for pg.query');
|
|
68
|
+
const lastArg = args[args.length - 1];
|
|
69
|
+
const cb = typeof lastArg === 'function' ? lastArg : undefined;
|
|
70
|
+
if (cb) {
|
|
71
|
+
process.nextTick(() => cb(replayErr));
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
return Promise.reject(replayErr);
|
|
75
|
+
}
|
|
76
|
+
return origQuery.apply(this, args);
|
|
77
|
+
}
|
|
78
|
+
const config = args[0];
|
|
79
|
+
const queryString = typeof config === 'string' ? config : config?.text;
|
|
80
|
+
if (typeof queryString !== 'string') {
|
|
81
|
+
return origQuery.apply(this, args);
|
|
82
|
+
}
|
|
83
|
+
// Support both promise and callback style (design §9.1: callback is last arg).
|
|
84
|
+
const lastArg = args[args.length - 1];
|
|
85
|
+
const cb = typeof lastArg === 'function' ? lastArg : undefined;
|
|
86
|
+
const valsArray = Array.isArray(args[1]) ? args[1] : undefined;
|
|
87
|
+
postgres_span_1.PostgresSpan.tagQuery(queryString, valsArray, api_1.trace.getActiveSpan() ?? undefined);
|
|
88
|
+
let payload;
|
|
89
|
+
const softprobeMatcher = matcher;
|
|
90
|
+
if (typeof softprobeMatcher.match === 'function') {
|
|
91
|
+
const r = softprobeMatcher.match({
|
|
92
|
+
attributes: {
|
|
93
|
+
'softprobe.protocol': 'postgres',
|
|
94
|
+
'softprobe.identifier': queryString,
|
|
95
|
+
...(valsArray !== undefined && { 'softprobe.request.body': JSON.stringify(valsArray) }),
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
if (r.action === 'MOCK') {
|
|
99
|
+
payload = r.payload;
|
|
100
|
+
}
|
|
101
|
+
else if (r.action === 'PASSTHROUGH') {
|
|
102
|
+
return origQuery.apply(this, args);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
if (strictReplay) {
|
|
106
|
+
const strictErr = new Error('Softprobe replay: no match for pg.query');
|
|
107
|
+
if (cb) {
|
|
108
|
+
process.nextTick(() => cb(strictErr));
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
return Promise.reject(strictErr);
|
|
112
|
+
}
|
|
113
|
+
return origQuery.apply(this, args);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
try {
|
|
118
|
+
payload = matcher.findMatch({
|
|
119
|
+
protocol: 'postgres',
|
|
120
|
+
identifier: queryString,
|
|
121
|
+
requestBody: valsArray,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
if (strictReplay) {
|
|
126
|
+
const strictErr = new Error('Softprobe replay: no match for pg.query');
|
|
127
|
+
if (cb) {
|
|
128
|
+
process.nextTick(() => cb(strictErr));
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
return Promise.reject(strictErr);
|
|
132
|
+
}
|
|
133
|
+
return origQuery.apply(this, args);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const rows = Array.isArray(payload) ? payload : payload?.rows ?? [];
|
|
137
|
+
const rowCount = payload?.rowCount ?? rows.length;
|
|
138
|
+
const mockedResult = { rows, rowCount, command: 'SELECT', oid: 0, fields: [] };
|
|
139
|
+
if (cb) {
|
|
140
|
+
process.nextTick(() => cb(null, mockedResult));
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
return Promise.resolve(mockedResult);
|
|
144
|
+
};
|
|
145
|
+
patchedQuery[SOFTPROBE_WRAPPED_MARKER] = true;
|
|
146
|
+
Object.defineProperty(pg.Client.prototype, 'query', {
|
|
147
|
+
configurable: true,
|
|
148
|
+
writable: true,
|
|
149
|
+
value: patchedQuery,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Sets up Postgres replay. Called from init so patches are in place before OTel.
|
|
154
|
+
* Idempotent when already applied. OTel may wrap on top when sdk.start() runs.
|
|
155
|
+
*/
|
|
156
|
+
function setupPostgresReplay() {
|
|
157
|
+
const pg = require('pg');
|
|
158
|
+
const existingQuery = pg.Client.prototype.query;
|
|
159
|
+
if (existingQuery[SOFTPROBE_WRAPPED_MARKER])
|
|
160
|
+
return;
|
|
161
|
+
applyPostgresReplay(pg);
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../src/instrumentations/postgres/replay.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AAeH,kDAuIC;AAMD,kDAQC;AAlKD,sDAA8B;AAC9B,4CAA2C;AAG3C,2CAAiD;AACjD,qEAAiE;AAEjE,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,EAAsD;IACxF,MAAM,aAAa,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAiD,CAAC;IAC5F,IAAI,aAAa,CAAC,wBAAwB,CAAC;QAAE,OAAO;IAEpD,MAAM,UAAU,GAAG,SAAkB,CAAC;IACtC,MAAM,eAAe,GAAG,EAAE,CAAC,MAA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AC,CAAC,OAAO,CAAC,CAAC,CAAE,OAAgC,EAAE,IAAI,IAAI,EAAE,CAAC;QAC9F,MAAM,QAAQ,GAAI,OAAiC,EAAE,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC;QAC7E,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAE/E,IAAI,EAAE,EAAE,CAAC;YACP,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAE,EAAiD,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;YAC/F,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC,CAAC;IACD,YAAmD,CAAC,wBAAwB,CAAC,GAAG,IAAI,CAAC;IACtF,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE;QAClD,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,YAAY;KACpB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,aAAa,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAGzC,CAAC;IACF,IAAI,aAAa,CAAC,wBAAwB,CAAC;QAAE,OAAO;IACpD,mBAAmB,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture hook for Redis. Pairs with replay/redis.ts (same protocol & identifier).
|
|
3
|
+
* Design §3.1, §5.3: responseHook contract must match @opentelemetry/instrumentation-redis-4.
|
|
4
|
+
* Design §10.5: when capture store is set, writes outbound record with responsePayload.
|
|
5
|
+
*
|
|
6
|
+
* Actual contract (from types.d.ts):
|
|
7
|
+
* responseHook(span: Span, cmdName: string, cmdArgs: Array<string|Buffer>, response: unknown): void
|
|
8
|
+
*/
|
|
9
|
+
export declare const REDIS_INSTRUMENTATION_NAME = "@opentelemetry/instrumentation-redis-4";
|
|
10
|
+
/**
|
|
11
|
+
* Builds the responseHook for Redis instrumentation.
|
|
12
|
+
* Sets softprobe.protocol: 'redis', identifier (command + args), and
|
|
13
|
+
* request/response on spans per design §3.1.
|
|
14
|
+
* When a capture store is set, writes an outbound SoftprobeCassetteRecord (Task 10.5.1).
|
|
15
|
+
*
|
|
16
|
+
* The instrumentation calls: responseHook(span, cmdName, cmdArgs, response).
|
|
17
|
+
* We declare the return type loosely so it can be stored via injectHook.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildRedisResponseHook(): (...args: unknown[]) => void;
|
|
20
|
+
//# sourceMappingURL=capture.d.ts.map
|