@downtrace/protocol 0.8.0 → 0.10.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.
Files changed (36) hide show
  1. package/README.md +25 -1
  2. package/dist/index.d.ts +430 -24
  3. package/dist/index.js +325 -26
  4. package/package.json +1 -1
  5. package/schema/v0/aggregates.schema.json +112 -17
  6. package/schema/v0/capture-evidence.schema.json +154 -4
  7. package/schema/v0/fixtures/evidence/invalid/coarse-second-without-its-calls.json +20 -0
  8. package/schema/v0/fixtures/evidence/invalid/dependencies-truncated-negative.json +14 -0
  9. package/schema/v0/fixtures/evidence/invalid/dependencies-truncated-not-a-boolean.json +24 -0
  10. package/schema/v0/fixtures/evidence/invalid/operation-of-an-unknown-kind.json +33 -0
  11. package/schema/v0/fixtures/evidence/invalid/shed-with-an-extra-field.json +14 -0
  12. package/schema/v0/fixtures/evidence/invalid/shed-with-unknown-reason.json +14 -0
  13. package/schema/v0/fixtures/evidence/invalid/shed-with-zero-ms.json +14 -0
  14. package/schema/v0/fixtures/evidence/valid/with-coarse.json +40 -0
  15. package/schema/v0/fixtures/evidence/valid/with-dependencies-truncated.json +32 -0
  16. package/schema/v0/fixtures/evidence/valid/with-operation-kinds.json +57 -0
  17. package/schema/v0/fixtures/evidence/valid/with-shed.json +31 -0
  18. package/schema/v0/fixtures/invalid/a-running-total-of-nothing.json +27 -0
  19. package/schema/v0/fixtures/invalid/an-ending-nobody-declared.json +46 -0
  20. package/schema/v0/fixtures/invalid/call-with-a-path.json +38 -0
  21. package/schema/v0/fixtures/invalid/call-with-a-query-string.json +38 -0
  22. package/schema/v0/fixtures/invalid/command-with-its-key.json +38 -0
  23. package/schema/v0/fixtures/invalid/context-that-is-not-flat.json +40 -0
  24. package/schema/v0/fixtures/invalid/error-sources-with-a-call.json +49 -0
  25. package/schema/v0/fixtures/invalid/error-sources-with-a-query.json +49 -0
  26. package/schema/v0/fixtures/invalid/error-sources-with-a-repeat.json +49 -0
  27. package/schema/v0/fixtures/invalid/error-sources-with-an-unknown-value.json +49 -0
  28. package/schema/v0/fixtures/invalid/operation-of-an-unknown-kind.json +37 -0
  29. package/schema/v0/fixtures/valid/calls-and-commands.json +59 -0
  30. package/schema/v0/fixtures/valid/dropped-exceptions.json +56 -0
  31. package/schema/v0/fixtures/valid/error-sources.json +49 -0
  32. package/schema/v0/fixtures/valid/exceptions-with-a-running-total.json +38 -0
  33. package/schema/v0/fixtures/valid/exceptions-without-intervals.json +37 -0
  34. package/schema/v0/fixtures/valid/reported-errors.json +97 -0
  35. package/schema/v0/fixtures/valid/the-last-batch-of-a-process.json +59 -0
  36. package/schema/v0/fixtures/valid/triggers-without-intervals.json +28 -0
package/dist/index.js CHANGED
@@ -25,7 +25,9 @@ var aggregates_schema_default = {
25
25
  "0.5.0",
26
26
  "0.6.0",
27
27
  "0.7.0",
28
- "0.8.0"
28
+ "0.8.0",
29
+ "0.9.0",
30
+ "0.10.0"
29
31
  ],
30
32
  "description": "Protocol version this batch conforms to. Every published minor of v0 stays acceptable."
31
33
  },
@@ -37,7 +39,7 @@ var aggregates_schema_default = {
37
39
  "minItems": 0,
38
40
  "maxItems": 6,
39
41
  "items": { "$ref": "#/$defs/Interval" },
40
- "description": "The intervals this batch carries. May be empty when the batch carries a profile: the profile has a cadence of its own and hangs off the batch, not off an interval (ADR 0017), so tying its delivery to one meant it was lost whenever a window closed with no traffic — at shutdown, always (gh-375). A batch with neither is refused by the cloud with a reason, which the schema cannot say without making the generated types unusable."
42
+ "description": "The intervals this batch carries. May be empty whenever the batch carries anything else: a process that serves no requests closes no interval, and nothing else a batch carries hangs off one — tying delivery to an interval lost the profile at every shutdown (gh-375) and every exception of a process with no traffic (gh-627). A batch that carries nothing at all is refused by the cloud with a reason, which the schema cannot say without making the generated types unusable."
41
43
  },
42
44
  "profile": { "$ref": "#/$defs/Profile" },
