@pristine-ts/aws-xray 2.0.1 → 2.0.2

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.
@@ -14,5 +14,6 @@ exports.AwsXrayConfigurationKeys = void 0;
14
14
  */
15
15
  exports.AwsXrayConfigurationKeys = {
16
16
  Debug: "pristine.aws-xray.debug",
17
+ Activated: "pristine.aws-xray.activated",
17
18
  };
18
19
  //# sourceMappingURL=aws-xray.configuration-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aws-xray.configuration-keys.js","sourceRoot":"","sources":["../../../src/aws-xray.configuration-keys.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACU,QAAA,wBAAwB,GAAG;IACtC,KAAK,EAAE,yBAAyB;CACxB,CAAC"}
1
+ {"version":3,"file":"aws-xray.configuration-keys.js","sourceRoot":"","sources":["../../../src/aws-xray.configuration-keys.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACU,QAAA,wBAAwB,GAAG;IACtC,KAAK,EAAE,yBAAyB;IAChC,SAAS,EAAE,6BAA6B;CAChC,CAAC"}
@@ -31,6 +31,28 @@ exports.AwsXrayModule = {
31
31
  defaultResolvers: [
32
32
  new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_AWS_XRAY_DEBUG")),
33
33
  ]
34
+ },
35
+ /**
36
+ * Whether the X-Ray tracer should actually export traces. **Default `false`** —
37
+ * importing `@pristine-ts/aws-xray` (directly or transitively) is no longer enough
38
+ * on its own to start exporting; you must explicitly opt in by setting this to
39
+ * `true` (or `PRISTINE_AWS_XRAY_ACTIVATED=true`).
40
+ *
41
+ * The tracer is always constructed when the package is in the import graph (it has
42
+ * to be — the constructor wires up the stream listener the framework pushes traces
43
+ * into). When `activated === false`, the listener early-returns instead of touching
44
+ * the AWS X-Ray SDK. No segments are sent, no AWS credentials are required.
45
+ *
46
+ * This default-off model means local dev, tests, and CI environments don't
47
+ * accidentally try to ship segments to X-Ray when AWS isn't reachable.
48
+ */
49
+ {
50
+ parameterName: aws_xray_module_keyname_1.AwsXrayModuleKeyname + ".activated",
51
+ defaultValue: false,
52
+ isRequired: false,
53
+ defaultResolvers: [
54
+ new configuration_1.BooleanResolver(new configuration_1.EnvironmentVariableResolver("PRISTINE_AWS_XRAY_ACTIVATED")),
55
+ ]
34
56
  }
35
57
  ],
