@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.16

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 (235) hide show
  1. package/README.md +111 -101
  2. package/app_meta.ts +56 -54
  3. package/config/config.ts +60 -57
  4. package/config/secrets.ts +45 -52
  5. package/config/value.ts +23 -26
  6. package/cron/mod.ts +28 -29
  7. package/dist/app_meta.d.ts +52 -50
  8. package/dist/app_meta.d.ts.map +1 -1
  9. package/dist/app_meta.js +2 -2
  10. package/dist/app_meta.js.map +1 -1
  11. package/dist/config/config.d.ts +58 -55
  12. package/dist/config/config.d.ts.map +1 -1
  13. package/dist/config/config.js +8 -9
  14. package/dist/config/config.js.map +1 -1
  15. package/dist/config/secrets.d.ts +45 -52
  16. package/dist/config/secrets.d.ts.map +1 -1
  17. package/dist/config/secrets.js +8 -9
  18. package/dist/config/secrets.js.map +1 -1
  19. package/dist/config/value.d.ts +20 -23
  20. package/dist/config/value.d.ts.map +1 -1
  21. package/dist/config/value.js +20 -23
  22. package/dist/config/value.js.map +1 -1
  23. package/dist/cron/mod.d.ts +26 -27
  24. package/dist/cron/mod.d.ts.map +1 -1
  25. package/dist/cron/mod.js +13 -14
  26. package/dist/cron/mod.js.map +1 -1
  27. package/dist/frontends/mod.d.ts +20 -19
  28. package/dist/frontends/mod.d.ts.map +1 -1
  29. package/dist/frontends/mod.js +20 -19
  30. package/dist/frontends/mod.js.map +1 -1
  31. package/dist/gateway/errors.d.ts +28 -30
  32. package/dist/gateway/errors.d.ts.map +1 -1
  33. package/dist/gateway/errors.js +29 -31
  34. package/dist/gateway/errors.js.map +1 -1
  35. package/dist/gateway/match.d.ts +54 -54
  36. package/dist/gateway/match.d.ts.map +1 -1
  37. package/dist/gateway/match.js +56 -56
  38. package/dist/gateway/match.js.map +1 -1
  39. package/dist/gateway/middleware.d.ts +62 -64
  40. package/dist/gateway/middleware.d.ts.map +1 -1
  41. package/dist/gateway/middleware.js +1 -1
  42. package/dist/gateway/middleware.js.map +1 -1
  43. package/dist/gateway/mod.d.ts +64 -67
  44. package/dist/gateway/mod.d.ts.map +1 -1
  45. package/dist/gateway/mod.js +72 -76
  46. package/dist/gateway/mod.js.map +1 -1
  47. package/dist/gateway/request.d.ts +138 -134
  48. package/dist/gateway/request.d.ts.map +1 -1
  49. package/dist/gateway/request.js +117 -108
  50. package/dist/gateway/request.js.map +1 -1
  51. package/dist/gateway/serve.d.ts +29 -34
  52. package/dist/gateway/serve.d.ts.map +1 -1
  53. package/dist/gateway/serve.js +51 -56
  54. package/dist/gateway/serve.js.map +1 -1
  55. package/dist/gateways/mod.d.ts +23 -21
  56. package/dist/gateways/mod.d.ts.map +1 -1
  57. package/dist/gateways/mod.js +25 -23
  58. package/dist/gateways/mod.js.map +1 -1
  59. package/dist/internal/runtime/napi/napi.cjs +1 -1
  60. package/dist/internal/runtime/napi/napi.d.cts +10 -3
  61. package/dist/internal/runtime/shutdown.d.ts +75 -57
  62. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  63. package/dist/internal/runtime/shutdown.js +88 -84
  64. package/dist/internal/runtime/shutdown.js.map +1 -1
  65. package/dist/log/logger.d.ts +43 -37
  66. package/dist/log/logger.d.ts.map +1 -1
  67. package/dist/log/logger.js +26 -25
  68. package/dist/log/logger.js.map +1 -1
  69. package/dist/metrics/mod.d.ts +133 -114
  70. package/dist/metrics/mod.d.ts.map +1 -1
  71. package/dist/metrics/mod.js +109 -101
  72. package/dist/metrics/mod.js.map +1 -1
  73. package/dist/otel.d.ts +6 -3
  74. package/dist/otel.d.ts.map +1 -1
  75. package/dist/otel.js +6 -3
  76. package/dist/otel.js.map +1 -1
  77. package/dist/pubsub/subscription.d.ts +88 -116
  78. package/dist/pubsub/subscription.d.ts.map +1 -1
  79. package/dist/pubsub/subscription.js +14 -17
  80. package/dist/pubsub/subscription.js.map +1 -1
  81. package/dist/pubsub/topic.d.ts +86 -113
  82. package/dist/pubsub/topic.d.ts.map +1 -1
  83. package/dist/pubsub/topic.js +68 -82
  84. package/dist/pubsub/topic.js.map +1 -1
  85. package/dist/reqctx/mod.d.ts +83 -86
  86. package/dist/reqctx/mod.d.ts.map +1 -1
  87. package/dist/reqctx/mod.js +39 -41
  88. package/dist/reqctx/mod.js.map +1 -1
  89. package/dist/services/index.d.ts +76 -75
  90. package/dist/services/index.d.ts.map +1 -1
  91. package/dist/services/index.js +73 -71
  92. package/dist/services/index.js.map +1 -1
  93. package/dist/shutdown/mod.d.ts +26 -25
  94. package/dist/shutdown/mod.d.ts.map +1 -1
  95. package/dist/shutdown/mod.js +26 -25
  96. package/dist/shutdown/mod.js.map +1 -1
  97. package/dist/storage/clickhouse/database.d.ts +113 -115
  98. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  99. package/dist/storage/clickhouse/database.js +65 -79
  100. package/dist/storage/clickhouse/database.js.map +1 -1
  101. package/dist/storage/clickhouse/errors.d.ts +25 -26
  102. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  103. package/dist/storage/clickhouse/errors.js +15 -17
  104. package/dist/storage/clickhouse/errors.js.map +1 -1
  105. package/dist/storage/clickhouse/mod.d.ts +10 -10
  106. package/dist/storage/clickhouse/mod.js +10 -10
  107. package/dist/storage/objects/bucket.d.ts +196 -225
  108. package/dist/storage/objects/bucket.d.ts.map +1 -1
  109. package/dist/storage/objects/bucket.js +71 -84
  110. package/dist/storage/objects/bucket.js.map +1 -1
  111. package/dist/storage/objects/error.d.ts +4 -4
  112. package/dist/storage/objects/error.js +4 -4
  113. package/dist/storage/postgres/database.d.ts +124 -149
  114. package/dist/storage/postgres/database.d.ts.map +1 -1
  115. package/dist/storage/postgres/database.js +98 -135
  116. package/dist/storage/postgres/database.js.map +1 -1
  117. package/dist/storage/postgres/errors.d.ts +42 -48
  118. package/dist/storage/postgres/errors.d.ts.map +1 -1
  119. package/dist/storage/postgres/errors.js +44 -51
  120. package/dist/storage/postgres/errors.js.map +1 -1
  121. package/dist/storage/postgres/interval.d.ts +19 -19
  122. package/dist/storage/postgres/interval.d.ts.map +1 -1
  123. package/dist/storage/postgres/interval.js +21 -21
  124. package/dist/storage/postgres/interval.js.map +1 -1
  125. package/dist/storage/redis/bitfield.d.ts +48 -23
  126. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  127. package/dist/storage/redis/bitfield.js +38 -19
  128. package/dist/storage/redis/bitfield.js.map +1 -1
  129. package/dist/storage/redis/command.d.ts +16 -12
  130. package/dist/storage/redis/command.d.ts.map +1 -1
  131. package/dist/storage/redis/command.js +16 -12
  132. package/dist/storage/redis/command.js.map +1 -1
  133. package/dist/storage/redis/commands.d.ts +99 -100
  134. package/dist/storage/redis/commands.d.ts.map +1 -1
  135. package/dist/storage/redis/commands.js +84 -85
  136. package/dist/storage/redis/commands.js.map +1 -1
  137. package/dist/storage/redis/database.d.ts +138 -122
  138. package/dist/storage/redis/database.d.ts.map +1 -1
  139. package/dist/storage/redis/database.js +120 -101
  140. package/dist/storage/redis/database.js.map +1 -1
  141. package/dist/storage/redis/mod.d.ts +52 -48
  142. package/dist/storage/redis/mod.d.ts.map +1 -1
  143. package/dist/storage/redis/mod.js +52 -48
  144. package/dist/storage/redis/mod.js.map +1 -1
  145. package/dist/storage/redis/options.d.ts +26 -24
  146. package/dist/storage/redis/options.d.ts.map +1 -1
  147. package/dist/storage/redis/options.js.map +1 -1
  148. package/dist/storage/redis/pubsub.d.ts +16 -16
  149. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  150. package/dist/storage/redis/pubsub.js +14 -14
  151. package/dist/storage/redis/pubsub.js.map +1 -1
  152. package/dist/storage/redis/reply.d.ts +80 -72
  153. package/dist/storage/redis/reply.d.ts.map +1 -1
  154. package/dist/storage/redis/reply.js +53 -46
  155. package/dist/storage/redis/reply.js.map +1 -1
  156. package/dist/storage/redis/scan.d.ts +4 -4
  157. package/dist/storage/redis/scan.d.ts.map +1 -1
  158. package/dist/storage/redis/scan.js +6 -6
  159. package/dist/storage/redis/scan.js.map +1 -1
  160. package/dist/storage/redis/script.d.ts +28 -21
  161. package/dist/storage/redis/script.d.ts.map +1 -1
  162. package/dist/storage/redis/script.js +29 -22
  163. package/dist/storage/redis/script.js.map +1 -1
  164. package/dist/storage/redis/target.d.ts +17 -1
  165. package/dist/storage/redis/target.d.ts.map +1 -1
  166. package/dist/storage/redis/target.js +30 -1
  167. package/dist/storage/redis/target.js.map +1 -1
  168. package/dist/storage/redis/wire.d.ts +6 -6
  169. package/dist/storage/redis/wire.d.ts.map +1 -1
  170. package/dist/storage/redis/wire.js +6 -6
  171. package/dist/storage/redis/wire.js.map +1 -1
  172. package/dist/testing/mod.d.ts +83 -88
  173. package/dist/testing/mod.d.ts.map +1 -1
  174. package/dist/testing/mod.js +75 -81
  175. package/dist/testing/mod.js.map +1 -1
  176. package/dist/testing/playwright.d.ts +28 -32
  177. package/dist/testing/playwright.d.ts.map +1 -1
  178. package/dist/testing/playwright.js +22 -27
  179. package/dist/testing/playwright.js.map +1 -1
  180. package/dist/testing/puppeteer.d.ts +11 -12
  181. package/dist/testing/puppeteer.d.ts.map +1 -1
  182. package/dist/testing/puppeteer.js +17 -18
  183. package/dist/testing/puppeteer.js.map +1 -1
  184. package/dist/testing/system.d.ts +72 -90
  185. package/dist/testing/system.d.ts.map +1 -1
  186. package/dist/testing/system.js +90 -107
  187. package/dist/testing/system.js.map +1 -1
  188. package/dist/tsconfig.build.tsbuildinfo +1 -1
  189. package/frontends/mod.test.ts +6 -2
  190. package/frontends/mod.ts +20 -19
  191. package/gateway/errors.ts +30 -32
  192. package/gateway/match.ts +61 -57
  193. package/gateway/middleware.ts +62 -64
  194. package/gateway/mod.ts +73 -76
  195. package/gateway/request.ts +143 -140
  196. package/gateway/serve.ts +58 -63
  197. package/gateways/mod.ts +25 -23
  198. package/internal/runtime/napi/napi.cjs +1 -1
  199. package/internal/runtime/napi/napi.d.cts +10 -3
  200. package/internal/runtime/shutdown.ts +113 -101
  201. package/log/logger.test.ts +8 -0
  202. package/log/logger.ts +48 -45
  203. package/metrics/mod.ts +138 -122
  204. package/otel.ts +6 -3
  205. package/package.json +1 -1
  206. package/pubsub/subscription.ts +93 -123
  207. package/pubsub/topic.ts +96 -130
  208. package/reqctx/mod.ts +83 -86
  209. package/services/index.ts +78 -78
  210. package/shutdown/mod.ts +26 -25
  211. package/storage/clickhouse/database.ts +115 -129
  212. package/storage/clickhouse/errors.ts +27 -29
  213. package/storage/clickhouse/mod.ts +10 -10
  214. package/storage/objects/bucket.ts +209 -239
  215. package/storage/objects/error.ts +4 -4
  216. package/storage/postgres/database.ts +131 -164
  217. package/storage/postgres/errors.ts +45 -52
  218. package/storage/postgres/interval.ts +21 -21
  219. package/storage/redis/bitfield.ts +51 -26
  220. package/storage/redis/command.ts +16 -12
  221. package/storage/redis/commands.ts +99 -100
  222. package/storage/redis/database.ts +145 -123
  223. package/storage/redis/mod.ts +52 -48
  224. package/storage/redis/options.ts +26 -24
  225. package/storage/redis/pubsub.ts +14 -14
  226. package/storage/redis/redis.test.ts +17 -2
  227. package/storage/redis/reply.ts +85 -77
  228. package/storage/redis/scan.ts +6 -6
  229. package/storage/redis/script.ts +29 -22
  230. package/storage/redis/target.ts +34 -1
  231. package/storage/redis/wire.ts +8 -8
  232. package/testing/mod.ts +99 -105
  233. package/testing/playwright.ts +32 -37
  234. package/testing/puppeteer.ts +22 -23
  235. package/testing/system.ts +117 -133
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Metrics: counters, up-down counters, histograms and gauges of what an app
3
- * does.
2
+ * Application metrics: counters, up-down counters, histograms, and gauges.
4
3
  *