43
45
  "captures": {
@@ -56,7 +58,15 @@ var aggregates_schema_default = {
56
58
  "type": "array",
57
59
  "maxItems": 4,
58
60
  "items": { "$ref": "#/$defs/LocalTrigger" },
59
- "description": "Local signals that ask for a capture. `product.md:124` gives the instrumentation «disparar por señales locales»: it sees a process in trouble before any aggregate crosses the cloud, and asking in the batch costs no channel of its own — the answer already carries the orders (ADR 0071). Absent from every sender that predates it and from every batch with nothing to ask. The cloud decides: the same budget, cooldown and concurrency as any other capture (`product.md:122`), and a refusal is silence, because there is nothing the instrumentation would do differently."
61
+ "description": "Local signals that ask for a capture. `product.md:124` gives the instrumentation «trigger on local signals»: it sees a process in trouble before any aggregate crosses the cloud, and asking in the batch costs no channel of its own — the answer already carries the orders (ADR 0071). Absent from every sender that predates it and from every batch with nothing to ask. The cloud decides: the same budget, cooldown and concurrency as any other capture (`product.md:122`), and a refusal is silence, because there is nothing the instrumentation would do differently."
62
+ },
63
+ "ending": {
64
+ "enum": [
65
+ "signal",
66
+ "exit",
67
+ "idle"
68
+ ],
69
+ "description": "This batch is the last one: the process is leaving deliberately and has already been handed everything the instrumentation was holding. `signal`, a SIGTERM or SIGINT the instrumentation's own handler saw; `exit`, an application that awaited `shutdown()` before calling `process.exit()`; `idle`, an event loop that emptied. Absent means **this sender did not say**, the same reading as `observers` — never that it ended badly: an instrumentation older than this never says it, and a process an exception killed says nothing because it cannot. It is the half of ERR-04 the cloud cannot infer — from outside, every ending looks like batches stopping — and it carries no instant, because the one that matters is when the batch arrived, which the cloud measures."
60
70
  }
61
71
  },
62
72
  $defs: {
@@ -97,10 +107,55 @@ var aggregates_schema_default = {
97
107
  },
98
108
  "resources": {
99
109
  "$ref": "#/$defs/AgentResources",
100
- "description": "What the instrumentation costs and what it has lost, measured by itself. Absent means **this sender did not say**, the same reading as `observers` and `withholding`. `product.md:239` asks for it by name: «recursos internos medidos»."
110
+ "description": "What the instrumentation costs and what it has lost, measured by itself. Absent means **this sender did not say**, the same reading as `observers` and `withholding`. `product.md:239` asks for it by name: «measured internal resources»."
111
+ },
112
+ "errorSources": {
113
+ "$ref": "#/$defs/ErrorSources",
114
+ "description": "Which of the sources of error this process has connected, as of the moment this batch is sealed. A source is on its list when the process has, at that moment, the instrumentation that produces it installed; the application calling `captureException` does not make it one without the hook connected. Absent means **this sender did not say**, the same reading as `observers` and `resources`: an instrumentation older than protocol 0.9.0 says nothing, and the two lists left empty are not the same thing, because they are a statement — the sender says it has connected no source of error."
101
115
  }
102
116
  }
103
117
  },
