@interfere/test-utils 10.1.0-rc.1 → 10.1.0-rc.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @interfere/test-utils
2
2
 
3
+ ## 10.1.0-rc.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 7c8441a: `exportedSpans()` and `exceptions()` keep each span's `links` (trace and span ids).
8
+
3
9
  ## 10.1.0-rc.1
4
10
 
5
11
  ### Patch Changes
@@ -33,6 +33,10 @@ export declare function exportedSpans(requests: ReceivedRequest[]): {
33
33
  };
34
34
  }[];
35
35
  }[];
36
+ links: {
37
+ traceId: string;
38
+ spanId: string;
39
+ }[];
36
40
  status?: {
37
41
  code?: number | undefined;
38
42
  } | undefined;
@@ -70,6 +74,10 @@ export declare function exceptions(requests: ReceivedRequest[], message: string)
70
74
  };
71
75
  }[];
72
76
  }[];
77
+ links: {
78
+ traceId: string;
79
+ spanId: string;
80
+ }[];
73
81
  status?: {
74
82
  code?: number | undefined;
75
83
  } | undefined;
@@ -1 +1 @@
1
- import{z}from"zod";const attributes=z.array(z.object({key:z.string(),value:z.object({stringValue:z.string().optional(),boolValue:z.boolean().optional(),intValue:z.union([z.string(),z.number()]).optional()})})),span=z.object({name:z.string(),traceId:z.string(),spanId:z.string(),parentSpanId:z.string().optional(),attributes:attributes.default([]),events:z.array(z.object({name:z.string(),attributes:attributes.default([])})).default([]),status:z.object({code:z.number().optional()}).optional()}),traces=z.object({resourceSpans:z.array(z.object({resource:z.object({attributes}),scopeSpans:z.array(z.object({spans:z.array(span)}))}))});function exportedSpans(requests){return requests.filter(request=>request.url.startsWith(`/drain/v1/traces`)&&request.status<300).flatMap(request=>traces.parse(JSON.parse(request.body)).resourceSpans.flatMap(resource=>resource.scopeSpans.flatMap(scope=>scope.spans.map(item=>({...item,resource:resource.resource.attributes})))))}function attribute(values,key){let value=values.find(item=>item.key===key)?.value;return value?.stringValue??value?.boolValue??value?.intValue}function exceptions(requests,message){return exportedSpans(requests).filter(item=>item.events.some(event=>event.name===`exception`&&attribute(event.attributes,`exception.message`)===message))}const logs=z.object({resourceLogs:z.array(z.object({resource:z.object({attributes}),scopeLogs:z.array(z.object({logRecords:z.array(z.object({eventName:z.string().optional(),attributes:attributes.default([]),traceId:z.string().optional(),spanId:z.string().optional()}))}))}))});function exportedLogRecords(requests){return requests.filter(request=>request.url.startsWith(`/drain/v1/logs`)&&request.status<300).flatMap(request=>logs.parse(JSON.parse(request.body)).resourceLogs.flatMap(resource=>resource.scopeLogs.flatMap(scope=>scope.logRecords.map(item=>({...item,resource:resource.resource.attributes})))))}export{attribute,exceptions,exportedLogRecords,exportedSpans};
1
+ import{z}from"zod";const attributes=z.array(z.object({key:z.string(),value:z.object({stringValue:z.string().optional(),boolValue:z.boolean().optional(),intValue:z.union([z.string(),z.number()]).optional()})})),span=z.object({name:z.string(),traceId:z.string(),spanId:z.string(),parentSpanId:z.string().optional(),attributes:attributes.default([]),events:z.array(z.object({name:z.string(),attributes:attributes.default([])})).default([]),links:z.array(z.object({traceId:z.string(),spanId:z.string()})).default([]),status:z.object({code:z.number().optional()}).optional()}),traces=z.object({resourceSpans:z.array(z.object({resource:z.object({attributes}),scopeSpans:z.array(z.object({spans:z.array(span)}))}))});function exportedSpans(requests){return requests.filter(request=>request.url.startsWith(`/drain/v1/traces`)&&request.status<300).flatMap(request=>traces.parse(JSON.parse(request.body)).resourceSpans.flatMap(resource=>resource.scopeSpans.flatMap(scope=>scope.spans.map(item=>({...item,resource:resource.resource.attributes})))))}function attribute(values,key){let value=values.find(item=>item.key===key)?.value;return value?.stringValue??value?.boolValue??value?.intValue}function exceptions(requests,message){return exportedSpans(requests).filter(item=>item.events.some(event=>event.name===`exception`&&attribute(event.attributes,`exception.message`)===message))}const logs=z.object({resourceLogs:z.array(z.object({resource:z.object({attributes}),scopeLogs:z.array(z.object({logRecords:z.array(z.object({eventName:z.string().optional(),attributes:attributes.default([]),traceId:z.string().optional(),spanId:z.string().optional()}))}))}))});function exportedLogRecords(requests){return requests.filter(request=>request.url.startsWith(`/drain/v1/logs`)&&request.status<300).flatMap(request=>logs.parse(JSON.parse(request.body)).resourceLogs.flatMap(resource=>resource.scopeLogs.flatMap(scope=>scope.logRecords.map(item=>({...item,resource:resource.resource.attributes})))))}export{attribute,exceptions,exportedLogRecords,exportedSpans};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interfere/test-utils",
3
- "version": "10.1.0-rc.1",
3
+ "version": "10.1.0-rc.2",
4
4
  "description": "Shared test utilities used across Interfere packages.",
5
5
  "homepage": "https://interfere.com",
6
6
  "bugs": "mailto:support@interfere.com",