5
- * A metric is declared at module level and used wherever the thing it
6
- * measures happens. Its JSDoc comment, else its `description` option, is
7
- * its description:
4
+ * Declare metrics at module level and record to them wherever the measured
5
+ * event occurs. A metric's JSDoc comment is used as its description (falling
6
+ * back to the `description` option):
8
7
  *
9
8
  * ```typescript
10
9
  * import { Counter, Histogram } from "@encore.dev/sdk/metrics";
@@ -19,28 +18,25 @@
19
18
  * uploadSize.record(2048);
20
19
  * ```
21
20
  *
22
- * Each is an instrument of the OpenTelemetry Metrics API
23
- * (`@opentelemetry/api`), of the meter `encore`, named as declared, a
24
- * service's own prefixed with its service's name (`orders_placed` of the
25
- * service `shop` is exported as `shop.orders_placed`), created when it is
26
- * first recorded to, recording through Encore's meter provider whatever the
27
- * global one is. Instruments of the API itself made with it
28
- * (`meterProvider().getMeter(…)`) are exported alongside: observable
29
- * instruments are made with it.
21
+ * Each metric is backed by an OpenTelemetry Metrics API (`@opentelemetry/api`)
22
+ * instrument on the `encore` meter, created lazily on first use and exported
23
+ * through Encore's meter provider regardless of any global provider.
24
+ * Service-scoped metrics are exported with their service name as a prefix
25
+ * (e.g. `orders_placed` in service `shop` is exported as `shop.orders_placed`).
26
+ * Custom OpenTelemetry instruments created via `meterProvider().getMeter(...)`
27
+ * — such as observable instruments — are exported alongside Encore metrics.
30
28
  *
