@twin.org/tracing-service 0.9.2-next.1

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.
Files changed (32) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/es/index.js +7 -0
  4. package/dist/es/index.js.map +1 -0
  5. package/dist/es/models/ITracingServiceConstructorOptions.js +4 -0
  6. package/dist/es/models/ITracingServiceConstructorOptions.js.map +1 -0
  7. package/dist/es/restEntryPoints.js +13 -0
  8. package/dist/es/restEntryPoints.js.map +1 -0
  9. package/dist/es/tracingRoutes.js +298 -0
  10. package/dist/es/tracingRoutes.js.map +1 -0
  11. package/dist/es/tracingService.js +147 -0
  12. package/dist/es/tracingService.js.map +1 -0
  13. package/dist/types/index.d.ts +4 -0
  14. package/dist/types/models/ITracingServiceConstructorOptions.d.ts +10 -0
  15. package/dist/types/restEntryPoints.d.ts +5 -0
  16. package/dist/types/tracingRoutes.d.ts +45 -0
  17. package/dist/types/tracingService.d.ts +72 -0
  18. package/docs/changelog.md +25 -0
  19. package/docs/examples.md +37 -0
  20. package/docs/open-api/spec.json +847 -0
  21. package/docs/reference/classes/TracingService.md +224 -0
  22. package/docs/reference/functions/generateRestRoutesTracing.md +25 -0
  23. package/docs/reference/functions/tracingGetTrace.md +31 -0
  24. package/docs/reference/functions/tracingList.md +31 -0
  25. package/docs/reference/functions/tracingSpanEnd.md +31 -0
  26. package/docs/reference/functions/tracingSpanStart.md +31 -0
  27. package/docs/reference/index.md +22 -0
  28. package/docs/reference/interfaces/ITracingServiceConstructorOptions.md +17 -0
  29. package/docs/reference/variables/restEntryPoints.md +5 -0
  30. package/docs/reference/variables/tagsTracing.md +5 -0
  31. package/locales/en.json +7 -0
  32. package/package.json +55 -0
