@twin.org/tracing-processors 0.9.3-next.1 → 0.9.3-next.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ITracingRestClientProcessorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/ITracingRestClientProcessorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\nimport type { ITracingRestClientProcessorConfig } from \"./ITracingRestClientProcessorConfig.js\";\n\n/**\n * Options for the TracingRestClientProcessor constructor.\n */\nexport interface ITracingRestClientProcessorConstructorOptions {\n\t/**\n\t * The type for the tracing component, when absent no spans are created and no trace header is\n\t * sent.\n\t */\n\ttracingComponentType?: string;\n\n\t/**\n\t * Configuration for the processor.\n\t */\n\tconfig?: ITracingRestClientProcessorConfig;\n}\n"]}
1
+ {"version":3,"file":"ITracingRestClientProcessorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/ITracingRestClientProcessorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\nimport type { ITracingRestClientProcessorConfig } from \"./ITracingRestClientProcessorConfig.js\";\n\n/**\n * Options for the TracingRestClientProcessor constructor.\n */\nexport interface ITracingRestClientProcessorConstructorOptions {\n\t/**\n\t * The type for the tracing component, when absent no spans are created and no trace header is\n\t * sent.\n\t */\n\ttracingComponentType?: string;\n\n\t/**\n\t * The type for the logging component, used to report a tracing failure.\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * Configuration for the processor.\n\t */\n\tconfig?: ITracingRestClientProcessorConfig;\n}\n"]}
@@ -15,6 +15,11 @@ export class TracingRestClientProcessor {
15
15
  * @internal
16
16
  */
17
17
  _tracing;
18
+ /**
19
+ * The component for logging a tracing failure.
20
+ * @internal
21
+ */
22
+ _logging;
18
23
  /**
19
24
  * Route templates to skip tracing.
20
25
  * @internal
@@ -26,6 +31,7 @@ export class TracingRestClientProcessor {
26
31
  */
27
32
  constructor(options) {
28
33
  this._tracing = ComponentFactory.getIfExists(options?.tracingComponentType);
34
+ this._logging = ComponentFactory.getIfExists(options?.loggingComponentType);
29
35
  this._excludeRouteTemplates = options?.config?.excludePaths ?? [];
30
36
  }
31
37
  /**
@@ -64,7 +70,7 @@ export class TracingRestClientProcessor {
64
70
  };
65
71
  }
66
72
  return response;
67
- });
73
+ }, this._logging);
68
74
  }
69
75
  }
70
76
  //# sourceMappingURL=tracingRestClientProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracingRestClientProcessor.js","sourceRoot":"","sources":["../../src/tracingRestClientProcessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EACN,QAAQ,EACR,iBAAiB,EACjB,aAAa,EAEb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACtC;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,sBAAsB,CAAW;IAElD;;;OAGG;IACH,YAAY,OAAuD;QAClE,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;QAC5E,IAAI,CAAC,sBAAsB,GAAG,OAAO,EAAE,MAAM,EAAE,YAAY,IAAI,EAAE,CAAC;IACnE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,0BAA0B,CAAC,UAAU,CAAC;IAC9C,CAAC;IAED;;;;;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C;IACH,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestClientProcessor, IRestClientProcessorContext } from \"@twin.org/api-models\";\nimport { ComponentFactory, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tSpanKind,\n\tTraceparentHelper,\n\tTracingHelper,\n\ttype ITracingComponent\n} from \"@twin.org/tracing-models\";\nimport { HttpStatusCode } from \"@twin.org/web\";\nimport { HttpSpanAttributes } from \"./models/httpSpanAttributes.js\";\nimport type { ITracingRestClientProcessorConstructorOptions } from \"./models/ITracingRestClientProcessorConstructorOptions.js\";\n\n/**\n * Records a span for each outbound REST request and carries the trace via traceparent header.\n */\nexport class TracingRestClientProcessor implements IRestClientProcessor {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TracingRestClientProcessor>();\n\n\t/**\n\t * The component recording the spans.\n\t * @internal\n\t */\n\tprivate readonly _tracing?: ITracingComponent;\n\n\t/**\n\t * Route templates to skip tracing.\n\t * @internal\n\t */\n\tprivate readonly _excludeRouteTemplates: string[];\n\n\t/**\n\t * Create a new instance of TracingRestClientProcessor.\n\t * @param options Options for the processor.\n\t */\n\tconstructor(options?: ITracingRestClientProcessorConstructorOptions) {\n\t\tthis._tracing = ComponentFactory.getIfExists(options?.tracingComponentType);\n\t\tthis._excludeRouteTemplates = options?.config?.excludePaths ?? [];\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn TracingRestClientProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Wrap the request in a client span, sending the current span as the traceparent so the\n\t * receiving service continues this trace.\n\t * @param context The details of the request being made.\n\t * @param next Performs the request.\n\t * @returns The response.\n\t */\n\tpublic async pre(\n\t\tcontext: IRestClientProcessorContext,\n\t\tnext: () => Promise<Response>\n\t): Promise<Response> {\n\t\tif (Is.empty(this._tracing) || this._excludeRouteTemplates.includes(context.routeTemplate)) {\n\t\t\treturn next();\n\t\t}\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracing,\n\t\t\t`${context.restClientClassName}${context.route.startsWith(\"/\") ? \"\" : \"/\"}${context.route}`,\n\t\t\t{\n\t\t\t\tkind: SpanKind.Client,\n\t\t\t\tattributes: {\n\t\t\t\t\t[HttpSpanAttributes.HttpMethod]: context.method,\n\t\t\t\t\t[HttpSpanAttributes.HttpRoute]: context.route\n\t\t\t\t}\n\t\t\t},\n\t\t\tasync span => {\n\t\t\t\tif (!Is.empty(span)) {\n\t\t\t\t\tcontext.headers[TraceparentHelper.HEADER_NAME] = TraceparentHelper.format(span.context);\n\t\t\t\t}\n\n\t\t\t\tconst response = await next();\n\n\t\t\t\tif (!Is.empty(span)) {\n\t\t\t\t\tspan.attributes = {\n\t\t\t\t\t\t...span.attributes,\n\t\t\t\t\t\t[HttpSpanAttributes.HttpStatusCode]: response.status ?? HttpStatusCode.ok\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t}\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"tracingRestClientProcessor.js","sourceRoot":"","sources":["../../src/tracingRestClientProcessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EACN,QAAQ,EACR,iBAAiB,EACjB,aAAa,EAEb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACtC;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,sBAAsB,CAAW;IAElD;;;O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AAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzF,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAC;YAE9B,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,IAAI,CAAC,UAAU,GAAG;oBACjB,GAAG,IAAI,CAAC,UAAU;oBAClB,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,IAAI,cAAc,CAAC,EAAE;iBACzE,CAAC;YACH,CAAC;YAED,OAAO,QAAQ,CAAC;QACjB,CAAC,EACD,IAAI,CAAC,QAAQ,CACb,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestClientProcessor, IRestClientProcessorContext } from \"@twin.org/api-models\";\nimport { ComponentFactory, Is } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tSpanKind,\n\tTraceparentHelper,\n\tTracingHelper,\n\ttype ITracingComponent\n} from \"@twin.org/tracing-models\";\nimport { HttpStatusCode } from \"@twin.org/web\";\nimport { HttpSpanAttributes } from \"./models/httpSpanAttributes.js\";\nimport type { ITracingRestClientProcessorConstructorOptions } from \"./models/ITracingRestClientProcessorConstructorOptions.js\";\n\n/**\n * Records a span for each outbound REST request and carries the trace via traceparent header.\n */\nexport class TracingRestClientProcessor implements IRestClientProcessor {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TracingRestClientProcessor>();\n\n\t/**\n\t * The component recording the spans.\n\t * @internal\n\t */\n\tprivate readonly _tracing?: ITracingComponent;\n\n\t/**\n\t * The component for logging a tracing failure.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Route templates to skip tracing.\n\t * @internal\n\t */\n\tprivate readonly _excludeRouteTemplates: string[];\n\n\t/**\n\t * Create a new instance of TracingRestClientProcessor.\n\t * @param options Options for the processor.\n\t */\n\tconstructor(options?: ITracingRestClientProcessorConstructorOptions) {\n\t\tthis._tracing = ComponentFactory.getIfExists(options?.tracingComponentType);\n\t\tthis._logging = ComponentFactory.getIfExists(options?.loggingComponentType);\n\t\tthis._excludeRouteTemplates = options?.config?.excludePaths ?? [];\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn TracingRestClientProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Wrap the request in a client span, sending the current span as the traceparent so the\n\t * receiving service continues this trace.\n\t * @param context The details of the request being made.\n\t * @param next Performs the request.\n\t * @returns The response.\n\t */\n\tpublic async pre(\n\t\tcontext: IRestClientProcessorContext,\n\t\tnext: () => Promise<Response>\n\t): Promise<Response> {\n\t\tif (Is.empty(this._tracing) || this._excludeRouteTemplates.includes(context.routeTemplate)) {\n\t\t\treturn next();\n\t\t}\n\n\t\treturn TracingHelper.withSpan(\n\t\t\tthis._tracing,\n\t\t\t`${context.restClientClassName}${context.route.startsWith(\"/\") ? \"\" : \"/\"}${context.route}`,\n\t\t\t{\n\t\t\t\tkind: SpanKind.Client,\n\t\t\t\tattributes: {\n\t\t\t\t\t[HttpSpanAttributes.HttpMethod]: context.method,\n\t\t\t\t\t[HttpSpanAttributes.HttpRoute]: context.route\n\t\t\t\t}\n\t\t\t},\n\t\t\tasync span => {\n\t\t\t\tif (!Is.empty(span)) {\n\t\t\t\t\tcontext.headers[TraceparentHelper.HEADER_NAME] = TraceparentHelper.format(span.context);\n\t\t\t\t}\n\n\t\t\t\tconst response = await next();\n\n\t\t\t\tif (!Is.empty(span)) {\n\t\t\t\t\tspan.attributes = {\n\t\t\t\t\t\t...span.attributes,\n\t\t\t\t\t\t[HttpSpanAttributes.HttpStatusCode]: response.status ?? HttpStatusCode.ok\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t},\n\t\t\tthis._logging\n\t\t);\n\t}\n}\n"]}
@@ -8,6 +8,10 @@ export interface ITracingRestClientProcessorConstructorOptions {
8
8
  * sent.
9
9
  */
10
10
  tracingComponentType?: string;
11
+ /**
12
+ * The type for the logging component, used to report a tracing failure.
13
+ */
14
+ loggingComponentType?: string;
11
15
  /**
12
16
  * Configuration for the processor.
13
17
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.3-next.3](https://github.com/iotaledger/twin-tracing/compare/tracing-processors-v0.9.3-next.2...tracing-processors-v0.9.3-next.3) (2026-09-08)
4
+
5
+
6
+ ### Features
7
+
8
+ * tracing facade ([#43](https://github.com/iotaledger/twin-tracing/issues/43)) ([83f23ef](https://github.com/iotaledger/twin-tracing/commit/83f23eff032cc8be235ebfb33c5582bfa1c95ddf))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/tracing-models bumped from 0.9.3-next.2 to 0.9.3-next.3
16
+
17
+ ## [0.9.3-next.2](https://github.com/iotaledger/twin-tracing/compare/tracing-processors-v0.9.3-next.1...tracing-processors-v0.9.3-next.2) (2026-09-02)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **tracing-processors:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/tracing-models bumped from 0.9.3-next.1 to 0.9.3-next.2
30
+
3
31
  ## [0.9.3-next.1](https://github.com/iotaledger/twin-tracing/compare/tracing-processors-v0.9.3-next.0...tracing-processors-v0.9.3-next.1) (2026-08-26)
4
32
 
5
33
 
@@ -13,6 +13,14 @@ sent.
13
13
 
14
14
  ***
15
15
 
16
+ ### loggingComponentType? {#loggingcomponenttype}
17
+
18
+ > `optional` **loggingComponentType?**: `string`
19
+
20
+ The type for the logging component, used to report a tracing failure.
21
+
22
+ ***
23
+
16
24
  ### config? {#config}
17
25
 
18
26
  > `optional` **config?**: [`ITracingRestClientProcessorConfig`](ITracingRestClientProcessorConfig.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/tracing-processors",
3
- "version": "0.9.3-next.1",
3
+ "version": "0.9.3-next.3",
4
4
  "description": "Processors which record spans for inbound and outbound REST requests.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/logging-models": "next",
21
21
  "@twin.org/nameof": "next",
22
- "@twin.org/tracing-models": "0.9.3-next.1",
22
+ "@twin.org/tracing-models": "0.9.3-next.3",
23
23
  "@twin.org/web": "next"
24
24
  },
25
25
  "main": "./dist/es/index.js",