@crvouga/mockingbird-service-otel 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-CZKU2KT2.js";
7
- import "./chunk-HRGWNDT2.js";
6
+ } from "./chunk-JZ6IVZNV.js";
7
+ import "./chunk-T4AU5UCQ.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -748,10 +748,44 @@ type Organization = {
748
748
  identifier: string;
749
749
  name: string;
750
750
  };
751
+ /**
752
+ * How the OTLP receiver authenticates an export: a bearer token (`ingestTokens`), Basic
753
+ * credentials (`ingestUsers`; a hosted OTLP gateway's `instanceId:token`), or nothing at all
754
+ * (a local collector).
755
+ */
756
+ type IngestAuth = "bearer" | "basic" | "none";
757
+ declare const INGEST_AUTH_MODES: readonly IngestAuth[];
758
+ /**
759
+ * Browser CORS for the receiver routes, shaped like the Collector's `cors:` block. No allowed
760
+ * origin: CORS is off (no preflight, no headers).
761
+ */
762
+ type CorsSettings = {
763
+ /** Exact origins, origins with one `*` wildcard (`https://*.example.test`), or `*` for any. */
764
+ allowedOrigins: string[];
765
+ /** Request headers a preflight may name; `*` for any. Default accept, content-type, x-requested-with. */
766
+ allowedHeaders?: string[];
767
+ /** Methods a cross-origin request may use. Default GET, POST, HEAD. */
768
+ allowedMethods?: string[];
769
+ /** `Access-Control-Expose-Headers` on the export's response. */
770
+ exposedHeaders?: string[];
771
+ /** `Access-Control-Max-Age` in seconds; 0 or absent sends none. */
772
+ maxAge?: number;
773
+ };
751
774
  /** Per-namespace knobs, set through `PUT /__admin/settings`; cleared on reset. */
