@downtrace/protocol 0.10.0 → 0.12.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 CHANGED
@@ -62,6 +62,10 @@ And still protocol **0.9.0**, an operation may be an **outgoing HTTP call** or a
62
62
 
63
63
  And since **0.10.0** a dependency may be of kind **`mongodb`**: a MongoDB database, one dependency with an empty `target` whatever the members of its replica set, as Postgres reached through postgres.js is. Its commands are operations of kind `query`, labelled by two words, the command's name and the collection it names — `find users`, `insert orders`, `aggregate events` — and never the filter, the documents, the pipeline or the update; a collection whose name looks like a value is `?`.
64
64
 
65
+ And since **0.11.0** a dependency may be of kind **`sqlite`**: a SQLite database the process opens itself, through `better-sqlite3`, `libsql` or `@libsql/client` on a file, one dependency with an empty `target` whatever file it is, as MongoDB is. Its statements are operations of kind `query`, normalised as SQLite reads them: a double quote, a backtick and a bracket delimit a name, a single quote a value, and a backslash escapes nothing. The same minor lets `observers` name every switch of `DOWNTRACE_INSTRUMENT`: `mysql`, `sqlite` and `mongodb` beside `pg`, `http`, `redis` and `runtime`, so an observer of those three that is watching is said; the instrumentation leaves the key out when no driver of it resolved, which is «did not say».
66
+
67
+ And since **0.12.0** `observers` has a `prisma` switch: Prisma's client, observed through the client and not through a driver, for Prisma before 7 on its own engine. Its operations are operations of kind `query` of the dependency its datasource is — `postgres` for Postgres and CockroachDB, `mysql`, `sqlite`, `mongodb` — with an empty `target`, labelled by two words, the action and the model (`findMany Post`, `create User`), and never the arguments; a raw query is labelled by its SQL, normalised as that dependency's dialect reads it. A client given a driver adapter is not counted by it: its driver's observer counts the SQL.
68
+
65
69
  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 and the ingestion path (`x-ingest-path`), so they are part of the generated contract rather than a constant someone has to keep in sync. So is the first minor that carries each kind of operation and of process exception (`x-since`, beside each `kind` enum), which is how a consumer tells a kind of error a sender cannot send from one it did not send, and whether each kind of operation is an error (`x-error`). A validator in strict mode has to be told these annotations are keywords.
66
70
 
67
71
  ## Source
package/dist/index.d.ts CHANGED
@@ -11,6 +11,22 @@ declare function captureEvidencePath(id: string): string;
11
11
  * Whether an observer is attached (`on`), was not asked for (`off`), or was asked for and could not attach (`unavailable`) — a driver that is not resolvable from the application's root, for instance. The third one is the point: without it, a service that is not being watched looks exactly like a service that has nothing to watch (COB-01, invariant 14).
12
12
  */
13
13
  type ObserverState = "on" | "off" | "unavailable";
14
+ /**
15
+ * Whether an observer is attached (`on`), was not asked for (`off`), or was asked for and could not attach (`unavailable`) — a driver that is not resolvable from the application's root, for instance. The third one is the point: without it, a service that is not being watched looks exactly like a service that has nothing to watch (COB-01, invariant 14).
16
+ */
17
+ type ObserverState1 = "on" | "off" | "unavailable";
18
+ /**
19
+ * Whether an observer is attached (`on`), was not asked for (`off`), or was asked for and could not attach (`unavailable`) — a driver that is not resolvable from the application's root, for instance. The third one is the point: without it, a service that is not being watched looks exactly like a service that has nothing to watch (COB-01, invariant 14).
20
+ */
21
+ type ObserverState2 = "on" | "off" | "unavailable";
22
+ /**
23
+ * Whether an observer is attached (`on`), was not asked for (`off`), or was asked for and could not attach (`unavailable`) — a driver that is not resolvable from the application's root, for instance. The third one is the point: without it, a service that is not being watched looks exactly like a service that has nothing to watch (COB-01, invariant 14).
24
+ */
25
+ type ObserverState3 = "on" | "off" | "unavailable";
26
+ /**
27
+ * Whether an observer is attached (`on`), was not asked for (`off`), or was asked for and could not attach (`unavailable`) — a driver that is not resolvable from the application's root, for instance. The third one is the point: without it, a service that is not being watched looks exactly like a service that has nothing to watch (COB-01, invariant 14).
28
+ */
29
+ type ObserverState4 = "on" | "off" | "unavailable";
14
30
  /**
15
31
  * A value of `Operation.kind` that its `x-error` marks as an error: the ways an error inside a request arrives, and so the sources that can produce one. A query, an outgoing call and a Redis command are things a route ran, never a source of error.
16
32
  */