31
- * A metric's `scope` option says who records to it: by default
32
- * (`"service"`) it belongs to the declaring service, which alone records to
33
- * it; a `"shared"` one is shared between services, each that records to it
34
- * tracked as using it; a `"global"` one is the whole app's, recorded to from
35
- * any code, untracked. It is written as a string literal, for Encore to
36
- * read:
29
+ * Use the `scope` option (as a string literal) to control which services can
30
+ * record to a metric:
31
+ * - `"service"` (default): owned by the declaring service alone.
32
+ * - `"shared"`: shared across services, with each recording service tracked.
33
+ * - `"global"`: app-wide and recordable from any code without usage tracking.
37
34
  *
38
35
  * ```typescript
39
36
  * export const signups = new Counter("signups", { scope: "shared" });
40
37
  * ```
41
38
  *
42
- * The `…Group` classes take a label type, whose fields are the attributes of
43
- * what is recorded:
39
+ * Use the `*Group` classes to attach typed labels as metric attributes:
44
40
  *
45
41
  * ```typescript
46
42
  * import { CounterGroup } from "@encore.dev/sdk/metrics";
@@ -55,12 +51,11 @@
55
51
  * requests.with({ method: "GET", status: 200 }).increment();
56
52
  * ```
57
53
  *
58
- * A shared or global metric is declared once in the app, as a shared
59
- * secret is. Other code records to it by importing the declaration, or,
60
- * from another service in another language, binds it by name with
61
- * `named`, which states the declaration's kind and labels and takes its
62
- * scope, unit, description and buckets. A bound metric is exported as
63
- * declared, never prefixed.
54
+ * Like shared secrets, a shared or global metric is declared once in the app.
55
+ * Other services record to it by importing the declaration, or (for example,
56
+ * across languages) by binding it by name with `named(...)`, which inherits the
57
+ * declaration's scope, unit, description, and buckets. Bound metrics are
58
+ * exported as declared without a service prefix:
64
59
  *
