@downtrace/protocol 0.3.0 → 0.5.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/README.md +4 -2
- package/dist/index.d.ts +17 -7
- package/dist/index.js +20 -7
- package/package.json +1 -1
- package/schema/v0/aggregates.schema.json +6 -1
- package/schema/v0/fixtures/valid/pool-wait.json +84 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The ingestion contract between Downtrace agents and the Downtrace cloud, as a JS
|
|
|
4
4
|
|
|
5
5
|
- `schema/v0/aggregates.schema.json` — the contract. Everything else derives from it.
|
|
6
6
|
- `schema/v0/fixtures/{valid,invalid}/` — examples every implementation must accept and reject.
|
|
7
|
-
- Exports: `PROTOCOL_VERSION`, `AGGREGATES_PATH`, `AGGREGATES_SCHEMA_V0`, `LATENCY_BOUNDARIES_V0`, `LATENCY_BUCKETS_V0`, `latencyBucket()`, `CALLS_PER_REQUEST_BOUNDARIES_V0`, `CALLS_PER_REQUEST_BUCKETS_V0`, `callsPerRequestBucket()`, and the types `AggregatesBatch`, `Interval`, `Endpoint`, `LatencyHistogram`, `Dependency`, `PostgresStats`, …
|
|
7
|
+
- Exports: `PROTOCOL_VERSION`, `ACCEPTED_PROTOCOL_VERSIONS_V0`, `AGGREGATES_PATH`, `AGGREGATES_SCHEMA_V0`, `LATENCY_BOUNDARIES_V0`, `LATENCY_BUCKETS_V0`, `latencyBucket()`, `CALLS_PER_REQUEST_BOUNDARIES_V0`, `CALLS_PER_REQUEST_BUCKETS_V0`, `callsPerRequestBucket()`, and the types `AggregatesBatch`, `Interval`, `Endpoint`, `LatencyHistogram`, `Dependency`, `PostgresStats`, …
|
|
8
8
|
|
|
9
9
|
## v0 in one sentence
|
|
10
10
|
|
|
@@ -16,7 +16,9 @@ Since **0.2.0** an endpoint may also carry `postgres`: how many queries each req
|
|
|
16
16
|
|
|
17
17
|
## How the protocol changes
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**The package version is the protocol version.** `@downtrace/protocol@0.5.0` speaks protocol `0.5.0`, and CI refuses to publish a release where the two disagree, so you can read the contract off the version in your lockfile. A release that changes the package without touching the contract moves the patch segment only.
|
|
20
|
+
|
|
21
|
+
Fields are only ever **added**, and always optional. Each addition bumps the minor version, and the batch's `protocol` field is an enum of every published minor, so a cloud that speaks 0.2 still accepts an agent that speaks 0.1. Removing or renaming a field, or moving a histogram's bucket bounds, would be a major version on a new path. Bucket bounds are declared in the schema itself (`x-latency-boundaries-ms`, `x-calls-per-request-boundaries`), and so are the versions themselves, so they are part of the generated contract rather than a constant someone has to keep in sync.
|
|
20
22
|
|
|
21
23
|
## Source
|
|
22
24
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ interface AggregatesBatch {
|
|
|
6
6
|
/**
|
|
7
7
|
* Protocol version this batch conforms to. Every published minor of v0 stays acceptable.
|
|
8
8
|
*/
|
|
9
|
-
protocol: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0";
|
|
9
|
+
protocol: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0" | "0.5.0";
|
|
10
10
|
agent: AgentInfo;
|
|
11
11
|
instance: InstanceInfo;
|
|
12
12
|
deploy: DeployInfo;
|
|
@@ -157,6 +157,10 @@ interface Dependency {
|
|
|
157
157
|
* Calls that failed.
|
|
158
158
|
*/
|
|
159
159
|
errors: number;
|
|
160
|
+
/**
|
|
161
|
+
* Time requests spent waiting to be able to talk to this dependency, on top of the time spent talking to it: a saturated connection pool shows up here and nowhere else. Optional; agents that cannot see it omit it.
|
|
162
|
+
*/
|
|
163
|
+
waitMs?: number;
|
|
160
164
|
}
|
|
161
165
|
/**
|
|
162
166
|
* Health of the agent's own process during the interval. Optional: an agent that does not measure it omits it. Per interval, not per route, because it belongs to the process.
|
|
@@ -211,12 +215,13 @@ declare const CALLS_PER_REQUEST_BOUNDARIES_V0: readonly number[];
|
|
|
211
215
|
/** Number of calls-per-request buckets: boundaries + 1 open-ended bucket. */
|
|
212
216
|
declare const CALLS_PER_REQUEST_BUCKETS_V0 = 8;
|
|
213
217
|
//#endregion
|
|
218
|
+
//#region src/generated/versions.d.ts
|
|
219
|
+
/** Every published minor of v0, oldest first. The cloud never stops accepting one it published (ADR 0008). */
|
|
220
|
+
declare const ACCEPTED_PROTOCOL_VERSIONS_V0: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0"];
|
|
221
|
+
/** The newest published minor: what an up-to-date agent stamps on every batch. */
|
|
222
|
+
declare const PROTOCOL_VERSION = "0.5.0";
|
|
223
|
+
//#endregion
|
|
214
224
|
//#region src/index.d.ts
|
|
215
|
-
/**
|
|
216
|
-
* Version of the ingestion protocol this package speaks. Every published minor of v0 stays acceptable to the
|
|
217
|
-
* cloud, so an agent on an older minor keeps working: fields are only ever added, and always optional (ADR 0008).
|
|
218
|
-
*/
|
|
219
|
-
declare const PROTOCOL_VERSION = "0.4.0";
|
|
220
225
|
/** Path, relative to the ingest URL, that receives AggregatesBatch payloads. */
|
|
221
226
|
declare const AGGREGATES_PATH = "/v0/aggregates";
|
|
222
227
|
/** The JSON Schema (draft 2020-12) for AggregatesBatch, for validators on either side. */
|
|
@@ -577,6 +582,11 @@ declare const AGGREGATES_SCHEMA_V0: {
|
|
|
577
582
|
minimum: number;
|
|
578
583
|
description: string;
|
|
579
584
|
};
|
|
585
|
+
waitMs: {
|
|
586
|
+
type: string;
|
|
587
|
+
minimum: number;
|
|
588
|
+
description: string;
|
|
589
|
+
};
|
|
580
590
|
};
|
|
581
591
|
};
|
|
582
592
|
};
|
|
@@ -586,4 +596,4 @@ declare function latencyBucket(ms: number): number;
|
|
|
586
596
|
/** Index of the bucket a call count falls into: first boundary >= count, else the open-ended last bucket. */
|
|
587
597
|
declare function callsPerRequestBucket(calls: number): number;
|
|
588
598
|
//#endregion
|
|
589
|
-
export { AGGREGATES_PATH, AGGREGATES_SCHEMA_V0, type AgentInfo, type AggregatesBatch, CALLS_PER_REQUEST_BOUNDARIES_V0, CALLS_PER_REQUEST_BUCKETS_V0, type Dependency, type DeployInfo, type Endpoint, type InstanceInfo, type Interval, LATENCY_BOUNDARIES_V0, LATENCY_BUCKETS_V0, type LatencyHistogram, PROTOCOL_VERSION, type PostgresStats, type RuntimeHealth, type StatusClasses, callsPerRequestBucket, latencyBucket };
|
|
599
|
+
export { ACCEPTED_PROTOCOL_VERSIONS_V0, AGGREGATES_PATH, AGGREGATES_SCHEMA_V0, type AgentInfo, type AggregatesBatch, CALLS_PER_REQUEST_BOUNDARIES_V0, CALLS_PER_REQUEST_BUCKETS_V0, type Dependency, type DeployInfo, type Endpoint, type InstanceInfo, type Interval, LATENCY_BOUNDARIES_V0, LATENCY_BUCKETS_V0, type LatencyHistogram, PROTOCOL_VERSION, type PostgresStats, type RuntimeHealth, type StatusClasses, callsPerRequestBucket, latencyBucket };
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,8 @@ var aggregates_schema_default = {
|
|
|
20
20
|
"0.1.0",
|
|
21
21
|
"0.2.0",
|
|
22
22
|
"0.3.0",
|
|
23
|
-
"0.4.0"
|
|
23
|
+
"0.4.0",
|
|
24
|
+
"0.5.0"
|
|
24
25
|
],
|
|
25
26
|
"description": "Protocol version this batch conforms to. Every published minor of v0 stays acceptable."
|
|
26
27
|
},
|
|
@@ -450,6 +451,11 @@ var aggregates_schema_default = {
|
|
|
450
451
|
"type": "integer",
|
|
451
452
|
"minimum": 0,
|
|
452
453
|
"description": "Calls that failed."
|
|
454
|
+
},
|
|
455
|
+
"waitMs": {
|
|
456
|
+
"type": "number",
|
|
457
|
+
"minimum": 0,
|
|
458
|
+
"description": "Time requests spent waiting to be able to talk to this dependency, on top of the time spent talking to it: a saturated connection pool shows up here and nowhere else. Optional; agents that cannot see it omit it."
|
|
453
459
|
}
|
|
454
460
|
}
|
|
455
461
|
}
|
|
@@ -509,12 +515,19 @@ const CALLS_PER_REQUEST_BOUNDARIES_V0 = [
|
|
|
509
515
|
/** Number of calls-per-request buckets: boundaries + 1 open-ended bucket. */
|
|
510
516
|
const CALLS_PER_REQUEST_BUCKETS_V0 = 8;
|
|
511
517
|
//#endregion
|
|
518
|
+
//#region src/generated/versions.ts
|
|
519
|
+
/** Every published minor of v0, oldest first. The cloud never stops accepting one it published (ADR 0008). */
|
|
520
|
+
const ACCEPTED_PROTOCOL_VERSIONS_V0 = [
|
|
521
|
+
"0.1.0",
|
|
522
|
+
"0.2.0",
|
|
523
|
+
"0.3.0",
|
|
524
|
+
"0.4.0",
|
|
525
|
+
"0.5.0"
|
|
526
|
+
];
|
|
527
|
+
/** The newest published minor: what an up-to-date agent stamps on every batch. */
|
|
528
|
+
const PROTOCOL_VERSION = "0.5.0";
|
|
529
|
+
//#endregion
|
|
512
530
|
//#region src/index.ts
|
|
513
|
-
/**
|
|
514
|
-
* Version of the ingestion protocol this package speaks. Every published minor of v0 stays acceptable to the
|
|
515
|
-
* cloud, so an agent on an older minor keeps working: fields are only ever added, and always optional (ADR 0008).
|
|
516
|
-
*/
|
|
517
|
-
const PROTOCOL_VERSION = "0.4.0";
|
|
518
531
|
/** Path, relative to the ingest URL, that receives AggregatesBatch payloads. */
|
|
519
532
|
const AGGREGATES_PATH = "/v0/aggregates";
|
|
520
533
|
/** The JSON Schema (draft 2020-12) for AggregatesBatch, for validators on either side. */
|
|
@@ -538,4 +551,4 @@ function callsPerRequestBucket(calls) {
|
|
|
538
551
|
return n;
|
|
539
552
|
}
|
|
540
553
|
//#endregion
|
|
541
|
-
export { AGGREGATES_PATH, AGGREGATES_SCHEMA_V0, CALLS_PER_REQUEST_BOUNDARIES_V0, CALLS_PER_REQUEST_BUCKETS_V0, LATENCY_BOUNDARIES_V0, LATENCY_BUCKETS_V0, PROTOCOL_VERSION, callsPerRequestBucket, latencyBucket };
|
|
554
|
+
export { ACCEPTED_PROTOCOL_VERSIONS_V0, AGGREGATES_PATH, AGGREGATES_SCHEMA_V0, CALLS_PER_REQUEST_BOUNDARIES_V0, CALLS_PER_REQUEST_BUCKETS_V0, LATENCY_BOUNDARIES_V0, LATENCY_BUCKETS_V0, PROTOCOL_VERSION, callsPerRequestBucket, latencyBucket };
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"properties": {
|
|
10
10
|
"protocol": {
|
|
11
11
|
"type": "string",
|
|
12
|
-
"enum": ["0.1.0", "0.2.0", "0.3.0", "0.4.0"],
|
|
12
|
+
"enum": ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0"],
|
|
13
13
|
"description": "Protocol version this batch conforms to. Every published minor of v0 stays acceptable."
|
|
14
14
|
},
|
|
15
15
|
"agent": {
|
|
@@ -357,6 +357,11 @@
|
|
|
357
357
|
"type": "integer",
|
|
358
358
|
"minimum": 0,
|
|
359
359
|
"description": "Calls that failed."
|
|
360
|
+
},
|
|
361
|
+
"waitMs": {
|
|
362
|
+
"type": "number",
|
|
363
|
+
"minimum": 0,
|
|
364
|
+
"description": "Time requests spent waiting to be able to talk to this dependency, on top of the time spent talking to it: a saturated connection pool shows up here and nowhere else. Optional; agents that cannot see it omit it."
|
|
360
365
|
}
|
|
361
366
|
}
|
|
362
367
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "0.5.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": "POST",
|
|
25
|
+
"route": "/checkout",
|
|
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
|
+
"dependencies": [
|
|
42
|
+
{
|
|
43
|
+
"kind": "postgres",
|
|
44
|
+
"target": "",
|
|
45
|
+
"callsPerRequest": [0, 0, 0, 0, 0, 3, 0, 0],
|
|
46
|
+
"totalMs": 41.25,
|
|
47
|
+
"max": 9.5,
|
|
48
|
+
"errors": 0,
|
|
49
|
+
"waitMs": 30.5
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"kind": "http",
|
|
53
|
+
"target": "api.stripe.com",
|
|
54
|
+
"callsPerRequest": [0, 0, 3, 0, 0, 0, 0, 0],
|
|
55
|
+
"totalMs": 612.4,
|
|
56
|
+
"max": 240.1,
|
|
57
|
+
"errors": 1
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"kind": "redis",
|
|
61
|
+
"target": "",
|
|
62
|
+
"callsPerRequest": [0, 0, 0, 3, 0, 0, 0, 0],
|
|
63
|
+
"totalMs": 4.2,
|
|
64
|
+
"max": 1.1,
|
|
65
|
+
"errors": 0
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"runtime": {
|
|
71
|
+
"eventLoopDelayMs": {
|
|
72
|
+
"p50": 0.9,
|
|
73
|
+
"p99": 14.2,
|
|
74
|
+
"max": 61.5
|
|
75
|
+
},
|
|
76
|
+
"gcPauseMs": 22.4,
|
|
77
|
+
"gcCount": 7,
|
|
78
|
+
"heapUsedMb": 48.6,
|
|
79
|
+
"rssMb": 131.2,
|
|
80
|
+
"inFlightMax": 9
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|