@@ -26,7 +42,7 @@ interface AggregatesBatch {
26
42
  /**
27
43
  * Protocol version this batch conforms to. Every published minor of v0 stays acceptable.
28
44
  */
29
- protocol: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.7.0" | "0.8.0" | "0.9.0" | "0.10.0";
45
+ protocol: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.7.0" | "0.8.0" | "0.9.0" | "0.10.0" | "0.11.0" | "0.12.0";
30
46
  agent: AgentInfo;
31
47
  instance: InstanceInfo;
32
48
  deploy: DeployInfo;
@@ -76,6 +92,10 @@ interface AgentInfo {
76
92
  */
77
93
  interface Observers {
78
94
  pg?: ObserverState;
95
+ mysql?: ObserverState1;
96
+ sqlite?: ObserverState2;
97
+ mongodb?: ObserverState3;
98
+ prisma?: ObserverState4;
79
99
  http?: ObserverState;
80
100
  redis?: ObserverState;
81
101
  runtime?: ObserverState;
@@ -260,9 +280,9 @@ interface PostgresStats {
260
280
  */
261
281
  interface Dependency {
262
282
  /**
263
- * What kind of dependency this is. `mongodb` since 0.10.0: a MongoDB database, whose commands are operations of kind `query` named by the command and the collection (`find users`).
283
+ * What kind of dependency this is. `mongodb` since 0.10.0: a MongoDB database, whose commands are operations of kind `query` named by the command and the collection (`find users`). `sqlite` since 0.11.0: a SQLite database in the process, one dependency with an empty `target`, whose statements are operations of kind `query`. Since 0.12.0 a Prisma client's operation is an operation of kind `query` of the dependency its datasource is, with an empty `target`, named by the action and the model (`findMany Post`), or by its SQL for a raw query.
264
284
  */
265
- kind: "postgres" | "mysql" | "mongodb" | "redis" | "http";
285
+ kind: "postgres" | "mysql" | "sqlite" | "mongodb" | "redis" | "http";
266
286
  /**
267
287
  * Host for outgoing HTTP (`api.stripe.com`); empty when the dependency is a single one, like the application's own database.
268
288
  */
@@ -483,7 +503,7 @@ declare const DEPENDENCIES_MAX_ITEMS_V0 = 64;
483
503
  /** The most requests a capture's evidence may carry: the ring is sized as this minus the reserves' room (gh-901). */
484
504
  declare const EVIDENCE_REQUESTS_MAX_ITEMS_V0 = 4096;
485
505
  /** The dependency kinds the schema names, in the order it names them. */
486
- declare const DEPENDENCY_KINDS_V0: readonly ["postgres", "mysql", "mongodb", "redis", "http"];
506
+ declare const DEPENDENCY_KINDS_V0: readonly ["postgres", "mysql", "sqlite", "mongodb", "redis", "http"];
487
507
  //#endregion
488
508
  //#region src/generated/capture-evidence.d.ts
489
509
  /**
@@ -493,7 +513,7 @@ interface CaptureEvidence {
493
513
  /**
494
514
  * Protocol version this payload conforms to. Same enum as a batch: every published minor of v0 stays acceptable.
495
515
  */
496
- protocol: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.7.0" | "0.8.0" | "0.9.0" | "0.10.0";
516
+ protocol: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.7.0" | "0.8.0" | "0.9.0" | "0.10.0" | "0.11.0" | "0.12.0";
497
517
  /**
498
518
  * Which process observed this. Several instances of one deployment get the same order on purpose (ADR 0071), so the cloud has to be able to tell two answers apart.
499
519
  */
@@ -766,9 +786,9 @@ interface PendingCapture {
766
786
  //#endregion
767
787
  //#region src/generated/versions.d.ts
768
788
  /** Every published minor of v0, oldest first. The cloud never stops accepting one it published (ADR 0008). */
769
- declare const ACCEPTED_PROTOCOL_VERSIONS_V0: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.7.0", "0.8.0", "0.9.0", "0.10.0"];
789
+ declare const ACCEPTED_PROTOCOL_VERSIONS_V0: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.7.0", "0.8.0", "0.9.0", "0.10.0", "0.11.0", "0.12.0"];
770
790
  /** The newest published minor: what an up-to-date agent stamps on every batch. */
771
- declare const PROTOCOL_VERSION = "0.10.0";
791
+ declare const PROTOCOL_VERSION = "0.12.0";
772
792
  //#endregion
773
793
  //#region src/index.d.ts
774
794
  /** The JSON Schema (draft 2020-12) for AggregatesBatch, for validators on either side. */
@@ -1370,6 +1390,22 @@ declare const AGGREGATES_SCHEMA_V0: {
1370
1390
  pg: {
1371
1391
  $ref: string;
1372
1392
  };
1393
+ mysql: {
1394
+ $ref: string;
1395
+ description: string;
1396
+ };
1397
+ sqlite: {
1398
+ $ref: string;
1399
+ description: string;
1400
+ };
1401
+ mongodb: {
1402
+ $ref: string;
1403
+ description: string;
1404
+ };
1405
+ prisma: {
1406
+ $ref: string;
1407
+ description: string;
1408
+ };
1373
1409
  http: {
1374
1410
  $ref: string;
1375
1411
  };
package/dist/index.js CHANGED
@@ -27,7 +27,9 @@ var aggregates_schema_default = {
27
27
  "0.7.0",
28
28
  "0.8.0",
29
29
  "0.9.0",
30
- "0.10.0"
30
+ "0.10.0",
31
+ "0.11.0",
32
+ "0.12.0"
31
33
  ],
32
34
  "description": "Protocol version this batch conforms to. Every published minor of v0 stays acceptable."
33
35
  },
@@ -501,11 +503,12 @@ var aggregates_schema_default = {
501
503
  "enum": [
502
504
  "postgres",
503
505
  "mysql",
506
+ "sqlite",
504
507
  "mongodb",
505
508
  "redis",
506
509
  "http"
507
510
  ],
508
- "description": "What kind of dependency this is. `mongodb` since 0.10.0: a MongoDB database, whose commands are operations of kind `query` named by the command and the collection (`find users`)."
511
+ "description": "What kind of dependency this is. `mongodb` since 0.10.0: a MongoDB database, whose commands are operations of kind `query` named by the command and the collection (`find users`). `sqlite` since 0.11.0: a SQLite database in the process, one dependency with an empty `target`, whose statements are operations of kind `query`. Since 0.12.0 a Prisma client's operation is an operation of kind `query` of the dependency its datasource is, with an empty `target`, named by the action and the model (`findMany Post`), or by its SQL for a raw query."
509
512
  },
510
513
  "target": {
511
514
  "type": "string",
@@ -712,6 +715,22 @@ var aggregates_schema_default = {
712
715
  "description": "What the instrumentation is watching, by switch. The keys are the switches of `DOWNTRACE_INSTRUMENT`, so this says `pg` where a dependency says `postgres`: one is the switch and the other is the thing observed.",
713
716
  "properties": {
714
717
  "pg": { "$ref": "#/$defs/ObserverState" },
718
+ "mysql": {
719
+ "$ref": "#/$defs/ObserverState",
720
+ "description": "Since 0.11.0. Absent from an older sender, which had no word for it."
721
+ },
722
+ "sqlite": {
723
+ "$ref": "#/$defs/ObserverState",
724
+ "description": "Since 0.11.0. Absent from an older sender, which had no word for it."
725
+ },
726
+ "mongodb": {
727
+ "$ref": "#/$defs/ObserverState",
728
+ "description": "Since 0.11.0. Absent from an older sender, which had no word for it."
729
+ },
730
+ "prisma": {
731
+ "$ref": "#/$defs/ObserverState",
732
+ "description": "Since 0.12.0. Absent from an older sender, which had no word for it. Prisma's client, whose operations are queries of the dependency its datasource is: a switch of its own because it observes a client and not a driver."
733
+ },
715
734
  "http": { "$ref": "#/$defs/ObserverState" },
716
735
  "redis": { "$ref": "#/$defs/ObserverState" },
717
736
  "runtime": { "$ref": "#/$defs/ObserverState" }
@@ -946,7 +965,9 @@ var capture_evidence_schema_default = {
946
965
  "0.7.0",
947
966
  "0.8.0",
948
967
  "0.9.0",
949
- "0.10.0"
968
+ "0.10.0",
969
+ "0.11.0",
970
+ "0.12.0"
950
971
  ]
951
972
  },
952
973
  "instance": {
@@ -1468,6 +1489,7 @@ const EVIDENCE_REQUESTS_MAX_ITEMS_V0 = 4096;
1468
1489
  const DEPENDENCY_KINDS_V0 = [
1469
1490
  "postgres",
1470
1491
  "mysql",
1492
+ "sqlite",
1471
1493
  "mongodb",
1472
1494
  "redis",
1473
1495
  "http"
@@ -1485,10 +1507,12 @@ const ACCEPTED_PROTOCOL_VERSIONS_V0 = [
1485
1507
  "0.7.0",
1486
1508
  "0.8.0",
1487
1509
  "0.9.0",
1488
- "0.10.0"
1510
+ "0.10.0",
1511
+ "0.11.0",
1512
+ "0.12.0"
1489
1513
  ];
1490
1514
  /** The newest published minor: what an up-to-date agent stamps on every batch. */
1491
- const PROTOCOL_VERSION = "0.10.0";
1515
+ const PROTOCOL_VERSION = "0.12.0";
1492
1516
  //#endregion
1493
1517
  //#region src/index.ts
1494
1518
  /** The JSON Schema (draft 2020-12) for AggregatesBatch, for validators on either side. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@downtrace/protocol",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Downtrace ingestion protocol: JSON Schema, fixtures and generated TypeScript types",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,7 +10,20 @@
10
10
  "properties": {
11
11
  "protocol": {
12
12
  "type": "string",
13
- "enum": ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.7.0", "0.8.0", "0.9.0", "0.10.0"],
13
+ "enum": [
14
+ "0.1.0",
15
+ "0.2.0",
16
+ "0.3.0",
17
+ "0.4.0",
18
+ "0.5.0",
19
+ "0.6.0",
20
+ "0.7.0",
21
+ "0.8.0",
22
+ "0.9.0",
23
+ "0.10.0",
24
+ "0.11.0",
25
+ "0.12.0"
26
+ ],
14
27
  "description": "Protocol version this batch conforms to. Every published minor of v0 stays acceptable."
15
28
  },
16
29
  "agent": {
@@ -410,8 +423,8 @@
410
423
  "x-calls-per-request-boundaries": [0, 1, 2, 5, 10, 20, 50],
411
424
  "properties": {
412
425
  "kind": {
413
- "enum": ["postgres", "mysql", "mongodb", "redis", "http"],
414
- "description": "What kind of dependency this is. `mongodb` since 0.10.0: a MongoDB database, whose commands are operations of kind `query` named by the command and the collection (`find users`)."
426
+ "enum": ["postgres", "mysql", "sqlite", "mongodb", "redis", "http"],
427
+ "description": "What kind of dependency this is. `mongodb` since 0.10.0: a MongoDB database, whose commands are operations of kind `query` named by the command and the collection (`find users`). `sqlite` since 0.11.0: a SQLite database in the process, one dependency with an empty `target`, whose statements are operations of kind `query`. Since 0.12.0 a Prisma client's operation is an operation of kind `query` of the dependency its datasource is, with an empty `target`, named by the action and the model (`findMany Post`), or by its SQL for a raw query."
415
428
  },
416
429
  "target": {
417
430
  "type": "string",
@@ -594,6 +607,22 @@
594
607
  "pg": {
595
608
  "$ref": "#/$defs/ObserverState"
596
609
  },
610
+ "mysql": {
611
+ "$ref": "#/$defs/ObserverState",
612
+ "description": "Since 0.11.0. Absent from an older sender, which had no word for it."
613
+ },
614
+ "sqlite": {
615
+ "$ref": "#/$defs/ObserverState",
616
+ "description": "Since 0.11.0. Absent from an older sender, which had no word for it."
617
+ },
618
+ "mongodb": {
619
+ "$ref": "#/$defs/ObserverState",
620
+ "description": "Since 0.11.0. Absent from an older sender, which had no word for it."
621
+ },
622
+ "prisma": {
623
+ "$ref": "#/$defs/ObserverState",
624
+ "description": "Since 0.12.0. Absent from an older sender, which had no word for it. Prisma's client, whose operations are queries of the dependency its datasource is: a switch of its own because it observes a client and not a driver."
625
+ },
597
626
  "http": {
598
627
  "$ref": "#/$defs/ObserverState"
599
628
  },
@@ -11,7 +11,20 @@
11
11
  "protocol": {
12
12
  "type": "string",
13
13
  "description": "Protocol version this payload conforms to. Same enum as a batch: every published minor of v0 stays acceptable.",
14
- "enum": ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.7.0", "0.8.0", "0.9.0", "0.10.0"]
14
+ "enum": [
15
+ "0.1.0",
16
+ "0.2.0",
17
+ "0.3.0",
18
+ "0.4.0",
19
+ "0.5.0",
20
+ "0.6.0",
21
+ "0.7.0",
22
+ "0.8.0",
23
+ "0.9.0",
24
+ "0.10.0",
25
+ "0.11.0",
26
+ "0.12.0"
27
+ ]
15
28
  },
16
29
  "instance": {
17
30
  "type": "object",