@encore.dev/sdk 0.0.0 → 2.0.0-beta.5

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 (250) hide show
  1. package/LICENSE +362 -0
  2. package/README.md +122 -2
  3. package/app_meta.test.ts +134 -0
  4. package/app_meta.ts +186 -0
  5. package/config/config.test.ts +381 -0
  6. package/config/config.ts +178 -0
  7. package/config/mod.ts +14 -0
  8. package/config/secrets.ts +147 -0
  9. package/config/value.ts +243 -0
  10. package/cron/mod.ts +23 -0
  11. package/dist/app_meta.d.ts +93 -0
  12. package/dist/app_meta.js +65 -0
  13. package/dist/app_meta.js.map +1 -0
  14. package/dist/config/config.d.ts +105 -0
  15. package/dist/config/config.js +87 -0
  16. package/dist/config/config.js.map +1 -0
  17. package/dist/config/mod.d.ts +4 -0
  18. package/dist/config/mod.js +3 -0
  19. package/dist/config/mod.js.map +1 -0
  20. package/dist/config/secrets.d.ts +92 -0
  21. package/dist/config/secrets.js +80 -0
  22. package/dist/config/secrets.js.map +1 -0
  23. package/dist/config/value.d.ts +51 -0
  24. package/dist/config/value.js +178 -0
  25. package/dist/config/value.js.map +1 -0
  26. package/dist/cron/mod.d.ts +22 -0
  27. package/dist/cron/mod.js +9 -0
  28. package/dist/cron/mod.js.map +1 -0
  29. package/dist/internal/otel/backend.d.ts +50 -0
  30. package/dist/internal/otel/backend.js +2 -0
  31. package/dist/internal/otel/backend.js.map +1 -0
  32. package/dist/internal/otel/context.d.ts +10 -0
  33. package/dist/internal/otel/context.js +34 -0
  34. package/dist/internal/otel/context.js.map +1 -0
  35. package/dist/internal/otel/context_manager.d.ts +22 -0
  36. package/dist/internal/otel/context_manager.js +120 -0
  37. package/dist/internal/otel/context_manager.js.map +1 -0
  38. package/dist/internal/otel/encode.d.ts +112 -0
  39. package/dist/internal/otel/encode.js +290 -0
  40. package/dist/internal/otel/encode.js.map +1 -0
  41. package/dist/internal/otel/index.d.ts +9 -0
  42. package/dist/internal/otel/index.js +9 -0
  43. package/dist/internal/otel/index.js.map +1 -0
  44. package/dist/internal/otel/meter.d.ts +73 -0
  45. package/dist/internal/otel/meter.js +265 -0
  46. package/dist/internal/otel/meter.js.map +1 -0
  47. package/dist/internal/otel/propagator.d.ts +14 -0
  48. package/dist/internal/otel/propagator.js +61 -0
  49. package/dist/internal/otel/propagator.js.map +1 -0
  50. package/dist/internal/otel/provider.d.ts +9 -0
  51. package/dist/internal/otel/provider.js +19 -0
  52. package/dist/internal/otel/provider.js.map +1 -0
  53. package/dist/internal/otel/request_context.d.ts +11 -0
  54. package/dist/internal/otel/request_context.js +20 -0
  55. package/dist/internal/otel/request_context.js.map +1 -0
  56. package/dist/internal/otel/span.d.ts +61 -0
  57. package/dist/internal/otel/span.js +206 -0
  58. package/dist/internal/otel/span.js.map +1 -0
  59. package/dist/internal/otel/tracer.d.ts +15 -0
  60. package/dist/internal/otel/tracer.js +65 -0
  61. package/dist/internal/otel/tracer.js.map +1 -0
  62. package/dist/internal/reqtrack/mod.d.ts +6 -0
  63. package/dist/internal/reqtrack/mod.js +28 -0
  64. package/dist/internal/reqtrack/mod.js.map +1 -0
  65. package/dist/internal/runtime/meter.d.ts +11 -0
  66. package/dist/internal/runtime/meter.js +22 -0
  67. package/dist/internal/runtime/meter.js.map +1 -0
  68. package/dist/internal/runtime/mod.d.ts +12 -0
  69. package/dist/internal/runtime/mod.js +28 -0
  70. package/dist/internal/runtime/mod.js.map +1 -0
  71. package/dist/internal/runtime/napi/napi.cjs +122 -0
  72. package/dist/internal/runtime/napi/napi.d.cts +601 -0
  73. package/dist/internal/runtime/shutdown.d.ts +13 -0
  74. package/dist/internal/runtime/shutdown.js +56 -0
  75. package/dist/internal/runtime/shutdown.js.map +1 -0
  76. package/dist/internal/utils/constraints.d.ts +9 -0
  77. package/dist/internal/utils/constraints.js +2 -0
  78. package/dist/internal/utils/constraints.js.map +1 -0
  79. package/dist/log/index.d.ts +39 -0
  80. package/dist/log/index.js +44 -0
  81. package/dist/log/index.js.map +1 -0
  82. package/dist/log/logger.d.ts +123 -0
  83. package/dist/log/logger.js +203 -0
  84. package/dist/log/logger.js.map +1 -0
  85. package/dist/log/runtime.d.ts +19 -0
  86. package/dist/log/runtime.js +22 -0
  87. package/dist/log/runtime.js.map +1 -0
  88. package/dist/log/stderr.d.ts +9 -0
  89. package/dist/log/stderr.js +25 -0
  90. package/dist/log/stderr.js.map +1 -0
  91. package/dist/metrics/mod.d.ts +315 -0
  92. package/dist/metrics/mod.js +488 -0
  93. package/dist/metrics/mod.js.map +1 -0
  94. package/dist/mod.d.ts +6 -0
  95. package/dist/mod.js +4 -0
  96. package/dist/mod.js.map +1 -0
  97. package/dist/otel.d.ts +9 -0
  98. package/dist/otel.js +13 -0
  99. package/dist/otel.js.map +1 -0
  100. package/dist/pubsub/encoding.d.ts +3 -0
  101. package/dist/pubsub/encoding.js +10 -0
  102. package/dist/pubsub/encoding.js.map +1 -0
  103. package/dist/pubsub/mod.d.ts +6 -0
  104. package/dist/pubsub/mod.js +3 -0
  105. package/dist/pubsub/mod.js.map +1 -0
  106. package/dist/pubsub/refs.d.ts +12 -0
  107. package/dist/pubsub/refs.js +11 -0
  108. package/dist/pubsub/refs.js.map +1 -0
  109. package/dist/pubsub/subscription.d.ts +128 -0
  110. package/dist/pubsub/subscription.js +39 -0
  111. package/dist/pubsub/subscription.js.map +1 -0
  112. package/dist/pubsub/topic.d.ts +148 -0
  113. package/dist/pubsub/topic.js +164 -0
  114. package/dist/pubsub/topic.js.map +1 -0
  115. package/dist/req_meta.d.ts +47 -0
  116. package/dist/req_meta.js +26 -0
  117. package/dist/req_meta.js.map +1 -0
  118. package/dist/services/index.d.ts +12 -0
  119. package/dist/services/index.js +22 -0
  120. package/dist/services/index.js.map +1 -0
  121. package/dist/shutdown/mod.d.ts +23 -0
  122. package/dist/shutdown/mod.js +24 -0
  123. package/dist/shutdown/mod.js.map +1 -0
  124. package/dist/storage/objects/bucket.d.ts +216 -0
  125. package/dist/storage/objects/bucket.js +123 -0
  126. package/dist/storage/objects/bucket.js.map +1 -0
  127. package/dist/storage/objects/error.d.ts +14 -0
  128. package/dist/storage/objects/error.js +81 -0
  129. package/dist/storage/objects/error.js.map +1 -0
  130. package/dist/storage/objects/mod.d.ts +4 -0
  131. package/dist/storage/objects/mod.js +3 -0
  132. package/dist/storage/objects/mod.js.map +1 -0
  133. package/dist/storage/objects/refs.d.ts +31 -0
  134. package/dist/storage/objects/refs.js +20 -0
  135. package/dist/storage/objects/refs.js.map +1 -0
  136. package/dist/storage/postgres/database.d.ts +295 -0
  137. package/dist/storage/postgres/database.js +378 -0
  138. package/dist/storage/postgres/database.js.map +1 -0
  139. package/dist/storage/postgres/mod.d.ts +2 -0
  140. package/dist/storage/postgres/mod.js +2 -0
  141. package/dist/storage/postgres/mod.js.map +1 -0
  142. package/dist/storage/redis/commands.d.ts +573 -0
  143. package/dist/storage/redis/commands.js +637 -0
  144. package/dist/storage/redis/commands.js.map +1 -0
  145. package/dist/storage/redis/database.d.ts +302 -0
  146. package/dist/storage/redis/database.js +336 -0
  147. package/dist/storage/redis/database.js.map +1 -0
  148. package/dist/storage/redis/mod.d.ts +88 -0
  149. package/dist/storage/redis/mod.js +84 -0
  150. package/dist/storage/redis/mod.js.map +1 -0
  151. package/dist/storage/redis/native.d.ts +8 -0
  152. package/dist/storage/redis/native.js +11 -0
  153. package/dist/storage/redis/native.js.map +1 -0
  154. package/dist/storage/redis/options.d.ts +89 -0
  155. package/dist/storage/redis/options.js +53 -0
  156. package/dist/storage/redis/options.js.map +1 -0
  157. package/dist/storage/redis/pubsub.d.ts +53 -0
  158. package/dist/storage/redis/pubsub.js +88 -0
  159. package/dist/storage/redis/pubsub.js.map +1 -0
  160. package/dist/storage/redis/reply.d.ts +256 -0
  161. package/dist/storage/redis/reply.js +572 -0
  162. package/dist/storage/redis/reply.js.map +1 -0
  163. package/dist/storage/redis/scan.d.ts +11 -0
  164. package/dist/storage/redis/scan.js +76 -0
  165. package/dist/storage/redis/scan.js.map +1 -0
  166. package/dist/storage/redis/script.d.ts +91 -0
  167. package/dist/storage/redis/script.js +143 -0
  168. package/dist/storage/redis/script.js.map +1 -0
  169. package/dist/storage/redis/target.d.ts +47 -0
  170. package/dist/storage/redis/target.js +82 -0
  171. package/dist/storage/redis/target.js.map +1 -0
  172. package/dist/storage/redis/wire.d.ts +105 -0
  173. package/dist/storage/redis/wire.js +333 -0
  174. package/dist/storage/redis/wire.js.map +1 -0
  175. package/dist/tsconfig.build.tsbuildinfo +1 -0
  176. package/dist/types/mod.d.ts +42 -0
  177. package/dist/types/mod.js +65 -0
  178. package/dist/types/mod.js.map +1 -0
  179. package/internal/otel/backend.ts +60 -0
  180. package/internal/otel/context.test.ts +70 -0
  181. package/internal/otel/context.ts +48 -0
  182. package/internal/otel/context_manager.test.ts +154 -0
  183. package/internal/otel/context_manager.ts +141 -0
  184. package/internal/otel/encode.test.ts +266 -0
  185. package/internal/otel/encode.ts +408 -0
  186. package/internal/otel/index.ts +20 -0
  187. package/internal/otel/meter.test.ts +231 -0
  188. package/internal/otel/meter.ts +332 -0
  189. package/internal/otel/propagator.test.ts +105 -0
  190. package/internal/otel/propagator.ts +68 -0
  191. package/internal/otel/provider.ts +23 -0
  192. package/internal/otel/request_context.ts +32 -0
  193. package/internal/otel/span.ts +252 -0
  194. package/internal/otel/tracer.test.ts +352 -0
  195. package/internal/otel/tracer.ts +104 -0
  196. package/internal/reqtrack/mod.ts +39 -0
  197. package/internal/runtime/meter.ts +26 -0
  198. package/internal/runtime/mod.ts +41 -0
  199. package/internal/runtime/napi/napi.cjs +122 -0
  200. package/internal/runtime/napi/napi.d.cts +601 -0
  201. package/internal/runtime/shutdown.test.ts +248 -0
  202. package/internal/runtime/shutdown.ts +64 -0
  203. package/internal/utils/constraints.ts +12 -0
  204. package/log/index.ts +107 -0
  205. package/log/logger.test.ts +194 -0
  206. package/log/logger.ts +308 -0
  207. package/log/runtime.test.ts +65 -0
  208. package/log/runtime.ts +40 -0
  209. package/log/stderr.test.ts +23 -0
  210. package/log/stderr.ts +24 -0
  211. package/metrics/export.test.ts +337 -0
  212. package/metrics/mod.test.ts +180 -0
  213. package/metrics/mod.ts +619 -0
  214. package/mod.ts +22 -0
  215. package/otel.test.ts +84 -0
  216. package/otel.ts +17 -0
  217. package/package.json +121 -5
  218. package/pubsub/encoding.ts +8 -0
  219. package/pubsub/mod.ts +14 -0
  220. package/pubsub/pubsub.test.ts +186 -0
  221. package/pubsub/refs.ts +22 -0
  222. package/pubsub/subscription.ts +180 -0
  223. package/pubsub/topic.test.ts +121 -0
  224. package/pubsub/topic.ts +212 -0
  225. package/req_meta.ts +75 -0
  226. package/services/index.test.ts +30 -0
  227. package/services/index.ts +21 -0
  228. package/shutdown/mod.ts +24 -0
  229. package/storage/objects/bucket.ts +338 -0
  230. package/storage/objects/error.ts +94 -0
  231. package/storage/objects/mod.ts +35 -0
  232. package/storage/objects/refs.ts +69 -0
  233. package/storage/postgres/database.integration.test.ts +175 -0
  234. package/storage/postgres/database.test.ts +241 -0
  235. package/storage/postgres/database.ts +497 -0
  236. package/storage/postgres/mod.ts +15 -0
  237. package/storage/redis/commands.ts +1221 -0
  238. package/storage/redis/database.ts +466 -0
  239. package/storage/redis/mod.ts +135 -0
  240. package/storage/redis/native.ts +11 -0
  241. package/storage/redis/options.ts +119 -0
  242. package/storage/redis/pubsub.ts +92 -0
  243. package/storage/redis/redis.test.ts +706 -0
  244. package/storage/redis/reply.ts +705 -0
  245. package/storage/redis/runtime.test.ts +233 -0
  246. package/storage/redis/scan.ts +125 -0
  247. package/storage/redis/script.ts +162 -0
  248. package/storage/redis/target.ts +131 -0
  249. package/storage/redis/wire.ts +369 -0
  250. package/types/mod.ts +92 -0
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Metrics: counters, up-down counters, histograms and gauges of what an app
3
+ * does.
4
+ *
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:
8
+ *
9
+ * ```typescript
10
+ * import { Counter, Histogram } from "@encore.dev/sdk/metrics";
11
+ *
12
+ * export const ordersPlaced = new Counter("orders_placed", { unit: "{order}" });
13
+ * export const uploadSize = new Histogram("upload_size", {
14
+ * unit: "By",
15
+ * buckets: [1024, 65536, 1048576]
16
+ * });
17
+ *
18
+ * ordersPlaced.increment();
19
+ * uploadSize.record(2048);
20
+ * ```
21
+ *
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.
30
+ *
31
+ * Which class declares a metric says who records to it: a `Counter`
32
+ * belongs to the declaring service, which alone records to it; a
33
+ * `SharedCounter` is shared between services, each that records to it
34
+ * tracked as using it; a `GlobalCounter` is the whole app's, recorded to
35
+ * from any code, untracked. `SharedCounter` and `GlobalCounter` extend
36
+ * `Counter`, so code taking a `Counter` takes one of any scope. The
37
+ * `…Group` classes take a label type, whose fields are the attributes of
38
+ * what is recorded:
39
+ *
40
+ * ```typescript
41
+ * import { CounterGroup } from "@encore.dev/sdk/metrics";
42
+ *
43
+ * interface Outcome {
44
+ * method: string;
45
+ * status: number;
46
+ * }
47
+ *
48
+ * export const requests = new CounterGroup<Outcome>("requests_handled");
49
+ *
50
+ * requests.with({ method: "GET", status: 200 }).increment();
51
+ * ```
52
+ *
53
+ * A shared or global metric is declared once in the app, as a shared
54
+ * secret is. Other code records to it by importing the declaration, or,
55
+ * from another service in another language, binds it by name with
56
+ * `named`, which states the declaration's kind and labels and takes its
57
+ * scope, unit, description and buckets. Every scope's class has it and
58
+ * binds alike: `SharedCounter.named` is `Counter.named`. A bound metric is
59
+ * exported as declared, never prefixed.
60
+ *
61
+ * ```typescript
62
+ * import { CounterGroup } from "@encore.dev/sdk/metrics";
63
+ *
64
+ * const served = CounterGroup.named<Served>("greetings.served");
65
+ * ```
66
+ *
67
+ * To hand a metric to other code, pass its `ref()`: it counts as recording
68
+ * to it.
69
+ *
70
+ * @module
71
+ */
72
+ import { meterProvider } from '../internal/runtime/meter.js';
73
+ import { StringLiteral } from '../internal/utils/constraints.js';
74
+ export { meterProvider };
75
+ export type { MeterProvider } from '../internal/otel/meter.js';
76
+ /** The options every metric is declared with. */
77
+ export interface MetricOptions {
78
+ /** What the metric measures in, as exported: `"s"`, `"By"`,
79
+ * `"{request}"` ([UCUM](https://ucum.org/ucum)). */
80
+ unit?: string;
81
+ /** What the metric measures, for one without a JSDoc comment. */
82
+ description?: string;
83
+ }
84
+ /** The options a histogram is declared with. */
85
+ export interface HistogramOptions extends MetricOptions {
86
+ /** The upper bounds of the buckets, increasing: what is recorded is
87
+ * counted in the first it is no greater than, or one past the last.
88
+ * Without them, the OpenTelemetry defaults. */
89
+ buckets?: number[];
90
+ }
91
+ /** A metric group's labels: an interface or type whose fields are strings,
92
+ * numbers or booleans. Each field is a label, named as the field in
93
+ * snake_case. A number is recorded as an integer, its value floored
94
+ * (`Math.floor`): `200.7` is `200`. */
95
+ export type Labels<L> = {
96
+ [K in keyof L]: string | number | boolean;
97
+ };
98
+ /** A number that only goes up: how many times something happened, or how
99
+ * much of something there has been. Belongs to the declaring service: only it records to it. */
100
+ export declare class Counter {
101
+ private readonly inst;
102
+ private readonly attrs?;
103
+ /** Declares the counter `name`. */
104
+ constructor(name: string, opts?: MetricOptions);
105
+ /** Binds the shared or global counter `name`, declared elsewhere. */
106
+ static named<N extends string>(name: StringLiteral<N>): Counter;
107
+ /** Adds one. */
108
+ increment(): void;
109
+ /** Adds `n`. A counter does not go down: an amount below zero is
110
+ * ignored. */
111
+ add(n: number): void;
112
+ /** The counter itself, to hand to other code. */
113
+ ref(): this;
114
+ }
115
+ /** A counter shared between services: each that records to it is tracked as
116
+ * using it. */
117
+ export declare class SharedCounter extends Counter {
118
+ /** Declares the shared counter `name`. */
119
+ constructor(name: string, opts?: MetricOptions);
120
+ }
121
+ /** A counter of the whole app: any code may record to it. */
122
+ export declare class GlobalCounter extends Counter {
123
+ /** Declares the global counter `name`. */
124
+ constructor(name: string, opts?: MetricOptions);
125
+ }
126
+ /** A number that goes up and down by what is added to it: how many
127
+ * requests are in flight, how many jobs are queued. Belongs to the declaring service: only it records to it. */
128
+ export declare class UpDownCounter {
129
+ private readonly inst;
130
+ private readonly attrs?;
131
+ /** Declares the up-down counter `name`. */
132
+ constructor(name: string, opts?: MetricOptions);
133
+ /** Binds the shared or global up-down counter `name`, declared elsewhere. */
134
+ static named<N extends string>(name: StringLiteral<N>): UpDownCounter;
135
+ /** Adds `n`, which may be below zero. */
136
+ add(n: number): void;
137
+ /** Adds one. */
138
+ increment(): void;
139
+ /** Takes away one. */
140
+ decrement(): void;
141
+ /** The up-down counter itself, to hand to other code. */
142
+ ref(): this;
143
+ }
144
+ /** An up-down counter shared between services: each that records to it is tracked as
145
+ * using it. */
146
+ export declare class SharedUpDownCounter extends UpDownCounter {
147
+ /** Declares the shared up-down counter `name`. */
148
+ constructor(name: string, opts?: MetricOptions);
149
+ }
150
+ /** An up-down counter of the whole app: any code may record to it. */
151
+ export declare class GlobalUpDownCounter extends UpDownCounter {
152
+ /** Declares the global up-down counter `name`. */
153
+ constructor(name: string, opts?: MetricOptions);
154
+ }
155
+ /** A number that is what it was last set to: what something is right now. Belongs to the declaring service: only it records to it. */
156
+ export declare class Gauge {
157
+ private readonly inst;
158
+ private readonly attrs?;
159
+ /** Declares the gauge `name`. */
160
+ constructor(name: string, opts?: MetricOptions);
161
+ /** Binds the shared or global gauge `name`, declared elsewhere. */
162
+ static named<N extends string>(name: StringLiteral<N>): Gauge;
163
+ /** Sets the gauge to `value`. */
164
+ set(value: number): void;
165
+ /** The gauge itself, to hand to other code. */
166
+ ref(): this;
167
+ }
168
+ /** A gauge shared between services: each that records to it is tracked as
169
+ * using it. */
170
+ export declare class SharedGauge extends Gauge {
171
+ /** Declares the shared gauge `name`. */
172
+ constructor(name: string, opts?: MetricOptions);
173
+ }
174
+ /** A gauge of the whole app: any code may record to it. */
175
+ export declare class GlobalGauge extends Gauge {
176
+ /** Declares the global gauge `name`. */
177
+ constructor(name: string, opts?: MetricOptions);
178
+ }
179
+ /** How what is recorded is distributed: how long requests take, how large
180
+ * uploads are. Belongs to the declaring service: only it records to it. */
181
+ export declare class Histogram {
182
+ private readonly inst;
183
+ private readonly attrs?;
184
+ /** Declares the histogram `name`. */
185
+ constructor(name: string, opts?: HistogramOptions);
186
+ /** Binds the shared or global histogram `name`, declared elsewhere. */
187
+ static named<N extends string>(name: StringLiteral<N>): Histogram;
188
+ /** Records `value`. */
189
+ record(value: number): void;
190
+ /** The histogram itself, to hand to other code. */
191
+ ref(): this;
192
+ }
193
+ /** A histogram shared between services: each that records to it is tracked as
194
+ * using it. */
195
+ export declare class SharedHistogram extends Histogram {
196
+ /** Declares the shared histogram `name`. */
197
+ constructor(name: string, opts?: HistogramOptions);
198
+ }
199
+ /** A histogram of the whole app: any code may record to it. */
200
+ export declare class GlobalHistogram extends Histogram {
201
+ /** Declares the global histogram `name`. */
202
+ constructor(name: string, opts?: HistogramOptions);
203
+ }
204
+ /** A counter for each combination of the labels `L`. Belongs to the
205
+ * declaring service: only it records to it. */
206
+ export declare class CounterGroup<L extends Labels<L>> {
207
+ private readonly inst;
208
+ /** Declares the counter group `name`. */
209
+ constructor(name: string, opts?: MetricOptions);
210
+ /** Binds the shared or global counter group `name`, declared elsewhere,
211
+ * whose labels are `L`. */
212
+ static named<L extends Labels<L>>(name: string): CounterGroup<L>;
213
+ /** The counter for `labels`. Worth keeping where it is used often:
214
+ * making it encodes the labels' attributes. */
215
+ with(labels: L): Counter;
216
+ /** The group itself, to hand to other code. */
217
+ ref(): this;
218
+ }
219
+ /** A counter group shared between services: each that records to it is tracked
220
+ * as using it. */
221
+ export declare class SharedCounterGroup<L extends Labels<L>> extends CounterGroup<L> {
222
+ /** Declares the shared counter group `name`. */
223
+ constructor(name: string, opts?: MetricOptions);
224
+ with(labels: L): SharedCounter;
225
+ }
226
+ /** A counter group of the whole app: any code may record to it. */
227
+ export declare class GlobalCounterGroup<L extends Labels<L>> extends CounterGroup<L> {
228
+ /** Declares the global counter group `name`. */
229
+ constructor(name: string, opts?: MetricOptions);
230
+ with(labels: L): GlobalCounter;
231
+ }
232
+ /** An up-down counter for each combination of the labels `L`. Belongs to the
233
+ * declaring service: only it records to it. */
234
+ export declare class UpDownCounterGroup<L extends Labels<L>> {
235
+ private readonly inst;
236
+ /** Declares the up-down counter group `name`. */
237
+ constructor(name: string, opts?: MetricOptions);
238
+ /** Binds the shared or global up-down counter group `name`, declared elsewhere,
239
+ * whose labels are `L`. */
240
+ static named<L extends Labels<L>>(name: string): UpDownCounterGroup<L>;
241
+ /** The up-down counter for `labels`. Worth keeping where it is used often:
242
+ * making it encodes the labels' attributes. */
243
+ with(labels: L): UpDownCounter;
244
+ /** The group itself, to hand to other code. */
245
+ ref(): this;
246
+ }
247
+ /** An up-down counter group shared between services: each that records to it is tracked
248
+ * as using it. */
249
+ export declare class SharedUpDownCounterGroup<L extends Labels<L>> extends UpDownCounterGroup<L> {
250
+ /** Declares the shared up-down counter group `name`. */
251
+ constructor(name: string, opts?: MetricOptions);
252
+ with(labels: L): SharedUpDownCounter;
253
+ }
254
+ /** An up-down counter group of the whole app: any code may record to it. */
255
+ export declare class GlobalUpDownCounterGroup<L extends Labels<L>> extends UpDownCounterGroup<L> {
256
+ /** Declares the global up-down counter group `name`. */
257
+ constructor(name: string, opts?: MetricOptions);
258
+ with(labels: L): GlobalUpDownCounter;
259
+ }
260
+ /** A gauge for each combination of the labels `L`. Belongs to the
261
+ * declaring service: only it records to it. */
262
+ export declare class GaugeGroup<L extends Labels<L>> {
263
+ private readonly inst;
264
+ /** Declares the gauge group `name`. */
265
+ constructor(name: string, opts?: MetricOptions);
266
+ /** Binds the shared or global gauge group `name`, declared elsewhere,
267
+ * whose labels are `L`. */
268
+ static named<L extends Labels<L>>(name: string): GaugeGroup<L>;
269
+ /** The gauge for `labels`. Worth keeping where it is used often:
270
+ * making it encodes the labels' attributes. */
271
+ with(labels: L): Gauge;
272
+ /** The group itself, to hand to other code. */
273
+ ref(): this;
274
+ }
275
+ /** A gauge group shared between services: each that records to it is tracked
276
+ * as using it. */
277
+ export declare class SharedGaugeGroup<L extends Labels<L>> extends GaugeGroup<L> {
278
+ /** Declares the shared gauge group `name`. */
279
+ constructor(name: string, opts?: MetricOptions);
280
+ with(labels: L): SharedGauge;
281
+ }
282
+ /** A gauge group of the whole app: any code may record to it. */
283
+ export declare class GlobalGaugeGroup<L extends Labels<L>> extends GaugeGroup<L> {
284
+ /** Declares the global gauge group `name`. */
285
+ constructor(name: string, opts?: MetricOptions);
286
+ with(labels: L): GlobalGauge;
287
+ }
288
+ /** A histogram for each combination of the labels `L`. Belongs to the
289
+ * declaring service: only it records to it. */
290
+ export declare class HistogramGroup<L extends Labels<L>> {
291
+ private readonly inst;
292
+ /** Declares the histogram group `name`. */
293
+ constructor(name: string, opts?: HistogramOptions);
294
+ /** Binds the shared or global histogram group `name`, declared elsewhere,
295
+ * whose labels are `L`. */
296
+ static named<L extends Labels<L>>(name: string): HistogramGroup<L>;
297
+ /** The histogram for `labels`. Worth keeping where it is used often:
298
+ * making it encodes the labels' attributes. */
299
+ with(labels: L): Histogram;
300
+ /** The group itself, to hand to other code. */
301
+ ref(): this;
302
+ }
303
+ /** A histogram group shared between services: each that records to it is tracked
304
+ * as using it. */
305
+ export declare class SharedHistogramGroup<L extends Labels<L>> extends HistogramGroup<L> {
306
+ /** Declares the shared histogram group `name`. */
307
+ constructor(name: string, opts?: HistogramOptions);
308
+ with(labels: L): SharedHistogram;
309
+ }
310
+ /** A histogram group of the whole app: any code may record to it. */
311
+ export declare class GlobalHistogramGroup<L extends Labels<L>> extends HistogramGroup<L> {
312
+ /** Declares the global histogram group `name`. */
313
+ constructor(name: string, opts?: HistogramOptions);
314
+ with(labels: L): GlobalHistogram;
315
+ }