65
60
  * ```typescript
66
61
  * import { CounterGroup } from "@encore.dev/sdk/metrics";
@@ -68,22 +63,21 @@
68
63
  * const served = CounterGroup.named<Served>("greetings.served");
69
64
  * ```
70
65
  *
71
- * To hand a metric to other code, pass its `ref()`: it counts as recording
72
- * to it.
66
+ * To pass a metric handle to helper functions or other modules, pass `ref()`
67
+ * (calling `ref()` counts as recording to the metric).
73
68
  *
74
69
  * @module
75
70
  */
76
71
  import { hostedService, meter, meterProvider } from '../internal/runtime/meter.js';
77
72
  export { meterProvider };
78
- /** A metric's instrument, made when first recorded to. */
73
+ /** Lazily instantiated underlying OpenTelemetry instrument. */
79
74
  class Lazy {
80
75
  kind;
81
76
  name;
82
77
  opts;
83
78
  own;
84
79
  inst;
85
- /** `own`: the declaring service's alone, exported as
86
- * `<service>.<name>`. */
80
+ /** `own`: belongs solely to the declaring service and is exported as `<service>.<name>`. */
87
81
  constructor(kind, name, opts, own) {
88
82
  this.kind = kind;
89
83
  this.name = name;
@@ -116,20 +110,18 @@ class Lazy {
116
110
  }
117
111
  }
118
112
  }