752
775
  type Settings = {
776
+ /** What the OTLP receiver asks of an export. Default `bearer`. */
777
+ ingestAuth: IngestAuth;
753
778
  /** Bearer tokens the OTLP receiver accepts. Empty: any bearer token (none is a 401). */
754
779
  ingestTokens: string[];
780
+ /**
781
+ * Basic credentials the OTLP receiver accepts in `basic` mode. Empty: any Basic credentials
782
+ * (none is a 401).
783
+ */
784
+ ingestUsers: {
785
+ username: string;
786
+ password: string;
787
+ }[];
788
+ cors: CorsSettings;
755
789
  /** Basic-auth users the search API accepts. Empty: any Basic credentials (none is a 401). */
756
790
  searchUsers: {
757
791
  username: string;
@@ -789,6 +823,7 @@ declare class OtelState {
789
823
  settings: Partial<Settings>;
790
824
  });
791
825
  ensureSeeded(): void;
826
+ /** Stored settings over the defaults, so a snapshot from before a setting existed still reads. */
792
827
  current(): Settings;
793
828
  update(patch: Partial<Settings>): Settings;
794
829
  /** The org an export lands in, from its resource attributes. */
@@ -969,10 +1004,10 @@ type OpenAPIDocument = {
969
1004
  };
970
1005
 
971
1006
  declare const document: OpenAPIDocument;
972
- type OperationId = "ExportTraces" | "ExportLogs" | "ExportMetrics" | "ListOrganizations" | "ListStreams" | "GetStreamSchema" | "Search";
973
- type SupportedOperationId = "ExportTraces" | "ExportLogs" | "ExportMetrics" | "ListOrganizations" | "ListStreams" | "GetStreamSchema" | "Search";
974
- declare const operationIds: readonly ["ExportTraces", "ExportLogs", "ExportMetrics", "ListOrganizations", "ListStreams", "GetStreamSchema", "Search"];
975
- declare const supportedOperationIds: readonly ["ExportTraces", "ExportLogs", "ExportMetrics", "ListOrganizations", "ListStreams", "GetStreamSchema", "Search"];
1007
+ type OperationId = "ExportTraces" | "PreflightTraces" | "ExportLogs" | "PreflightLogs" | "ExportMetrics" | "PreflightMetrics" | "ListOrganizations" | "ListStreams" | "GetStreamSchema" | "Search";
1008
+ type SupportedOperationId = "ExportTraces" | "PreflightTraces" | "ExportLogs" | "PreflightLogs" | "ExportMetrics" | "PreflightMetrics" | "ListOrganizations" | "ListStreams" | "GetStreamSchema" | "Search";
1009
+ declare const operationIds: readonly ["ExportTraces", "PreflightTraces", "ExportLogs", "PreflightLogs", "ExportMetrics", "PreflightMetrics", "ListOrganizations", "ListStreams", "GetStreamSchema", "Search"];
1010
+ declare const supportedOperationIds: readonly ["ExportTraces", "PreflightTraces", "ExportLogs", "PreflightLogs", "ExportMetrics", "PreflightMetrics", "ListOrganizations", "ListStreams", "GetStreamSchema", "Search"];
976
1011
 
977
1012
  /**
978
1013
  * A minimal protobuf wire-format decoder for the two OTLP export requests the receiver accepts
@@ -1093,7 +1128,8 @@ declare const execute: (query: Query, rows: Row[]) => Row[];
1093
1128
  /**
1094
1129
  * Every named collector misbehaviour our exporters branch on, switched on with
1095
1130
  * `POST /__admin/faults {"preset": "<name>"}` (add `count` to limit it). The SDK retries 429,
1096
- * 502, 503 and 504 (honouring `retry-after`) and drops everything else.
1131
+ * 502, 503 and 504 (honouring `retry-after`) and drops everything else. The export presets
1132
+ * fault the POST only, so a browser's CORS preflight does not use one up.
1097
1133
  */
1098
1134
  declare const OTEL_PRESETS: Record<string, FaultPreset>;
1099
1135
  type OtelRuntimeOptions = {
@@ -1109,20 +1145,21 @@ type OtelRuntime = ServiceRuntime<OtelAPI>;
1109
1145
  /**
1110
1146
  * The OTLP collector + OpenObserve search mock with Mockingbird's full service contract:
1111
1147
  * `/__admin/health`, `/__admin/*` (logs, spans, wait), namespaces by header, by `/__admin/ns/<name>` path
1112
- * prefix, or by credential (the OTLP bearer token or the O2 Basic username), clock control and
1113
- * fault presets.
1148
+ * prefix, or by credential (the OTLP bearer token, or the Basic username of a Basic collector
1149
+ * or of O2), clock control and fault presets.
1114
1150
  */
1115
1151
  declare const createRuntime: (options?: OtelRuntimeOptions) => OtelRuntime;
1116
1152
 
1117
1153
  declare const OTEL_NAMESPACE = "otel";
1118
1154
  type OtelAPIOptions = APIOptions & {
1119
- /** Initial per-namespace settings (tokens, users, orgs, routing, keepBodies). */
1155
+ /** Initial per-namespace settings (auth mode, tokens, users, CORS, orgs, routing, keepBodies). */
1120
1156
  settings?: Partial<Settings>;
1121
1157
  };
1122
1158
  /**
1123
1159
  * The credential a request carries, for `PUT /__admin/credentials`: the OTLP bearer token
1124
- * (`OTEL_AUTH_TOKEN`) or the O2 Basic-auth username (from `O2_BASIC_AUTH`). Map both to the
1125
- * same namespace so a worker's exports and searches meet.
1160
+ * (`OTEL_AUTH_TOKEN`), or the Basic-auth username (the O2 user from `O2_BASIC_AUTH`; a Basic
1161
+ * collector's instance id). Map both to the same namespace so a worker's exports and searches
1162
+ * meet.
1126
1163
  */
1127
1164
  declare const otelCredential: (request: Request) => string | undefined;
1128
1165
  /**
@@ -1139,8 +1176,10 @@ declare class OtelAPI implements FetchAPI$1 {
1139
1176
  private readonly service;
1140
1177
  private readonly now;
1141
1178
  constructor(options?: OtelAPIOptions);
1142
- /** Inflate `content-encoding: gzip` bodies (the exporters' `compression: "gzip"`). */
1179
+ /** CORS wraps everything the receiver answers, its errors included. */
1143
1180
  fetch(request: Request): Promise<Response>;
1181
+ /** Inflate `content-encoding: gzip` bodies (the exporters' `compression: "gzip"`). */
1182
+ private dispatch;
1144
1183
  reset(): Promise<void>;
1145
1184
  /** Every stored log row (with its org and stream), oldest first. */
1146
1185
  logs(): StoredRow[];
@@ -1148,6 +1187,10 @@ declare class OtelAPI implements FetchAPI$1 {
1148
1187
  spans(): StoredRow[];
1149
1188
  private settings;
1150
1189
  private gate;
1190
+ /** The receiver's auth mode: nothing, Basic credentials, or (the default) a bearer token. */
1191
+ private ingestAllowed;
1192
+ /** `OPTIONS` on a receiver route: a CORS preflight when CORS is on, else not a method it takes. */
1193
+ private preflight;
1151
1194
  private decode;
1152
1195
  private export;
1153
1196
  private organizations;
@@ -1159,5 +1202,5 @@ declare class OtelAPI implements FetchAPI$1 {
1159
1202
  /** A stored row as the admin routes show it: its org and stream beside its columns. */
1160
1203
  declare const adminRow: (stored: StoredRow) => Row;
1161
1204
 
1162
- export { DEFAULT_ORGANIZATIONS, DEFAULT_SETTINGS, OTEL_NAMESPACE, OTEL_PRESETS, OtelAPI, ProtobufError, SqlError, adminRow, createRuntime, decodeLogsRequest, decodeTraceRequest, document, execute, formatKey, logRows, operationIds, otelCredential, parseSql, referencedColumns, spanRows, supportedOperationIds };
1163
- export type { Expr, FetchAPI$1 as FetchAPI, IngestedRow, MetricCounters, OperationId, Organization, OtelAPIOptions, OtelRuntime, OtelRuntimeOptions, Query, Row, Scalar, SchemaFields, Settings, SqliteClient, StoredRow, StreamType, SupportedOperationId };
1205
+ export { DEFAULT_ORGANIZATIONS, DEFAULT_SETTINGS, INGEST_AUTH_MODES, OTEL_NAMESPACE, OTEL_PRESETS, OtelAPI, ProtobufError, SqlError, adminRow, createRuntime, decodeLogsRequest, decodeTraceRequest, document, execute, formatKey, logRows, operationIds, otelCredential, parseSql, referencedColumns, spanRows, supportedOperationIds };
1206
+ export type { CorsSettings, Expr, FetchAPI$1 as FetchAPI, IngestAuth, IngestedRow, MetricCounters, OperationId, Organization, OtelAPIOptions, OtelRuntime, OtelRuntimeOptions, Query, Row, Scalar, SchemaFields, Settings, SqliteClient, StoredRow, StreamType, SupportedOperationId };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  DEFAULT_ORGANIZATIONS,
3
3
  DEFAULT_SETTINGS,
4
+ INGEST_AUTH_MODES,
4
5
  OTEL_NAMESPACE,
5
6
  OTEL_PRESETS,
6
7
  OtelAPI,
@@ -20,10 +21,11 @@ import {
20
21
  referencedColumns,
21
22
  spanRows,
22
23
  supportedOperationIds
23
- } from "./chunk-HRGWNDT2.js";
24
+ } from "./chunk-T4AU5UCQ.js";
24
25
  export {
25
26
  DEFAULT_ORGANIZATIONS,
26
27
  DEFAULT_SETTINGS,
28
+ INGEST_AUTH_MODES,
27
29
  OTEL_NAMESPACE,
28
30
  OTEL_PRESETS,
29
31
  OtelAPI,
package/dist/server.d.ts CHANGED
@@ -1349,10 +1349,43 @@ type Organization = {
1349
1349
  identifier: string;
1350
1350
  name: string;
1351
1351
  };
1352
+ /**
1353
+ * How the OTLP receiver authenticates an export: a bearer token (`ingestTokens`), Basic
1354
+ * credentials (`ingestUsers`; a hosted OTLP gateway's `instanceId:token`), or nothing at all
1355
+ * (a local collector).
1356
+ */
1357
+ type IngestAuth = "bearer" | "basic" | "none";
1358
+ /**
1359
+ * Browser CORS for the receiver routes, shaped like the Collector's `cors:` block. No allowed
1360
+ * origin: CORS is off (no preflight, no headers).
1361
+ */
1362
+ type CorsSettings = {
1363
+ /** Exact origins, origins with one `*` wildcard (`https://*.example.test`), or `*` for any. */
1364
+ allowedOrigins: string[];
1365
+ /** Request headers a preflight may name; `*` for any. Default accept, content-type, x-requested-with. */
1366
+ allowedHeaders?: string[];
1367
+ /** Methods a cross-origin request may use. Default GET, POST, HEAD. */
1368
+ allowedMethods?: string[];
1369
+ /** `Access-Control-Expose-Headers` on the export's response. */
1370
+ exposedHeaders?: string[];
1371
+ /** `Access-Control-Max-Age` in seconds; 0 or absent sends none. */
1372
+ maxAge?: number;
1373
+ };
1352
1374
  /** Per-namespace knobs, set through `PUT /__admin/settings`; cleared on reset. */
1353
1375
  type Settings = {
1376
+ /** What the OTLP receiver asks of an export. Default `bearer`. */
1377
+ ingestAuth: IngestAuth;
1354
1378
  /** Bearer tokens the OTLP receiver accepts. Empty: any bearer token (none is a 401). */
1355
1379
  ingestTokens: string[];
1380
+ /**
1381
+ * Basic credentials the OTLP receiver accepts in `basic` mode. Empty: any Basic credentials
1382
+ * (none is a 401).
1383
+ */
1384
+ ingestUsers: {
1385
+ username: string;
1386
+ password: string;
1387
+ }[];
1388
+ cors: CorsSettings;
1356
1389
  /** Basic-auth users the search API accepts. Empty: any Basic credentials (none is a 401). */
1357
1390
  searchUsers: {
1358
1391
  username: string;
@@ -1388,6 +1421,7 @@ declare class OtelState {
1388
1421
  settings: Partial<Settings>;
1389
1422
  });
1390
1423
  ensureSeeded(): void;
1424
+ /** Stored settings over the defaults, so a snapshot from before a setting existed still reads. */
1391
1425
  current(): Settings;
1392
1426
  update(patch: Partial<Settings>): Settings;
1393
1427
  /** The org an export lands in, from its resource attributes. */
@@ -1403,7 +1437,7 @@ declare class OtelState {
1403
1437
  }
1404
1438
 
1405
1439
  type OtelAPIOptions = APIOptions & {
1406
- /** Initial per-namespace settings (tokens, users, orgs, routing, keepBodies). */
1440
+ /** Initial per-namespace settings (auth mode, tokens, users, CORS, orgs, routing, keepBodies). */
1407
1441
  settings?: Partial<Settings>;
1408
1442
  };
1409
1443
  /**
@@ -1420,8 +1454,10 @@ declare class OtelAPI implements FetchAPI {
1420
1454
  private readonly service;
1421
1455
  private readonly now;
1422
1456
  constructor(options?: OtelAPIOptions);
1423
- /** Inflate `content-encoding: gzip` bodies (the exporters' `compression: "gzip"`). */
1457
+ /** CORS wraps everything the receiver answers, its errors included. */
1424
1458
  fetch(request: Request): Promise<Response>;
1459
+ /** Inflate `content-encoding: gzip` bodies (the exporters' `compression: "gzip"`). */
1460
+ private dispatch;
1425
1461
  reset(): Promise<void>;
1426
1462
  /** Every stored log row (with its org and stream), oldest first. */
1427
1463
  logs(): StoredRow[];
@@ -1429,6 +1465,10 @@ declare class OtelAPI implements FetchAPI {
1429
1465
  spans(): StoredRow[];
1430
1466
  private settings;
1431
1467
  private gate;
1468
+ /** The receiver's auth mode: nothing, Basic credentials, or (the default) a bearer token. */
1469
+ private ingestAllowed;
1470
+ /** `OPTIONS` on a receiver route: a CORS preflight when CORS is on, else not a method it takes. */
1471
+ private preflight;
1432
1472
  private decode;
1433
1473
  private export;
1434
1474
  private organizations;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-CZKU2KT2.js";
6
- import "./chunk-HRGWNDT2.js";
5
+ } from "./chunk-JZ6IVZNV.js";
6
+ import "./chunk-T4AU5UCQ.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,