@ripplo/instrument 0.7.17 → 0.7.19

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/index.js CHANGED
@@ -13,6 +13,26 @@ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
13
13
  import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
14
14
  import { propagation } from "@opentelemetry/api";
15
15
  import { z } from "zod";
16
+
17
+ // src/redact.ts
18
+ var REDACTED = "[redacted]";
19
+ var SECRET_KEY_PATTERNS = [
20
+ /authorization/i,
21
+ /cf-access-client-secret/i,
22
+ /cf-access-client-id/i,
23
+ /x-ripplo-signature/i,
24
+ /webhook.?secret/i,
25
+ /\btoken\b/i,
26
+ /secret/i,
27
+ /api.?key/i,
28
+ /password/i,
29
+ /cookie/i
30
+ ];
31
+ function isSecretAttributeKey(key) {
32
+ return SECRET_KEY_PATTERNS.some((pattern) => pattern.test(key));
33
+ }
34
+
35
+ // src/register.ts
16
36
  var REQUIRE_PARENT = { requireParentSpan: true };
17
37
  var BAGGAGE_ATTRIBUTE_KEYS = ["ripplo.run"];
18
38
  var ENDPOINT_CACHE_TTL_MS = 1e3;
@@ -37,7 +57,9 @@ function register() {
37
57
  ],
38
58
  spanLimits: { attributeValueLengthLimit: 300 },
39
59
  spanProcessors: [
40
- new BaggageAttributeSpanProcessor(new BatchSpanProcessor(new LazyOtlpExporter()))
60
+ new BaggageAttributeSpanProcessor(
61
+ new RedactingSpanProcessor(new BatchSpanProcessor(new LazyOtlpExporter()))
62
+ )
41
63
  ],
42
64
  textMapPropagator: new CompositePropagator({
43
65
  propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()]
@@ -113,6 +135,27 @@ function findRipploRoot(dir) {
113
135
  const parent = path.dirname(dir);
114
136
  return parent === dir ? void 0 : findRipploRoot(parent);
115
137
  }
138
+ var RedactingSpanProcessor = class {
139
+ inner;
140
+ constructor(inner) {
141
+ this.inner = inner;
142
+ }
143
+ onStart(span, parentContext) {
144
+ this.inner.onStart(span, parentContext);
145
+ }
146
+ onEnd(span) {
147
+ Object.keys(span.attributes).filter((key) => isSecretAttributeKey(key)).forEach((key) => {
148
+ span.attributes[key] = REDACTED;
149
+ });
150
+ this.inner.onEnd(span);
151
+ }
152
+ forceFlush() {
153
+ return this.inner.forceFlush();
154
+ }
155
+ shutdown() {
156
+ return this.inner.shutdown();
157
+ }
158
+ };
116
159
  var BaggageAttributeSpanProcessor = class {
117
160
  inner;
118
161
  constructor(inner) {
package/dist/register.js CHANGED
@@ -13,6 +13,26 @@ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
13
13
  import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
14
14
  import { propagation } from "@opentelemetry/api";
15
15
  import { z } from "zod";
16
+
17
+ // src/redact.ts
18
+ var REDACTED = "[redacted]";
19
+ var SECRET_KEY_PATTERNS = [
20
+ /authorization/i,
21
+ /cf-access-client-secret/i,
22
+ /cf-access-client-id/i,
23
+ /x-ripplo-signature/i,
24
+ /webhook.?secret/i,
25
+ /\btoken\b/i,
26
+ /secret/i,
27
+ /api.?key/i,
28
+ /password/i,
29
+ /cookie/i
30
+ ];
31
+ function isSecretAttributeKey(key) {
32
+ return SECRET_KEY_PATTERNS.some((pattern) => pattern.test(key));
33
+ }
34
+
35
+ // src/register.ts
16
36
  var REQUIRE_PARENT = { requireParentSpan: true };
17
37
  var BAGGAGE_ATTRIBUTE_KEYS = ["ripplo.run"];
18
38
  var ENDPOINT_CACHE_TTL_MS = 1e3;
@@ -37,7 +57,9 @@ function register() {
37
57
  ],
38
58
  spanLimits: { attributeValueLengthLimit: 300 },
39
59
  spanProcessors: [
40
- new BaggageAttributeSpanProcessor(new BatchSpanProcessor(new LazyOtlpExporter()))
60
+ new BaggageAttributeSpanProcessor(
61
+ new RedactingSpanProcessor(new BatchSpanProcessor(new LazyOtlpExporter()))
62
+ )
41
63
  ],
42
64
  textMapPropagator: new CompositePropagator({
43
65
  propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()]
@@ -113,6 +135,27 @@ function findRipploRoot(dir) {
113
135
  const parent = path.dirname(dir);
114
136
  return parent === dir ? void 0 : findRipploRoot(parent);
115
137
  }
138
+ var RedactingSpanProcessor = class {
139
+ inner;
140
+ constructor(inner) {
141
+ this.inner = inner;
142
+ }
143
+ onStart(span, parentContext) {
144
+ this.inner.onStart(span, parentContext);
145
+ }
146
+ onEnd(span) {
147
+ Object.keys(span.attributes).filter((key) => isSecretAttributeKey(key)).forEach((key) => {
148
+ span.attributes[key] = REDACTED;
149
+ });
150
+ this.inner.onEnd(span);
151
+ }
152
+ forceFlush() {
153
+ return this.inner.forceFlush();
154
+ }
155
+ shutdown() {
156
+ return this.inner.shutdown();
157
+ }
158
+ };
116
159
  var BaggageAttributeSpanProcessor = class {
117
160
  inner;
118
161
  constructor(inner) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ripplo/instrument",
3
- "version": "0.7.17",
3
+ "version": "0.7.19",
4
4
  "description": "Server-side OpenTelemetry preload for Ripplo — streams backend spans into test runs",
5
5
  "homepage": "https://ripplo.ai",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -30,12 +30,14 @@
30
30
  "devDependencies": {
31
31
  "@types/node": "^25.9.1",
32
32
  "tsup": "^8.5.1",
33
+ "vitest": "^4.1.4",
33
34
  "@ripplo/eslint-config": "0.0.0"
34
35
  },
35
36
  "scripts": {
36
37
  "build": "tsup",
37
38
  "check-types": "tsc --noEmit",
38
- "lint": "eslint src"
39
+ "lint": "eslint src",
40
+ "test": "vitest run"
39
41
  },
40
42
  "main": "./dist/index.js"
41
43
  }