36
58
  importModules: [
@@ -1 +1 @@
1
- {"version":3,"file":"aws-xray.module.js","sourceRoot":"","sources":["../../../src/aws-xray.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,uEAA+D;AAC/D,sDAAuD;AACvD,kDAAmD;AACnD,8DAAwF;AAExF,oDAAkC;AAElC,gEAA8C;AACjC,QAAA,aAAa,GAAoB;IAC5C,OAAO,EAAE,8CAAoB;IAC7B,wBAAwB,EAAE;QACxB;YACE,aAAa,EAAE,8CAAoB,GAAG,QAAQ;YAC9C,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBAChB,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,yBAAyB,CAAC,CAAC;aAChF;SACF;KACF;IAED,aAAa,EAAE;QACb,2BAAe;QACf,uBAAa;KACd;IACD;;;OAGG;IACH,qBAAqB,EAAE,EAAE;CAC1B,CAAA"}
1
+ {"version":3,"file":"aws-xray.module.js","sourceRoot":"","sources":["../../../src/aws-xray.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,uEAA+D;AAC/D,sDAAuD;AACvD,kDAAmD;AACnD,8DAAwF;AAExF,oDAAkC;AAElC,gEAA8C;AACjC,QAAA,aAAa,GAAoB;IAC5C,OAAO,EAAE,8CAAoB;IAC7B,wBAAwB,EAAE;QACxB;YACE,aAAa,EAAE,8CAAoB,GAAG,QAAQ;YAC9C,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBAChB,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,yBAAyB,CAAC,CAAC;aAChF;SACF;QACD;;;;;;;;;;;;;WAaG;QACH;YACE,aAAa,EAAE,8CAAoB,GAAG,YAAY;YAClD,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,gBAAgB,EAAE;gBAChB,IAAI,+BAAe,CAAC,IAAI,2CAA2B,CAAC,6BAA6B,CAAC,CAAC;aACpF;SACF;KACF;IAED,aAAa,EAAE;QACb,2BAAe;QACf,uBAAa;KACd;IACD;;;OAGG;IACH,qBAAqB,EAAE,EAAE;CAC1B,CAAA"}
@@ -51,13 +51,21 @@ const telemetry_1 = require("@pristine-ts/telemetry");
51
51
  const common_1 = require("@pristine-ts/common");
52
52
  const stream_1 = require("stream");
53
53
  const aws_xray_sdk_1 = __importStar(require("aws-xray-sdk"));
54
+ const aws_xray_configuration_keys_1 = require("../aws-xray.configuration-keys");
54
55
  const aws_xray_module_keyname_1 = require("../aws-xray.module.keyname");
55
56
  /**
56
- * Tracer to be able to dump Pristine traces to AWS Xray
57
+ * Tracer to be able to dump Pristine traces to AWS X-Ray.
58
+ *
59
+ * The tracer is **always constructed** when `@pristine-ts/aws-xray` is in the import
60
+ * graph — that's a structural requirement of the framework's tracer registration. To
61
+ * disable export without removing the package, set the `pristine.aws-xray.activated`
62
+ * configuration to `false` (or `PRISTINE_AWS_XRAY_ACTIVATED=false`). When deactivated,
63
+ * the stream listener early-returns and the AWS X-Ray SDK is never touched.
57
64
  */
58
65
  let XrayTracer = class XrayTracer {
59
- constructor(debug, loghandler) {
66
+ constructor(debug, activated, loghandler) {
60
67
  this.debug = debug;
68
+ this.activated = activated;
61
69
  this.loghandler = loghandler;
62
70
  this.traceEndedStream = new stream_1.Readable({
63
71
  objectMode: true,
@@ -66,6 +74,13 @@ let XrayTracer = class XrayTracer {
66
74
  }
67
75
  });
68
76
  this.traceEndedStream.on('data', (trace) => {
77
+ // Honor the activation flag inside the listener (not at construction time) so the
78
+ // setting can be re-read without rebuilding the kernel. When off, drop the trace
79
+ // on the floor — the framework still considers the trace "delivered" to this
80
+ // tracer; this tracer just chose not to do anything with it.
81
+ if (this.activated === false) {
82
+ return;
83
+ }
69
84
  this.traceEnded(trace);
70
85
  });
71
86
  }
@@ -154,7 +169,8 @@ exports.XrayTracer = XrayTracer = __decorate([
154
169
  (0, common_1.tag)(common_1.ServiceDefinitionTagEnum.Tracer),
155
170
  (0, tsyringe_1.injectable)(),
156
171
  __param(0, (0, common_1.injectConfig)(telemetry_1.TelemetryConfigurationKeys.Debug)),
157
- __param(1, (0, tsyringe_1.inject)("LogHandlerInterface")),
158
- __metadata("design:paramtypes", [Boolean, Object])
172
+ __param(1, (0, common_1.injectConfig)(aws_xray_configuration_keys_1.AwsXrayConfigurationKeys.Activated)),
173
+ __param(2, (0, tsyringe_1.inject)("LogHandlerInterface")),
174
+ __metadata("design:paramtypes", [Boolean, Boolean, Object])
159
175
  ], XrayTracer);
160
176
  //# sourceMappingURL=xray.tracer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xray.tracer.js","sourceRoot":"","sources":["../../../../src/tracers/xray.tracer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,sDAAgG;AAChG,gDAA8F;AAC9F,mCAAgC;AAChC,6DAAwE;AACxE,wEAAgE;AAGhE;;GAEG;AAII,IAAM,UAAU,GAAhB,MAAM,UAAU;IAGrB,YAAoF,KAAc,EAC/B,UAA+B;QADd,UAAK,GAAL,KAAK,CAAS;QAC/B,eAAU,GAAV,UAAU,CAAqB;QAChG,IAAI,CAAC,gBAAgB,GAAG,IAAI,iBAAQ,CAAC;YACnC,UAAU,EAAE,IAAI;YAChB,IAAI,CAAC,IAAY;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAY,EAAE,EAA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