@@ -0,0 +1,224 @@
1
+ # Class: TracingService
2
+
3
+ Service for performing tracing operations to a connector.
4
+
5
+ ## Implements
6
+
7
+ - `ITracingComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new TracingService**(`options?`): `TracingService`
14
+
15
+ Create a new instance of TracingService.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`ITracingServiceConstructorOptions`](../interfaces/ITracingServiceConstructorOptions.md)
22
+
23
+ The options for the connector.
24
+
25
+ #### Returns
26
+
27
+ `TracingService`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ***
38
+
39
+ ### MAX\_GET\_TRACE\_PAGES {#max_get_trace_pages}
40
+
41
+ > `readonly` `static` **MAX\_GET\_TRACE\_PAGES**: `number` = `1000`
42
+
43
+ The maximum number of pages `getTrace` will request before stopping. A safety bound that
44
+ prevents an unexpectedly large trace or a non-terminating connector cursor from looping
45
+ unbounded; with the default page size this still covers very large traces.
46
+
47
+ ## Methods
48
+
49
+ ### className() {#classname}
50
+
51
+ > **className**(): `string`
52
+
53
+ Returns the class name of the component.
54
+
55
+ #### Returns
56
+
57
+ `string`
58
+
59
+ The class name of the component.
60
+
61
+ #### Implementation of
62
+
63
+ `ITracingComponent.className`
64
+
65
+ ***
66
+
67
+ ### startSpan() {#startspan}
68
+
69
+ > **startSpan**(`name`, `options?`): `Promise`\<`ISpan`\>
70
+
71
+ Start a new span.
72
+
73
+ #### Parameters
74
+
75
+ ##### name
76
+
77
+ `string`
78
+
79
+ The name of the span.
80
+
81
+ ##### options?
82
+
83
+ `ISpanOptions`
84
+
85
+ The options for the span.
86
+
87
+ #### Returns
88
+
89
+ `Promise`\<`ISpan`\>
90
+
91
+ The started span, including its minted context.
92
+
93
+ #### Implementation of
94
+
95
+ `ITracingComponent.startSpan`
96
+
97
+ ***
98
+
99
+ ### endSpan() {#endspan}
100
+
101
+ > **endSpan**(`span`, `status?`): `Promise`\<`void`\>
102
+
103
+ End a span, finalizing its status and duration.
104
+
105
+ #### Parameters
106
+
107
+ ##### span
108
+
109
+ `ISpan`
110
+
111
+ The span to end.
112
+
113
+ ##### status?
114
+
115
+ `SpanStatus`
116
+
117
+ The status to set on the span, defaults to ok.
118
+
119
+ #### Returns
120
+
121
+ `Promise`\<`void`\>
122
+
123
+ A promise that resolves when the span has been ended.
124
+
125
+ #### Implementation of
126
+
127
+ `ITracingComponent.endSpan`
128
+
129
+ ***
130
+
131
+ ### query() {#query}
132
+
133
+ > **query**(`traceId?`, `spanId?`, `status?`, `kind?`, `timeStart?`, `timeEnd?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `ISpan`[]; `cursor?`: `string`; \}\>
134
+
135
+ Query the spans.
136
+
137
+ #### Parameters
138
+
139
+ ##### traceId?
140
+
141
+ `string`
142
+
143
+ The id of the trace to filter by.
144
+
145
+ ##### spanId?
146
+
147
+ `string`
148
+
149
+ The id of the span to filter by.
150
+
151
+ ##### status?
152
+
153
+ `SpanStatus`
154
+
155
+ The status to filter by.
156
+
157
+ ##### kind?
158
+
159
+ `SpanKind`
160
+
161
+ The kind to filter by.
162
+
163
+ ##### timeStart?
164
+
165
+ `number`
166
+
167
+ The inclusive start time to filter the span start by, as a timestamp in ms.
168
+
169
+ ##### timeEnd?
170
+
171
+ `number`
172
+
173
+ The inclusive end time to filter the span start by, as a timestamp in ms.
174
+
175
+ ##### cursor?
176
+
177
+ `string`
178
+
179
+ The cursor to request the next chunk of entities.
180
+
181
+ ##### limit?
182
+
183
+ `number`
184
+
185
+ Limit the number of entities to return.
186
+
187
+ #### Returns
188
+
189
+ `Promise`\<\{ `entities`: `ISpan`[]; `cursor?`: `string`; \}\>
190
+
191
+ All the entities for the storage matching the conditions,
192
+ and a cursor which can be used to request more entities.
193
+
194
+ #### Implementation of
195
+
196
+ `ITracingComponent.query`
197
+
198
+ ***
199
+
200
+ ### getTrace() {#gettrace}
201
+
202
+ > **getTrace**(`traceId`): `Promise`\<`ISpan`[]\>
203
+
204
+ Get all the spans belonging to a trace, ordered by their start time. The whole trace is paged
205
+ into memory; paging is bounded by [TracingService.MAX\_GET\_TRACE\_PAGES](#max_get_trace_pages) as a safeguard
206
+ against a pathologically large trace or a non-terminating cursor.
207
+
208
+ #### Parameters
209
+
210
+ ##### traceId
211
+
212
+ `string`
213
+
214
+ The id of the trace to retrieve.
215
+
216
+ #### Returns
217
+
218
+ `Promise`\<`ISpan`[]\>
219
+
220
+ The spans belonging to the trace, ordered by their start time ascending.
221
+
222
+ #### Implementation of
223
+
224
+ `ITracingComponent.getTrace`
@@ -0,0 +1,25 @@
1
+ # Function: generateRestRoutesTracing()
2
+
3
+ > **generateRestRoutesTracing**(`baseRouteName`, `componentName`): `IRestRoute`\<`any`, `any`\>[]
4
+
5
+ The REST routes for tracing.
6
+
7
+ ## Parameters
8
+
9
+ ### baseRouteName
10
+
11
+ `string`
12
+
13
+ Prefix to prepend to the paths.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes stored in the ComponentFactory.
20
+
21
+ ## Returns
22
+
23
+ `IRestRoute`\<`any`, `any`\>[]
24
+
25
+ The generated routes.
@@ -0,0 +1,31 @@
1
+ # Function: tracingGetTrace()
2
+
3
+ > **tracingGetTrace**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ITracingGetTraceResponse`\>
4
+
5
+ Get all the spans belonging to a trace.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `ITracingGetTraceRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`ITracingGetTraceResponse`\>
30
+
31
+ A promise that resolves to the spans belonging to the trace.
@@ -0,0 +1,31 @@
1
+ # Function: tracingList()
2
+
3
+ > **tracingList**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ITracingListResponse`\>
4
+
5
+ Get a list of the spans.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `ITracingListRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`ITracingListResponse`\>
30
+
31
+ A promise that resolves to the matching spans and an optional pagination cursor.
@@ -0,0 +1,31 @@
1
+ # Function: tracingSpanEnd()
2
+
3
+ > **tracingSpanEnd**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ End a span.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `ITracingSpanEndRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`INoContentResponse`\>
30
+
31
+ A promise that resolves to a no-content response when the span has been ended.
@@ -0,0 +1,31 @@
1
+ # Function: tracingSpanStart()
2
+
3
+ > **tracingSpanStart**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ITracingSpanStartResponse`\>
4
+
5
+ Start a new span.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `ITracingSpanStartRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`ITracingSpanStartResponse`\>
30
+
31
+ A promise that resolves to the started span.
@@ -0,0 +1,22 @@
1
+ # @twin.org/tracing-service
2
+
3
+ ## Classes
4
+
5
+ - [TracingService](classes/TracingService.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [ITracingServiceConstructorOptions](interfaces/ITracingServiceConstructorOptions.md)
10
+
11
+ ## Variables
12
+
13
+ - [restEntryPoints](variables/restEntryPoints.md)
14
+ - [tagsTracing](variables/tagsTracing.md)
15
+
16
+ ## Functions
17
+
18
+ - [generateRestRoutesTracing](functions/generateRestRoutesTracing.md)
19
+ - [tracingSpanStart](functions/tracingSpanStart.md)
20
+ - [tracingSpanEnd](functions/tracingSpanEnd.md)
21
+ - [tracingList](functions/tracingList.md)
22
+ - [tracingGetTrace](functions/tracingGetTrace.md)
@@ -0,0 +1,17 @@
1
+ # Interface: ITracingServiceConstructorOptions
2
+
3
+ Options for the tracing service constructor.
4
+
5
+ ## Properties
6
+
7
+ ### tracingConnectorType? {#tracingconnectortype}
8
+
9
+ > `optional` **tracingConnectorType?**: `string`
10
+
11
+ The type of the tracing connector to use.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ tracing
17
+ ```
@@ -0,0 +1,5 @@
1
+ # Variable: restEntryPoints
2
+
3
+ > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
4
+
5
+ REST entry points for the tracing service.
@@ -0,0 +1,5 @@
1
+ # Variable: tagsTracing
2
+
3
+ > `const` **tagsTracing**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
@@ -0,0 +1,7 @@
1
+ {
2
+ "error": {
3
+ "tracingRoutes": {
4
+ "spanIdMismatch": "The span id in the path \"{pathSpanId}\" does not match the span id in the body \"{bodySpanId}\""
5
+ }
6
+ }
7
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@twin.org/tracing-service",
3
+ "version": "0.9.2-next.1",
4
+ "description": "Exposes tracing operations through service routes and API contracts for server-side integration.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/iotaledger/twin-tracing.git",
8
+ "directory": "packages/tracing-service"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@twin.org/api-models": "next",
18
+ "@twin.org/core": "next",
19
+ "@twin.org/entity": "next",
20
+ "@twin.org/nameof": "next",
21
+ "@twin.org/tracing-models": "0.9.2-next.1",
22
+ "@twin.org/web": "next"
23
+ },
24
+ "main": "./dist/es/index.js",
25
+ "types": "./dist/types/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/types/index.d.ts",
29
+ "import": "./dist/es/index.js",
30
+ "default": "./dist/es/index.js"
31
+ },
32
+ "./locales/*.json": "./locales/*.json"
33
+ },
34
+ "files": [
35
+ "dist/es",
36
+ "dist/types",
37
+ "locales",
38
+ "docs"
39
+ ],
40
+ "keywords": [
41
+ "twin",
42
+ "trade",
43
+ "iota",
44
+ "framework",
45
+ "blockchain",
46
+ "tracing",
47
+ "service",
48
+ "microservice",
49
+ "business-logic"
50
+ ],
51
+ "bugs": {
52
+ "url": "git+https://github.com/iotaledger/twin-tracing/issues"
53
+ },
54
+ "homepage": "https://twindev.org"
55
+ }