118
+ "ErrorSources": {
119
+ "title": "ErrorSources",
120
+ "type": "object",
121
+ "additionalProperties": false,
122
+ "required": ["inRequest", "outsideRequest"],
123
+ "properties": {
124
+ "inRequest": {
125
+ "type": "array",
126
+ "uniqueItems": true,
127
+ "items": { "$ref": "#/$defs/InRequestErrorSource" },
128
+ "description": "The sources of the errors this process sees inside a request, by the value of `Operation.kind` they arrive as, among the values `x-error` marks as errors: `error`, an instrumented operation failed; `framework`, the exception reached the framework's error path and was turned into a 5xx; `explicit`, the application handed it over itself. No value appears twice."
129
+ },
130
+ "outsideRequest": {
131
+ "type": "array",
132
+ "uniqueItems": true,
133
+ "items": { "$ref": "#/$defs/OutsideRequestErrorSource" },
134
+ "description": "The sources of the errors this process sees outside any request, by the value of `ProcessException.kind`: `uncaught`, an exception nothing caught; `unhandled-rejection`, a promise rejected with nothing to handle it; `framework`, one that reached a framework's error path; `explicit`, one the application handed over itself. No value appears twice."
135
+ }
136
+ }
137
+ },
138
+ "InRequestErrorSource": {
139
+ "title": "InRequestErrorSource",
140
+ "type": "string",
141
+ "enum": [
142
+ "error",
143
+ "framework",
144
+ "explicit"
145
+ ],
146
+ "description": "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."
147
+ },
148
+ "OutsideRequestErrorSource": {
149
+ "title": "OutsideRequestErrorSource",
150
+ "type": "string",
151
+ "enum": [
152
+ "uncaught",
153
+ "unhandled-rejection",
154
+ "framework",
155
+ "explicit"
156
+ ],
157
+ "description": "A value of `ProcessException.kind`: the ways an error outside any request arrives, and so the sources that can produce one."
158
+ },
104
159
  "InstanceInfo": {
105
160
  "title": "InstanceInfo",
106
161
  "type": "object",
@@ -202,7 +257,7 @@ var aggregates_schema_default = {
202
257
  "type": "string",
203
258
  "minLength": 1,
204
259
  "maxLength": 256,
205
- "description": "Normalised route template, e.g. /products/:id, or (other)."
260
+ "description": "Normalised route template, e.g. /products/:id, or a name that is not a route: (other), what the interval's cap on routes left out, or (unmatched), the requests that no route of the framework named (DT-56)."
206
261
  },
207
262
  "count": {
208
263
  "type": "integer",
@@ -446,10 +501,11 @@ var aggregates_schema_default = {
446
501
  "enum": [
447
502
  "postgres",
448
503
  "mysql",
504
+ "mongodb",
449
505
  "redis",
450
506
  "http"
451
507
  ],
452
- "description": "What kind of dependency this is."
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`)."
453
509
  },
454
510
  "target": {
455
511
  "type": "string",
@@ -537,7 +593,7 @@ var aggregates_schema_default = {
537
593
  "type": "string",
538
594
  "minLength": 1,
539
595
  "maxLength": 256,
540
- "description": "Normalised route template, e.g. /products/:id, or (other)."
596
+ "description": "Normalised route template, e.g. /products/:id, or a name that is not a route: (other), what the interval's cap on routes left out, or (unmatched), the requests that no route of the framework named (DT-56)."
541
597
  },
542
598
  "operations": {
543
599
  "type": "array",
@@ -558,8 +614,31 @@ var aggregates_schema_default = {
558
614
  ],
559
615
  "properties": {
560
616
  "kind": {
561
- "enum": ["query", "error"],
562
- "description": "What kind of operation this is."
617
+ "enum": [
618
+ "query",
619
+ "error",
620
+ "framework",
621
+ "explicit",
622
+ "call",
623
+ "command"
624
+ ],
625
+ "x-since": {
626
+ "query": "0.6.0",
627
+ "error": "0.6.0",
628
+ "framework": "0.9.0",
629
+ "explicit": "0.9.0",
630
+ "call": "0.9.0",
631
+ "command": "0.9.0"
632
+ },
633
+ "x-error": {
634
+ "query": false,
635
+ "error": true,
636
+ "framework": true,
637
+ "explicit": true,
638
+ "call": false,
639
+ "command": false
640
+ },
641
+ "description": "What kind of operation this is. Three are things the route ran: `query`, a query to a database; `call`, an outgoing HTTP call, identified by its method and its host; `command`, a Redis command, identified by its name and its server. The other three are errors, and which one it is says how the instrumentation came to see it: `error`, an instrumented operation failed; `framework`, the exception reached the framework's error path and was turned into a 5xx; `explicit`, the application handed it over itself (ERR-02). `x-since` says which minor first carries each value, which is how a reader tells a kind a sender cannot send from one it did not; `x-error` says which values are errors, which is what a list of errors takes and the rest never reach (ERR-01)."
563
642
  },
564
643
  "hash": {
565
644
  "type": "string",
@@ -570,7 +649,7 @@ var aggregates_schema_default = {
570
649
  "text": {
571
650
  "type": "string",
572
651
  "maxLength": 1024,
573
- "description": "Normalised text, e.g. `SELECT id FROM products WHERE id = ?`. Optional: a user who would rather not send it keeps the whole analysis, only without the label."
652
+ "description": "Normalised text, e.g. `SELECT id FROM products WHERE id = ?` for a query, `find users` for a MongoDB command — its name and its collection, never the filter or the documents —, `POST api.stripe.com` for a call and `HGETALL cache:6379` for a command. A call's and a command's are a word and the place it went — the method and the host, the command's name and its server — and never a path, a query string, a key or an argument (invariant 5): the schema refuses one with anything after the place, or a slash, a question mark or a hash in it. Optional: a user who would rather not send it keeps the whole analysis, only without the label, and a sender in minimal mode, or one withholding the name of the dependency, sends none."
574
653
  },
575
654
  "count": {
576
655
  "type": "integer",
@@ -592,6 +671,7 @@ var aggregates_schema_default = {
592
671
  "minimum": 0,
593
672
  "description": "Only on the `(other)` bucket: how many distinct operations it merges, so a cap does not become a lie by omission."
594
673
  },
674
+ "context": { "$ref": "#/$defs/ReportedContext" },
595
675
  "class": {
596
676
  "enum": [
597
677
  "select",
@@ -600,7 +680,7 @@ var aggregates_schema_default = {
600
680
  "delete",
601
681
  "other"
602
682
  ],
603
- "description": "What kind of statement this is, when the sender could not normalise it safely. Its presence is the reason the text is absent: `product.md:104` says a query the normaliser does not understand travels «solo como hash y clase», and this is the class. Never sent together with `text` — they are two answers to the same question. Our word and not the service's: it is decided from the first keyword, which is all that can be told without understanding the rest (gh-344)."
683
+ "description": "What kind of statement this is, when the sender could not normalise it safely. Its presence is the reason the text is absent: `product.md:104` says a query the normaliser does not understand travels «only as hash and class», and this is the class. Never sent together with `text` — they are two answers to the same question. Our word and not the service's: it is decided from the first keyword, which is all that can be told without understanding the rest (gh-344)."
604
684
  }
605
685
  },
606
686
  "not": {
@@ -609,7 +689,12 @@ var aggregates_schema_default = {
609
689
  "class": {},
610
690
  "text": {}
611
691
  }
612
- }
692
+ },
693
+ "if": { "properties": { "kind": { "enum": ["call", "command"] } } },
694
+ "then": { "properties": { "text": {
695
+ "type": "string",
696
+ "pattern": "^[A-Z][A-Z0-9._-]* [^\\s/?#]+$"
697
+ } } }
613
698
  },
614
699
  "ObserverState": {
615
700
  "title": "ObserverState",
@@ -684,11 +769,22 @@ var aggregates_schema_default = {
684
769
  "hash",
685
770
  "count"
686
771
  ],
687
- "description": "Something thrown outside any instrumented operation: an exception nobody caught, or a promise rejected with no `catch`. `product.md:77` asks for «errores **y excepciones**», and these are the two the word «excepciones» names. They live on the batch and not in the profile because they have **no route** — they happen outside a request's life, or after it ended — and filing them under a route that is not theirs would be worse than not having them (gh-341, ADR 0102).",
772
+ "description": "Something thrown outside any instrumented operation: an exception nobody caught, or a promise rejected with no `catch`. `product.md:77` asks for «errors and exceptions», and these are the two the word «excepciones» names. They live on the batch and not in the profile because they have **no route** — they happen outside a request's life, or after it ended — and filing them under a route that is not theirs would be worse than not having them (gh-341, ADR 0102).",
688
773
  "properties": {
689
774
  "kind": {
690
- "enum": ["uncaught", "unhandled-rejection"],
691
- "description": "Which of the two. Two different failures with two different fixes: counting them together hides which one is happening."
775
+ "enum": [
776
+ "uncaught",
777
+ "unhandled-rejection",
778
+ "framework",
779
+ "explicit"
780
+ ],
781
+ "x-since": {
782
+ "uncaught": "0.7.0",
783
+ "unhandled-rejection": "0.7.0",
784
+ "framework": "0.9.0",
785
+ "explicit": "0.9.0"
786
+ },
787
+ "description": "How the process came to see it. `uncaught` and `unhandled-rejection` are two different failures with two different fixes, and counting them together hides which one is happening. `explicit` is an error the application handed over while no request was being served, and `framework` one that reached a framework's error path outside any observed request — a process that is not opening request contexts at all (ERR-02). `x-since` says which minor first carries each value."
692
788
  },
693
789
  "hash": {
694
790
  "type": "string",
@@ -704,10 +800,27 @@ var aggregates_schema_default = {
704
800
  "count": {
705
801
  "type": "integer",
706
802
  "minimum": 1,
707
- "description": "How many times this signature happened. An instant per occurrence would be a row per crash of a process that crashes in a loop; what a reader asks is how many."
708
- }
803
+ "description": "How many times this signature happened since the last delivery this sender heard land. An instant per occurrence would be a row per crash of a process that crashes in a loop; what a reader asks is how many."
804
+ },
805
+ "total": {
806
+ "type": "integer",
807
+ "minimum": 1,
808
+ "description": "Since 0.9.0: how many times this signature has happened in this instance since it started, a running total every delivery of the signature carries again. It is what lets the cloud tell a delivery it already applied from one that happened again (gh-625): `total - count` is what the sender knows was applied, the cloud keeps the largest total it applied per instance and signature, and it counts only what this delivery adds beyond both — so a delivery sent again after its answer was lost, sent twice, or overtaken by a later one adds nothing, and one that never arrived is counted by the next. It never goes down while `instance.id` stays the same, which is why that id is generated once per process. Absent from every sender older than this, and from a signature past the number a sender keeps totals for: the cloud then counts `count` as delivered, and says so."
809
+ },
810
+ "context": { "$ref": "#/$defs/ReportedContext" }
709
811
  }
710
812
  },
813
+ "ReportedContext": {
814
+ "title": "ReportedContext",
815
+ "type": "object",
816
+ "maxProperties": 8,
817
+ "propertyNames": { "maxLength": 32 },
818
+ "additionalProperties": {
819
+ "type": "string",
820
+ "maxLength": 64
821
+ },
822
+ "description": "The structural context an application attached to an error it reported (ERR-02, since 0.9.0). Flat and small on purpose: what travels is the shape of the failure, never its contents (invariant 5). Every value has been through the same sanitising as an error message before it got here, so anything that looked like a value is already a `?`, and there is nothing per user in it (IMP-01). It is the context of the **first** occurrence of the signature in this window, because what travels is counted per signature and not per occurrence. Absent is the normal case: an error nobody attached a context to carries none."
823
+ },
711
824
  "LocalTrigger": {
712
825
  "type": "object",
713
826
  "title": "LocalTrigger",
@@ -768,6 +881,11 @@ var aggregates_schema_default = {
768
881
  "minimum": 0,
769
882
  "description": "Errors inside the instrumentation itself, since the previous batch. It disables itself after enough of them, and a sender that has gone quiet with these climbing is not a quiet service."
770
883
  },
884
+ "droppedExceptions": {
885
+ "type": "integer",
886
+ "minimum": 0,
887
+ "description": "Exception events the instrumentation discarded because they did not fit in its caps of distinct signatures — the register's window, and the sender's accumulation while batches do not land — since the previous batch. An occurrence, never a signature: the sender cannot name what it did not admit without remembering it, and remembering is the growth the cap exists to stop. This is what happened and is gone, the same kind of number as droppedBatches, for the errors a process throws outside any request: a batch that says 32 and was handed 35 must not leave the other 3 to be read as errors that did not happen (COB-01, invariant 14)."
888
+ },
771
889
  "bufferBytes": {
772
890
  "type": "integer",
773
891
  "minimum": 0,
@@ -785,7 +903,7 @@ var aggregates_schema_default = {
785
903
  "fine",
786
904
  "profile"
787
905
  ],
788
- "description": "What the instrumentation has given up because it was costing too much, cheapest loss first. `product.md:241` asks for both halves —«se autolimita» and «lo registra como pérdida de cobertura»— and this is the second. An enum and not free text: it is ours, and it has to be comparable between senders."
906
+ "description": "What the instrumentation has given up because it was costing too much, cheapest loss first. `product.md:241` asks for both halves —«it throttles itself» and «records it as a loss of coverage»— and this is the second. An enum and not free text: it is ours, and it has to be comparable between senders."
789
907
  },
790
908
  "shedReason": {
791
909
  "type": "string",
@@ -802,7 +920,7 @@ var capture_evidence_schema_default = {
802
920
  $schema: "https://json-schema.org/draft/2020-12/schema",
803
921
  $id: "https://downtrace.io/schema/v0/capture-evidence.schema.json",
804
922
  title: "CaptureEvidence",
805
- description: "What an instrumentation sends back for a capture the cloud asked for (POST /v0/captures/{id}/evidence). It is the contents of the black box's fine register, frozen: requests with their operations, in order, with starts and ends. Hashes only — the text of a query never travels here (invariant 5). Its own path and not the aggregates batch, because a batch is what goes out every ten seconds and this is a rare event several orders of magnitude larger.",
923
+ description: "What an instrumentation sends back for a capture the cloud asked for (POST /v0/captures/{id}/evidence). It is the contents of the black box, frozen: the fine register's requests with their operations, in order, with starts and ends, and the coarse summary of the previous minutes, second by second. Hashes only — the text of a query never travels here (invariant 5). Its own path and not the aggregates batch, because a batch is what goes out every ten seconds and this is a rare event several orders of magnitude larger.",
806
924
  "x-evidence-path": "/v0/captures/{id}/evidence",
807
925
  type: "object",
808
926
  additionalProperties: false,
@@ -826,7 +944,9 @@ var capture_evidence_schema_default = {
826
944
  "0.5.0",
827
945
  "0.6.0",
828
946
  "0.7.0",
829
- "0.8.0"
947
+ "0.8.0",
948
+ "0.9.0",
949
+ "0.10.0"
830
950
  ]
831
951
  },
832
952
  "instance": {
@@ -867,7 +987,8 @@ var capture_evidence_schema_default = {
867
987
  "items": { "$ref": "#/$defs/CapturedRequest" },
868
988
  "description": "The requests observed, oldest first. An empty array is a real answer and the commonest one: a route nobody called during the window. It means the capture is `empty`, and `product.md:192` is explicit that this must never read as an invitation to ask again unchanged."
869
989
  },
870
- "reference": { "$ref": "#/$defs/Reference" }
990
+ "reference": { "$ref": "#/$defs/Reference" },
991
+ "coarse": { "$ref": "#/$defs/CoarseSummary" }
871
992
  },
872
993
  $defs: {
873
994
  "Coverage": {
@@ -901,6 +1022,31 @@ var capture_evidence_schema_default = {
901
1022
  "type": "integer",
902
1023
  "minimum": 0,
903
1024
  "description": "Requests that ran more operations than the register keeps per request. Their count is real and their list is not complete."
1025
+ },
1026
+ "shed": { "$ref": "#/$defs/Shed" },
1027
+ "dependenciesTruncated": {
1028
+ "type": "integer",
1029
+ "minimum": 0,
1030
+ "description": "Requests whose list of dependencies was truncated. Their count is real and their list is not complete. A sender that knows the field sends it, zero included. Absent in an evidence of protocol 0.9.0 or later is zero: @downtrace/agent 0.9.0 omitted it at zero. Absent in an earlier protocol is a sender older than the field, which did not say, and that is not none."
1031
+ }
1032
+ }
1033
+ },
1034
+ "Shed": {
1035
+ "type": "object",
1036
+ "title": "Shed",
1037
+ "additionalProperties": false,
1038
+ "required": ["ms", "reason"],
1039
+ "description": "The time inside [startedAt, endedAt] when the instrumentation was not writing the fine detail — neither the register's ring nor the reserve — because it was shedding it. Present when some part of the window was shed, absent when there was no shedding, when the shedding came from configuration (`DOWNTRACE_SHED`, the benchmark) and so the instrumentation never decided it, or when the instrumentation predates the field: a sender older than the field sends nothing, and the cloud stores the absence as such (ADR 0008). The capture is still taken, not refused: the window can end before the shedding does, the coarse register keeps measuring, and the protocol has no way for an instance to refuse an order — saying it in the evidence is what CAP-01 asks for.",
1040
+ "properties": {
1041
+ "ms": {
1042
+ "type": "integer",
1043
+ "minimum": 1,
1044
+ "description": "How long the shedding lasted, in whole milliseconds, rounded up: one millisecond of shedding is still shedding, and the field says so rather than rounding it into silence."
1045
+ },
1046
+ "reason": {
1047
+ "type": "string",
1048
+ "enum": ["latency", "memory"],
1049
+ "description": "The last reason in force inside the window, the same enum as `agent.resources.shedReason` in the batch: why it gave ground. One value and not a list: a window that shed for two reasons is read as the one in force when it ended, which is the one still changing what arrives."
904
1050
  }
905
1051
  }
906
1052
  },
@@ -958,6 +1104,10 @@ var capture_evidence_schema_default = {
958
1104
  "detailLost": {
959
1105
  "type": "boolean",
960
1106
  "description": "This request's operations were overwritten before they were read. Absent means false. Its timing is still true."
1107
+ },
1108
+ "dependenciesTruncated": {
1109
+ "type": "boolean",
1110
+ "description": "This request's list of dependencies did not fit and was truncated to what the register keeps per request. A dependency not in the list is not proven not to have been used (invariant 14). Absent means false."
961
1111
  }
962
1112
  }
963
1113
  },
@@ -972,6 +1122,17 @@ var capture_evidence_schema_default = {
972
1122
  ],
973
1123
  "description": "One operation inside a request. Starts and ends and not durations, because the whole reason for capturing detail is order and overlap, which a duration cannot express (ADR 0068).",
974
1124
  "properties": {
1125
+ "kind": {
1126
+ "enum": [
1127
+ "query",
1128
+ "error",
1129
+ "framework",
1130
+ "explicit",
1131
+ "call",
1132
+ "command"
1133
+ ],
1134
+ "description": "What kind of operation this is, in the words of the batch's `Operation.kind`, whose enum this borrows: a query, an outgoing call or a Redis command the request ran, or one of the kinds of error recorded in it beside what failed. Since 0.9.0. **Absent means the sender did not say**, never a query: an instrumentation older than the field wrote every operation it recorded here without one, the error signatures beside a failed query among them, and a reader that took them for queries would be naming what it was not told."
1135
+ },
975
1136
  "hash": {
976
1137
  "type": "string",
977
1138
  "minLength": 1,
@@ -998,7 +1159,7 @@ var capture_evidence_schema_default = {
998
1159
  "population",
999
1160
  "samples"
1000
1161
  ],
1001
- "description": "A few requests of each endpoint kept as something to compare the captured ones against. `product.md:100`: «Comparar requests degradadas con requests de referencia exige conservar ambas; el detalle fino de hace una hora ya no existe». Being earlier does not certify health, which is why every field here is about how they were chosen and none of them says «healthy».",
1162
+ "description": "A few requests of each endpoint kept as something to compare the captured ones against. `product.md:100`: «Comparing degraded requests against reference requests requires keeping both; the fine detail of an hour ago no longer exists». Being earlier does not certify health, which is why every field here is about how they were chosen and none of them says «healthy».",
1002
1163
  "properties": {
1003
1164
  "selection": {
1004
1165
  "type": "string",
@@ -1013,7 +1174,7 @@ var capture_evidence_schema_default = {
1013
1174
  "routesDropped": {
1014
1175
  "type": "integer",
1015
1176
  "minimum": 0,
1016
- "description": "Endpoints seen that the register had no room for. Counted rather than silently absent: an endpoint with no samples is not an endpoint with no traffic (invariant 14)."
1177
+ "description": "Routes the register had no row for, folded into one shared row, counted once each. At the register's cap for how many it may remember it is a lower bound: a bounded memory does not count distinct names past its bound, and the volume of what was folded is what the shared row keeps."
1017
1178
  },
1018
1179
  "renewalPaused": {
1019
1180
  "type": "boolean",
@@ -1026,6 +1187,128 @@ var capture_evidence_schema_default = {
1026
1187
  "description": "The kept requests, in the same shape as the captured ones. An empty array is a real answer: a process that has just started has nothing to compare with yet."
1027
1188
  }
1028
1189
  }
1190
+ },
1191
+ "CoarseSummary": {
1192
+ "type": "object",
1193
+ "title": "CoarseSummary",
1194
+ "additionalProperties": false,
1195
+ "required": [
1196
+ "windowSeconds",
1197
+ "routes",
1198
+ "eventLoop",
1199
+ "routesDropped"
1200
+ ],
1201
+ "description": "The coarse half of the black box, frozen: the last few minutes, second by second, so a reader can see how something detected late began (`product.md:94`). Sums and a maximum, never percentiles: the interval aggregate answers the percentile question with exactness, and this answers the shape of the change (`product.md:122`). What an older instrumentation did not send is absent from the evidence, and stored as absent.",
1202
+ "properties": {
1203
+ "windowSeconds": {
1204
+ "type": "integer",
1205
+ "minimum": 1,
1206
+ "description": "How many seconds the summary covers: the length of the register's window, and the most any of the lists below may hold."
1207
+ },
1208
+ "routesDropped": {
1209
+ "type": "integer",
1210
+ "minimum": 0,
1211
+ "description": "Routes the register had no row for, folded into one shared row, counted once each. At the register's cap for how many it may remember it is a lower bound: a bounded memory does not count distinct names past its bound, and the volume of what was folded is what the shared row keeps."
1212
+ },
1213
+ "routes": {
1214
+ "type": "array",
1215
+ "maxItems": 129,
1216
+ "items": { "$ref": "#/$defs/CoarseRoute" },
1217
+ "description": "One entry per route with a row of its own, the last being the shared row for what did not fit, when there is one. A route's series starts at the first second this process saw the route: before it, nobody was watching this route, and inventing silence there would say the route was quiet when the truth is that it was unwatched (invariant 14)."
1218
+ },
1219
+ "eventLoop": {
1220
+ "type": "array",
1221
+ "maxItems": 300,
1222
+ "items": { "$ref": "#/$defs/CoarseEventLoopSecond" },
1223
+ "description": "The process's event loop delay, second by second, in its own series and not attributed to any route: it is the process's, and attributing it to a route would be inventing a measurement. Only the seconds somebody sampled are here: a second with no reading says nothing about the loop, and a zero would say it was idle. An empty array is a real answer: the process had no event loop to sample, or nobody did."
1224
+ }
1225
+ }
1226
+ },
1227
+ "CoarseRoute": {
1228
+ "type": "object",
1229
+ "title": "CoarseRoute",
1230
+ "additionalProperties": false,
1231
+ "required": [
1232
+ "method",
1233
+ "route",
1234
+ "seconds"
1235
+ ],
1236
+ "properties": {
1237
+ "method": {
1238
+ "type": "string",
1239
+ "maxLength": 16
1240
+ },
1241
+ "route": {
1242
+ "type": "string",
1243
+ "maxLength": 512,
1244
+ "description": "The route template, never the path with its values in it (invariant 5)."
1245
+ },
1246
+ "seconds": {
1247
+ "type": "array",
1248
+ "maxItems": 300,
1249
+ "items": { "$ref": "#/$defs/CoarseSecond" }
1250
+ }
1251
+ }
1252
+ },
1253
+ "CoarseSecond": {
1254
+ "type": "object",
1255
+ "title": "CoarseSecond",
1256
+ "additionalProperties": false,
1257
+ "required": [
1258
+ "second",
1259
+ "requests",
1260
+ "errors",
1261
+ "latencySumMs",
1262
+ "latencyMaxMs",
1263
+ "calls"
1264
+ ],
1265
+ "description": "One second of one route. Sums and a maximum, never a histogram: a histogram per second per route would multiply the memory by its buckets to answer a question the interval already answers.",
1266
+ "properties": {
1267
+ "second": {
1268
+ "type": "integer",
1269
+ "description": "The Unix second this row covers, an integer instant like the ones a batch writes: a reader aligns it with the dates the evidence writes by flooring them."
1270
+ },
1271
+ "requests": {
1272
+ "type": "integer",
1273
+ "minimum": 0,
1274
+ "description": "Requests this route answered in this second. Zero is a real answer: a watched second with no traffic, and not an absence."
1275
+ },
1276
+ "errors": {
1277
+ "type": "integer",
1278
+ "minimum": 0,
1279
+ "description": "Requests that answered 5xx."
1280
+ },
1281
+ "latencySumMs": {
1282
+ "type": "number",
1283
+ "minimum": 0
1284
+ },
1285
+ "latencyMaxMs": {
1286
+ "type": "number",
1287
+ "minimum": 0
1288
+ },
1289
+ "calls": {
1290
+ "type": "integer",
1291
+ "minimum": 0,
1292
+ "description": "Operations the requests of this second ran."
1293
+ }
1294
+ }
1295
+ },
1296
+ "CoarseEventLoopSecond": {
1297
+ "type": "object",
1298
+ "title": "CoarseEventLoopSecond",
1299
+ "additionalProperties": false,
1300
+ "required": ["second", "maxDelayMs"],
1301
+ "properties": {
1302
+ "second": {
1303
+ "type": "integer",
1304
+ "description": "The Unix second this reading covers."
1305
+ },
1306
+ "maxDelayMs": {
1307
+ "type": "number",
1308
+ "minimum": 0,
1309
+ "description": "The worst delay sampled in this second: a second that stalled once stalled, and averaging it away is how a stall becomes invisible."
1310
+ }
1311
+ }
1029
1312
  }
1030
1313
  }
1031
1314
  };
@@ -1176,6 +1459,20 @@ function captureEvidencePath(id) {
1176
1459
  return CAPTURE_EVIDENCE_PATH.replace("{id}", encodeURIComponent(id));
1177
1460
  }
1178
1461
  //#endregion
1462
+ //#region src/generated/caps.ts
1463
+ /** The most dependencies one endpoint may carry in a batch. */
1464
+ const DEPENDENCIES_MAX_ITEMS_V0 = 64;
1465
+ /** The most requests a capture's evidence may carry: the ring is sized as this minus the reserves' room (gh-901). */
1466
+ const EVIDENCE_REQUESTS_MAX_ITEMS_V0 = 4096;
1467
+ /** The dependency kinds the schema names, in the order it names them. */
1468
+ const DEPENDENCY_KINDS_V0 = [
1469
+ "postgres",
1470
+ "mysql",
1471
+ "mongodb",
1472
+ "redis",
1473
+ "http"
1474
+ ];
1475
+ //#endregion
1179
1476
  //#region src/generated/versions.ts
1180
1477
  /** Every published minor of v0, oldest first. The cloud never stops accepting one it published (ADR 0008). */
1181
1478
  const ACCEPTED_PROTOCOL_VERSIONS_V0 = [
@@ -1186,10 +1483,12 @@ const ACCEPTED_PROTOCOL_VERSIONS_V0 = [
1186
1483
  "0.5.0",
1187
1484
  "0.6.0",
1188
1485
  "0.7.0",
1189
- "0.8.0"
1486
+ "0.8.0",
1487
+ "0.9.0",
1488
+ "0.10.0"
1190
1489
  ];
1191
1490
  /** The newest published minor: what an up-to-date agent stamps on every batch. */
1192
- const PROTOCOL_VERSION = "0.8.0";
1491
+ const PROTOCOL_VERSION = "0.10.0";
1193
1492
  //#endregion
1194
1493
  //#region src/index.ts
1195
1494
  /** The JSON Schema (draft 2020-12) for AggregatesBatch, for validators on either side. */
@@ -1224,4 +1523,4 @@ function callsPerRequestBucket(calls) {
1224
1523
  return n;
1225
1524
  }
1226
1525
  //#endregion
1227
- export { ACCEPTED_PROTOCOL_VERSIONS_V0, AGGREGATES_PATH, AGGREGATES_SCHEMA_V0, CALLS_PER_REQUEST_BOUNDARIES_V0, CALLS_PER_REQUEST_BUCKETS_V0, CAPTURE_EVIDENCE_PATH, CAPTURE_EVIDENCE_SCHEMA_V0, INGEST_RESPONSE_SCHEMA_V0, LATENCY_BOUNDARIES_V0, LATENCY_BUCKETS_V0, PROTOCOL_VERSION, callsPerRequestBucket, captureEvidencePath, latencyBucket };
1526
+ export { ACCEPTED_PROTOCOL_VERSIONS_V0, AGGREGATES_PATH, AGGREGATES_SCHEMA_V0, CALLS_PER_REQUEST_BOUNDARIES_V0, CALLS_PER_REQUEST_BUCKETS_V0, CAPTURE_EVIDENCE_PATH, CAPTURE_EVIDENCE_SCHEMA_V0, DEPENDENCIES_MAX_ITEMS_V0, DEPENDENCY_KINDS_V0, EVIDENCE_REQUESTS_MAX_ITEMS_V0, INGEST_RESPONSE_SCHEMA_V0, LATENCY_BOUNDARIES_V0, LATENCY_BUCKETS_V0, PROTOCOL_VERSION, callsPerRequestBucket, captureEvidencePath, latencyBucket };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@downtrace/protocol",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Downtrace ingestion protocol: JSON Schema, fixtures and generated TypeScript types",
5
5
  "type": "module",
6
6
  "exports": {