@downtrace/protocol 0.1.0

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/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@downtrace/protocol",
3
+ "version": "0.1.0",
4
+ "description": "Downtrace ingestion protocol: JSON Schema, fixtures and generated TypeScript types",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "./schema/v0/aggregates.schema.json": "./schema/v0/aggregates.schema.json"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "schema",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "devDependencies": {
20
+ "ajv": "^8.20.0",
21
+ "json-schema-to-typescript": "^16.0.0"
22
+ },
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/RadW2020/downtrace-agent.git",
27
+ "directory": "packages/protocol"
28
+ },
29
+ "homepage": "https://github.com/RadW2020/downtrace-agent#readme",
30
+ "keywords": [
31
+ "downtrace",
32
+ "observability",
33
+ "protocol",
34
+ "json-schema"
35
+ ],
36
+ "engines": {
37
+ "node": ">=20"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "test": "vitest run",
44
+ "typecheck": "tsc -p tsconfig.json",
45
+ "gen": "node scripts/gen.ts",
46
+ "build": "tsdown"
47
+ },
48
+ "main": "./dist/index.js",
49
+ "types": "./dist/index.d.ts"
50
+ }
@@ -0,0 +1,220 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://downtrace.io/schema/v0/aggregates.schema.json",
4
+ "title": "AggregatesBatch",
5
+ "description": "A batch of per-interval, per-route aggregates sent by an agent to the cloud (POST /v0/aggregates).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["protocol", "agent", "instance", "deploy", "intervals"],
9
+ "properties": {
10
+ "protocol": {
11
+ "type": "string",
12
+ "const": "0.1.0",
13
+ "description": "Protocol version this batch conforms to."
14
+ },
15
+ "agent": {
16
+ "$ref": "#/$defs/AgentInfo"
17
+ },
18
+ "instance": {
19
+ "$ref": "#/$defs/InstanceInfo"
20
+ },
21
+ "deploy": {
22
+ "$ref": "#/$defs/DeployInfo"
23
+ },
24
+ "intervals": {
25
+ "type": "array",
26
+ "minItems": 1,
27
+ "maxItems": 6,
28
+ "items": {
29
+ "$ref": "#/$defs/Interval"
30
+ }
31
+ }
32
+ },
33
+ "$defs": {
34
+ "AgentInfo": {
35
+ "title": "AgentInfo",
36
+ "type": "object",
37
+ "additionalProperties": false,
38
+ "required": ["name", "version", "runtime", "runtimeVersion"],
39
+ "properties": {
40
+ "name": {
41
+ "type": "string",
42
+ "minLength": 1,
43
+ "maxLength": 128
44
+ },
45
+ "version": {
46
+ "type": "string",
47
+ "minLength": 1,
48
+ "maxLength": 64
49
+ },
50
+ "runtime": {
51
+ "enum": ["node", "go"]
52
+ },
53
+ "runtimeVersion": {
54
+ "type": "string",
55
+ "minLength": 1,
56
+ "maxLength": 64
57
+ }
58
+ }
59
+ },
60
+ "InstanceInfo": {
61
+ "title": "InstanceInfo",
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "required": ["id", "hostname", "pid"],
65
+ "properties": {
66
+ "id": {
67
+ "type": "string",
68
+ "minLength": 1,
69
+ "maxLength": 64,
70
+ "description": "Random identifier generated once per process."
71
+ },
72
+ "hostname": {
73
+ "type": "string",
74
+ "minLength": 1,
75
+ "maxLength": 253
76
+ },
77
+ "pid": {
78
+ "type": "integer",
79
+ "minimum": 0
80
+ }
81
+ }
82
+ },
83
+ "DeployInfo": {
84
+ "title": "DeployInfo",
85
+ "type": "object",
86
+ "additionalProperties": false,
87
+ "required": ["version", "environment"],
88
+ "properties": {
89
+ "version": {
90
+ "type": "string",
91
+ "minLength": 1,
92
+ "maxLength": 128,
93
+ "description": "Deployed version or commit; \"unknown\" when undetectable."
94
+ },
95
+ "environment": {
96
+ "type": "string",
97
+ "minLength": 1,
98
+ "maxLength": 64
99
+ }
100
+ }
101
+ },
102
+ "Interval": {
103
+ "title": "Interval",
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "required": ["start", "durationMs", "endpoints"],
107
+ "properties": {
108
+ "start": {
109
+ "type": "integer",
110
+ "minimum": 0,
111
+ "description": "Interval start, Unix epoch milliseconds."
112
+ },
113
+ "durationMs": {
114
+ "type": "integer",
115
+ "minimum": 1,
116
+ "maximum": 3600000
117
+ },
118
+ "endpoints": {
119
+ "type": "array",
120
+ "maxItems": 4096,
121
+ "items": {
122
+ "$ref": "#/$defs/Endpoint"
123
+ }
124
+ }
125
+ }
126
+ },
127
+ "Endpoint": {
128
+ "title": "Endpoint",
129
+ "type": "object",
130
+ "additionalProperties": false,
131
+ "required": ["method", "route", "count", "errors", "status", "latency"],
132
+ "properties": {
133
+ "method": {
134
+ "enum": ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "OTHER"]
135
+ },
136
+ "route": {
137
+ "type": "string",
138
+ "minLength": 1,
139
+ "maxLength": 256,
140
+ "description": "Normalised route template, e.g. /products/:id, or (other)."
141
+ },
142
+ "count": {
143
+ "type": "integer",
144
+ "minimum": 0
145
+ },
146
+ "errors": {
147
+ "type": "integer",
148
+ "minimum": 0,
149
+ "description": "Responses with a 5xx status."
150
+ },
151
+ "status": {
152
+ "$ref": "#/$defs/StatusClasses"
153
+ },
154
+ "latency": {
155
+ "$ref": "#/$defs/LatencyHistogram"
156
+ }
157
+ }
158
+ },
159
+ "StatusClasses": {
160
+ "title": "StatusClasses",
161
+ "type": "object",
162
+ "additionalProperties": false,
163
+ "required": ["success", "redirect", "clientError", "serverError"],
164
+ "properties": {
165
+ "success": {
166
+ "type": "integer",
167
+ "minimum": 0,
168
+ "description": "2xx"
169
+ },
170
+ "redirect": {
171
+ "type": "integer",
172
+ "minimum": 0,
173
+ "description": "3xx"
174
+ },
175
+ "clientError": {
176
+ "type": "integer",
177
+ "minimum": 0,
178
+ "description": "4xx"
179
+ },
180
+ "serverError": {
181
+ "type": "integer",
182
+ "minimum": 0,
183
+ "description": "5xx"
184
+ }
185
+ }
186
+ },
187
+ "LatencyHistogram": {
188
+ "title": "LatencyHistogram",
189
+ "description": "Fixed-bucket latency histogram in milliseconds. counts[i] is the number of requests with latency <= boundaries[i]; the last bucket holds everything above the last boundary. Fixed buckets add up across instances.",
190
+ "type": "object",
191
+ "additionalProperties": false,
192
+ "required": ["counts", "sum", "max"],
193
+ "x-latency-boundaries-ms": [
194
+ 0.5, 1, 1.5, 2, 3, 4, 5, 7.5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200, 300, 400, 500, 750, 1000, 1500, 2000,
195
+ 3000, 4000, 5000, 7500, 10000, 15000, 20000, 30000, 60000
196
+ ],
197
+ "properties": {
198
+ "counts": {
199
+ "type": "array",
200
+ "minItems": 35,
201
+ "maxItems": 35,
202
+ "items": {
203
+ "type": "integer",
204
+ "minimum": 0
205
+ }
206
+ },
207
+ "sum": {
208
+ "type": "number",
209
+ "minimum": 0,
210
+ "description": "Sum of latencies in ms."
211
+ },
212
+ "max": {
213
+ "type": "number",
214
+ "minimum": 0,
215
+ "description": "Maximum latency in ms."
216
+ }
217
+ }
218
+ }
219
+ }
220
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "protocol": "0.1.0",
3
+ "agent": {
4
+ "name": "@downtrace/agent",
5
+ "version": "0.0.0",
6
+ "runtime": "node",
7
+ "runtimeVersion": "v24.0.0"
8
+ },
9
+ "instance": {
10
+ "id": "7d1e9c6a-4f2b-4c1e-9b0a-2f6d3e8a1c55",
11
+ "hostname": "web-1",
12
+ "pid": 4242
13
+ },
14
+ "deploy": {
15
+ "version": "8f71ac2",
16
+ "environment": "production"
17
+ },
18
+ "intervals": [
19
+ {
20
+ "start": 1756900000000,
21
+ "durationMs": 10000,
22
+ "endpoints": [
23
+ {
24
+ "method": "GET",
25
+ "route": "/healthz",
26
+ "count": 3,
27
+ "errors": 0,
28
+ "status": {
29
+ "success": 3,
30
+ "redirect": 0,
31
+ "clientError": 0,
32
+ "serverError": 0
33
+ },
34
+ "latency": {
35
+ "counts": [
36
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
37
+ ],
38
+ "sum": 2.4,
39
+ "max": 0.9
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "protocol": "0.1.0",
3
+ "agent": {
4
+ "name": "@downtrace/agent",
5
+ "version": "0.0.0",
6
+ "runtime": "node",
7
+ "runtimeVersion": "v24.0.0"
8
+ },
9
+ "instance": {
10
+ "id": "7d1e9c6a-4f2b-4c1e-9b0a-2f6d3e8a1c55",
11
+ "hostname": "web-1",
12
+ "pid": 4242
13
+ },
14
+ "deploy": {
15
+ "version": "8f71ac2",
16
+ "environment": "production"
17
+ },
18
+ "intervals": [
19
+ {
20
+ "start": 1756900000000,
21
+ "durationMs": 10000,
22
+ "endpoints": [
23
+ {
24
+ "method": "GET",
25
+ "route": "/healthz",
26
+ "count": -1,
27
+ "errors": 0,
28
+ "status": {
29
+ "success": 3,
30
+ "redirect": 0,
31
+ "clientError": 0,
32
+ "serverError": 0
33
+ },
34
+ "latency": {
35
+ "counts": [
36
+ 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
37
+ ],
38
+ "sum": 2.4,
39
+ "max": 0.9
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "protocol": "9.9.9",
3
+ "agent": {
4
+ "name": "@downtrace/agent",
5
+ "version": "0.0.0",
6
+ "runtime": "node",
7
+ "runtimeVersion": "v24.0.0"
8
+ },
9
+ "instance": {
10
+ "id": "7d1e9c6a-4f2b-4c1e-9b0a-2f6d3e8a1c55",
11
+ "hostname": "web-1",
12
+ "pid": 4242
13
+ },
14
+ "deploy": {
15
+ "version": "8f71ac2",
16
+ "environment": "production"
17
+ },
18
+ "intervals": [
19
+ {
20
+ "start": 1756900000000,
21
+ "durationMs": 10000,
22
+ "endpoints": [
23
+ {
24
+ "method": "GET",
25
+ "route": "/healthz",
26
+ "count": 3,
27
+ "errors": 0,
28
+ "status": {
29
+ "success": 3,
30
+ "redirect": 0,
31
+ "clientError": 0,
32
+ "serverError": 0
33
+ },
34
+ "latency": {
35
+ "counts": [
36
+ 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
37
+ ],
38
+ "sum": 2.4,
39
+ "max": 0.9
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "protocol": "0.1.0",
3
+ "agent": {
4
+ "name": "@downtrace/agent",
5
+ "version": "0.0.0",
6
+ "runtime": "node",
7
+ "runtimeVersion": "v24.0.0"
8
+ },
9
+ "instance": {
10
+ "id": "7d1e9c6a-4f2b-4c1e-9b0a-2f6d3e8a1c55",
11
+ "hostname": "web-1",
12
+ "pid": 4242
13
+ },
14
+ "deploy": {
15
+ "version": "8f71ac2",
16
+ "environment": "production"
17
+ },
18
+ "intervals": [
19
+ {
20
+ "start": 1756900000000,
21
+ "durationMs": 10000,
22
+ "endpoints": [
23
+ {
24
+ "method": "GET",
25
+ "route": "/healthz",
26
+ "count": 3,
27
+ "errors": 0,
28
+ "status": {
29
+ "success": 3,
30
+ "redirect": 0,
31
+ "clientError": 0,
32
+ "serverError": 0
33
+ },
34
+ "latency": {
35
+ "counts": [
36
+ 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
37
+ ],
38
+ "sum": 2.4,
39
+ "max": 0.9
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,102 @@
1
+ {
2
+ "protocol": "0.1.0",
3
+ "agent": {
4
+ "name": "@downtrace/agent",
5
+ "version": "0.0.0",
6
+ "runtime": "node",
7
+ "runtimeVersion": "v24.0.0"
8
+ },
9
+ "instance": {
10
+ "id": "7d1e9c6a-4f2b-4c1e-9b0a-2f6d3e8a1c55",
11
+ "hostname": "web-1",
12
+ "pid": 4242
13
+ },
14
+ "deploy": {
15
+ "version": "8f71ac2",
16
+ "environment": "production"
17
+ },
18
+ "intervals": [
19
+ {
20
+ "start": 1756900010000,
21
+ "durationMs": 10000,
22
+ "endpoints": [
23
+ {
24
+ "method": "GET",
25
+ "route": "/products",
26
+ "count": 40,
27
+ "errors": 0,
28
+ "status": {
29
+ "success": 40,
30
+ "redirect": 0,
31
+ "clientError": 0,
32
+ "serverError": 0
33
+ },
34
+ "latency": {
35
+ "counts": [
36
+ 0, 0, 0, 10, 20, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
37
+ ],
38
+ "sum": 130.0,
39
+ "max": 4.8
40
+ }
41
+ },
42
+ {
43
+ "method": "GET",
44
+ "route": "/products/:id",
45
+ "count": 30,
46
+ "errors": 0,
47
+ "status": {
48
+ "success": 28,
49
+ "redirect": 0,
50
+ "clientError": 2,
51
+ "serverError": 0
52
+ },
53
+ "latency": {
54
+ "counts": [
55
+ 0, 0, 10, 15, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
56
+ ],
57
+ "sum": 90.5,
58
+ "max": 6.2
59
+ }
60
+ },
61
+ {
62
+ "method": "POST",
63
+ "route": "/checkout",
64
+ "count": 12,
65
+ "errors": 2,
66
+ "status": {
67
+ "success": 10,
68
+ "redirect": 0,
69
+ "clientError": 0,
70
+ "serverError": 2
71
+ },
72
+ "latency": {
73
+ "counts": [
74
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2
75
+ ],
76
+ "sum": 130450.0,
77
+ "max": 61200.0
78
+ }
79
+ },
80
+ {
81
+ "method": "GET",
82
+ "route": "(other)",
83
+ "count": 5,
84
+ "errors": 0,
85
+ "status": {
86
+ "success": 0,
87
+ "redirect": 0,
88
+ "clientError": 5,
89
+ "serverError": 0
90
+ },
91
+ "latency": {
92
+ "counts": [
93
+ 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
94
+ ],
95
+ "sum": 1.1,
96
+ "max": 0.3
97
+ }
98
+ }
99
+ ]
100
+ }
101
+ ]
102
+ }