119
- /** A `cls` recording to `inst` with `attrs`, attributes as a JSON object's
120
- * text, made without its constructor, which declares a metric. */
113
+ /** Creates an instance of `cls` bound to `inst` and pre-encoded `attrs` without invoking its declaring constructor. */
121
114
  function bind(cls, inst, attrs) {
122
115
  return Object.assign(Object.create(cls.prototype), {
123
116
  inst,
124
117
  attrs,
125
118
  });
126
119
  }
127
- /** Whether a metric declared with `opts` is the declaring service's own. */
120
+ /** Reports whether a metric declared with `opts` is service-scoped. */
128
121
  function own(opts) {
129
122
  return (opts?.scope ?? 'service') === 'service';
130
123
  }
131
- /** `labels` as attributes, a JSON object's text: keys in snake_case,
132
- * numbers floored. */
124
+ /** Encodes `labels` as a JSON attribute object with `snake_case` keys and floored numeric values. */
133
125
  function attributes(labels) {
134
126
  const out = {};
135
127
  for (const [key, value] of Object.entries(labels)) {
@@ -137,7 +129,7 @@ function attributes(labels) {
137
129
  }
138
130
  return JSON.stringify(out);
139
131
  }
140
- /** `statusCode` is `status_code`, `HTTPStatus` `http_status`. */
132
+ /** Converts camelCase/PascalCase to snake_case (e.g. `statusCode` -> `status_code`, `HTTPStatus` -> `http_status`). */
141
133
  function snakeCase(s) {
142
134
  return s
143
135
  .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
@@ -149,76 +141,79 @@ function snakeCase(s) {
149
141
  // `named` binds a shared or global metric declared elsewhere, by another
150
142
  // service, possibly in another language: its kind and labels are the
151
143
  // declaration's, and so are its scope, unit, description and buckets.
152
- /** A number that only goes up: how many times something happened, or how
153
- * much of something there has been. By default it belongs to the declaring
154
- * service, which alone records to it. */
144
+ /**
145
+ * A monotonically increasing metric for counting occurrences or totals.
146
+ * Scoped to the declaring service by default.
147
+ */
155
148
  export class Counter {
156
149
  inst;
157
150
  attrs;
158
- /** Declares the counter `name`. */
151
+ /** Declares a counter named `name`. */
159
152
  constructor(name, opts) {
160
153
  this.inst = new Lazy('counter', name, opts, own(opts));
161
154
  }
162
- /** Binds the shared or global counter `name`, declared elsewhere. */
155
+ /** Binds to a shared or global counter declared elsewhere. */
163
156
  static named(name) {
164
157
  return bind(Counter, new Lazy('counter', name, undefined, false));
165
158
  }
166
- /** Adds one. */
159
+ /** Increments the counter by 1. */
167
160
  increment() {
168
161
  this.inst.get().recordEncoded(1, this.attrs);
169
162
  }
170
- /** Adds `n`. A counter does not go down: an amount below zero is
171
- * ignored. */
163
+ /** Adds `n` to the counter. Negative values are ignored. */
172
164
  add(n) {
173
165
  this.inst.get().recordEncoded(n, this.attrs);
174
166
  }
175
- /** The counter itself, to hand to other code. */
167
+ /** Returns this counter handle so it can be passed to other code. */
176
168
  ref() {
177
169
  return this;
178
170
  }
179
171
  }
180
- /** A number that goes up and down by what is added to it: how many
181
- * requests are in flight, how many jobs are queued. By default it belongs
182
- * to the declaring service, which alone records to it. */
172
+ /**
173
+ * A metric that can increase or decrease by arbitrary deltas, such as
174
+ * in-flight requests or queued jobs. Scoped to the declaring service by
175
+ * default.
176
+ */
183
177
  export class UpDownCounter {
184
178
  inst;
185
179
  attrs;
186
- /** Declares the up-down counter `name`. */
180
+ /** Declares an up-down counter named `name`. */
187
181
  constructor(name, opts) {
188
182
  this.inst = new Lazy('upDownCounter', name, opts, own(opts));
189
183
  }
190
- /** Binds the shared or global up-down counter `name`, declared elsewhere. */
184
+ /** Binds to a shared or global up-down counter declared elsewhere. */
191
185
  static named(name) {
192
186
  return bind(UpDownCounter, new Lazy('upDownCounter', name, undefined, false));
193
187
  }
194
- /** Adds `n`, which may be below zero. */
188
+ /** Adds `n` (positive or negative) to the counter. */
195
189
  add(n) {
196
190
  this.inst.get().recordEncoded(n, this.attrs);
197
191
  }
198
- /** Adds one. */
192
+ /** Increments the counter by 1. */
199
193
  increment() {
200
194
  this.inst.get().recordEncoded(1, this.attrs);
201
195
  }
202
- /** Takes away one. */
196
+ /** Decrements the counter by 1. */
203
197
  decrement() {
204
198
  this.inst.get().recordEncoded(-1, this.attrs);
205
199
  }
206
- /** The up-down counter itself, to hand to other code. */
200
+ /** Returns this up-down counter handle so it can be passed to other code. */
207
201
  ref() {
208
202
  return this;
209
203
  }
210
204
  }
211
- /** A number that is what it was last set to: what something is right now.
212
- * By default it belongs to the declaring service, which alone records to
213
- * it. */
205
+ /**
206
+ * A metric that records the latest instantaneous value of something. Scoped to
207
+ * the declaring service by default.
208
+ */
214
209
  export class Gauge {
215
210
  inst;
216
211
  attrs;
217
- /** Declares the gauge `name`. */
212
+ /** Declares a gauge named `name`. */
218
213
  constructor(name, opts) {
219
214
  this.inst = new Lazy('gauge', name, opts, own(opts));
220
215
  }
221
- /** Binds the shared or global gauge `name`, declared elsewhere. */
216
+ /** Binds to a shared or global gauge declared elsewhere. */
222
217
  static named(name) {
223
218
  return bind(Gauge, new Lazy('gauge', name, undefined, false));
224
219
  }
@@ -226,30 +221,31 @@ export class Gauge {
226
221
  set(value) {
227
222
  this.inst.get().recordEncoded(value, this.attrs);
228
223
  }
229
- /** The gauge itself, to hand to other code. */
224
+ /** Returns this gauge handle so it can be passed to other code. */
230
225
  ref() {
231
226
  return this;
232
227
  }
233
228
  }
234
- /** How what is recorded is distributed: how long requests take, how large
235
- * uploads are. By default it belongs to the declaring service, which alone
236
- * records to it. */
229
+ /**
230
+ * A metric that records the distribution of values, such as request latencies
231
+ * or upload sizes. Scoped to the declaring service by default.
232
+ */
237
233
  export class Histogram {
238
234
  inst;
239
235
  attrs;
240
- /** Declares the histogram `name`. */
236
+ /** Declares a histogram named `name`. */
241
237
  constructor(name, opts) {
242
238
  this.inst = new Lazy('histogram', name, opts, own(opts));
243
239
  }
244
- /** Binds the shared or global histogram `name`, declared elsewhere. */
240
+ /** Binds to a shared or global histogram declared elsewhere. */
245
241
  static named(name) {
246
242
  return bind(Histogram, new Lazy('histogram', name, undefined, false));
247
243
  }
248
- /** Records `value`. */
244
+ /** Records `value` in the histogram. */
249
245
  record(value) {
250
246
  this.inst.get().recordEncoded(value, this.attrs);
251
247
  }
252
- /** The histogram itself, to hand to other code. */
248
+ /** Returns this histogram handle so it can be passed to other code. */
253
249
  ref() {
254
250
  return this;
255
251
  }
@@ -258,94 +254,106 @@ export class Histogram {
258
254
  // cannot infer the name's literal type beside an explicit type argument, so
259
255
  // the name is a plain `string`, and the parser's check is the only one it
260
256
  // gets.
261
- /** A counter for each combination of the labels `L`. By default it
262
- * belongs to the declaring service, which alone records to it. */
257
+ /**
258
+ * A labeled group of {@link Counter} metrics keyed by `L`. Scoped to the
259
+ * declaring service by default.
260
+ */
263
261
  export class CounterGroup {
264
262
  inst;
265
- /** Declares the counter group `name`. */
263
+ /** Declares a counter group named `name`. */
266
264
  constructor(name, opts) {
267
265
  this.inst = new Lazy('counter', name, opts, own(opts));
268
266
  }
269
- /** Binds the shared or global counter group `name`, declared elsewhere,
270
- * whose labels are `L`. */
267
+ /** Binds to a shared or global counter group declared elsewhere with labels `L`. */
271
268
  static named(name) {
272
269
  return bind(CounterGroup, new Lazy('counter', name, undefined, false));
273
270
  }
274
- /** The counter for `labels`. Worth keeping where it is used often:
275
- * making it encodes the labels' attributes. */
271
+ /**
272
+ * Returns a {@link Counter} bound to `labels`. Cache the returned handle on
273
+ * hot paths to avoid re-encoding the label attributes.
274
+ */
276
275
  with(labels) {
277
276
  return bind(Counter, this.inst, attributes(labels));
278
277
  }
279
- /** The group itself, to hand to other code. */
278
+ /** Returns this metric group handle so it can be passed to other code. */
280
279
  ref() {
281
280
  return this;
282
281
  }
283
282
  }
284
- /** An up-down counter for each combination of the labels `L`. By default it
285
- * belongs to the declaring service, which alone records to it. */
283
+ /**
284
+ * A labeled group of {@link UpDownCounter} metrics keyed by `L`. Scoped to the
285
+ * declaring service by default.
286
+ */
286
287
  export class UpDownCounterGroup {
287
288
  inst;
288
- /** Declares the up-down counter group `name`. */
289
+ /** Declares an up-down counter group named `name`. */
289
290
  constructor(name, opts) {
290
291
  this.inst = new Lazy('upDownCounter', name, opts, own(opts));
291
292
  }
292
- /** Binds the shared or global up-down counter group `name`, declared elsewhere,
293
- * whose labels are `L`. */
293
+ /** Binds to a shared or global up-down counter group declared elsewhere with labels `L`. */
294
294
  static named(name) {
295
295
  return bind(UpDownCounterGroup, new Lazy('upDownCounter', name, undefined, false));
296
296
  }
297
- /** The up-down counter for `labels`. Worth keeping where it is used often:
298
- * making it encodes the labels' attributes. */
297
+ /**
298
+ * Returns an {@link UpDownCounter} bound to `labels`. Cache the returned
299
+ * handle on hot paths to avoid re-encoding the label attributes.
300
+ */
299
301
  with(labels) {
300
302
  return bind(UpDownCounter, this.inst, attributes(labels));
301
303
  }
302
- /** The group itself, to hand to other code. */
304
+ /** Returns this metric group handle so it can be passed to other code. */
303
305
  ref() {
304
306
  return this;
305
307
  }
306
308
  }
307
- /** A gauge for each combination of the labels `L`. By default it
308
- * belongs to the declaring service, which alone records to it. */
309
+ /**
310
+ * A labeled group of {@link Gauge} metrics keyed by `L`. Scoped to the
311
+ * declaring service by default.
312
+ */
309
313
  export class GaugeGroup {
310
314
  inst;
311
- /** Declares the gauge group `name`. */
315
+ /** Declares a gauge group named `name`. */
312
316
  constructor(name, opts) {
313
317
  this.inst = new Lazy('gauge', name, opts, own(opts));
314
318
  }
315
- /** Binds the shared or global gauge group `name`, declared elsewhere,
316
- * whose labels are `L`. */
319
+ /** Binds to a shared or global gauge group declared elsewhere with labels `L`. */
317
320
  static named(name) {
318
321
  return bind(GaugeGroup, new Lazy('gauge', name, undefined, false));
319
322
  }
320
- /** The gauge for `labels`. Worth keeping where it is used often:
321
- * making it encodes the labels' attributes. */
323
+ /**
324
+ * Returns a {@link Gauge} bound to `labels`. Cache the returned handle on
325
+ * hot paths to avoid re-encoding the label attributes.
326
+ */
322
327
  with(labels) {
323
328
  return bind(Gauge, this.inst, attributes(labels));
324
329
  }
325
- /** The group itself, to hand to other code. */
330
+ /** Returns this metric group handle so it can be passed to other code. */
326
331
  ref() {
327
332
  return this;
328
333
  }
329
334
  }
330
- /** A histogram for each combination of the labels `L`. By default it
331
- * belongs to the declaring service, which alone records to it. */
335
+ /**
336
+ * A labeled group of {@link Histogram} metrics keyed by `L`. Scoped to the
337
+ * declaring service by default.
338
+ */
332
339
  export class HistogramGroup {
333
340
  inst;
334
- /** Declares the histogram group `name`. */
341
+ /** Declares a histogram group named `name`. */
335
342
  constructor(name, opts) {
336
343
  this.inst = new Lazy('histogram', name, opts, own(opts));
337
344
  }
338
- /** Binds the shared or global histogram group `name`, declared elsewhere,
339
- * whose labels are `L`. */
345
+ /** Binds to a shared or global histogram group declared elsewhere with labels `L`. */
340
346
  static named(name) {
341
347
  return bind(HistogramGroup, new Lazy('histogram', name, undefined, false));
342
348
  }
343
- /** The histogram for `labels`. Worth keeping where it is used often:
344
- * making it encodes the labels' attributes. */
349
+ /**
350
+ * Returns a {@link Histogram} bound to `labels`. Cache the returned handle
351
+ * on hot paths to avoid re-encoding the label attributes.
352
+ */
345
353
  with(labels) {
346
354
  return bind(Histogram, this.inst, attributes(labels));
347
355
  }
348
- /** The group itself, to hand to other code. */
356
+ /** Returns this metric group handle so it can be passed to other code. */
349
357
  ref() {
350
358
  return this;
351
359
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../metrics/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAGH,OAAO,EAAC,aAAa,EAAE,KAAK,EAAE,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAG9E,OAAO,EAAC,aAAa,EAAC,CAAC;AAyCvB,0DAA0D;AAC1D,MAAM,IAAI;IAMW;IACA;IACA;IACA;IARX,IAAI,CAAY;IAExB;6BACyB;IACzB,YACmB,IAAU,EACV,IAAY,EACZ,IAAkC,EAClC,GAAY;QAHZ,SAAI,GAAJ,IAAI,CAAM;QACV,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAA8B;QAClC,QAAG,GAAH,GAAG,CAAS;IAC5B,CAAC;IAEJ,GAAG;QACD,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEO,IAAI;QACV,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,I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ACH,IAAI,CAAC,MAAS;QACZ,OAAO,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,0EAA0E;IAC1E,GAAG;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,cAAc;IACR,IAAI,CAAO;IAE5B,+CAA+C;IAC/C,YAAY,IAAY,EAAE,IAAuB;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,sFAAsF;IACtF,MAAM,CAAC,KAAK,CAAsB,IAAY;QAC5C,OAAO,IAAI,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,MAAS;QACZ,OAAO,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,0EAA0E;IAC1E,GAAG;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
package/dist/otel.d.ts CHANGED
@@ -3,8 +3,11 @@ import { meterProvider } from './internal/runtime/meter.js';
3
3
  export { meterProvider };
4
4
  export type { MeterProvider } from './internal/otel/meter.js';
5
5
  export type { TracerProvider };
6
- /** Encore's tracer provider, recording into the runtime's telemetry
7
- * pipeline. Encore records its own spans without it; pass it to an
8
- * instrumentation, or register it with `trace.setGlobalTracerProvider`. */
6
+ /**
7
+ * Returns Encore's OpenTelemetry `TracerProvider`, which records spans into the
8
+ * runtime's telemetry pipeline. Encore records its own spans automatically;
9
+ * pass this provider to third-party instrumentations or register it with
10
+ * `trace.setGlobalTracerProvider`.
11
+ */
9
12
  export declare function tracerProvider(): TracerProvider;
10
13
  //# sourceMappingURL=otel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAC,aAAa,EAAC,CAAC;AACvB,YAAY,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAC,cAAc,EAAC,CAAC;AAI7B;;2EAE2E;AAC3E,wBAAgB,cAAc,IAAI,cAAc,CAG/C"}
1
+ {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAC,aAAa,EAAC,CAAC;AACvB,YAAY,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAC,cAAc,EAAC,CAAC;AAI7B;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAG/C"}
package/dist/otel.js CHANGED
@@ -3,9 +3,12 @@ import { meterProvider } from './internal/runtime/meter.js';
3
3
  import { RT } from './internal/runtime/mod.js';
4
4
  export { meterProvider };
5
5
  let tracers;
6
- /** Encore's tracer provider, recording into the runtime's telemetry
7
- * pipeline. Encore records its own spans without it; pass it to an
8
- * instrumentation, or register it with `trace.setGlobalTracerProvider`. */
6
+ /**
7
+ * Returns Encore's OpenTelemetry `TracerProvider`, which records spans into the
8
+ * runtime's telemetry pipeline. Encore records its own spans automatically;
9
+ * pass this provider to third-party instrumentations or register it with
10
+ * `trace.setGlobalTracerProvider`.
11
+ */
9
12
  export function tracerProvider() {
10
13
  tracers ??= new TracerProvider(RT.telemetry());
11
14
  return tracers;
package/dist/otel.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"otel.js","sourceRoot":"","sources":["../otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,EAAE,EAAC,MAAM,wBAAwB,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAC,CAAC;AAIvB,IAAI,OAAmC,CAAC;AAExC;;2EAE2E;AAC3E,MAAM,UAAU,cAAc;IAC5B,OAAO,KAAK,IAAI,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"otel.js","sourceRoot":"","sources":["../otel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,EAAE,EAAC,MAAM,wBAAwB,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAC,CAAC;AAIvB,IAAI,OAAmC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,KAAK,IAAI,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC;AACjB,CAAC"}