@sockethub/server 5.0.0-alpha.22 → 5.0.0-alpha.24

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.
@@ -21,6 +21,10 @@ export interface MessageHandlersOptions {
21
21
  clientIp?: string;
22
22
  platformSessionId?: string;
23
23
  onPlatformInstance?: (platformInstance: PlatformInstance) => void;
24
+ /** Bounded telemetry dimension identifying the public request path. */
25
+ transport?: "socket" | "http";
26
+ /** Called only after platform and action labels pass schema validation. */
27
+ onPlatformAction?: (platform: string, action: string) => void;
24
28
  }
25
29
  /**
26
30
  * Normalize middleware errors into payload-safe error responses.
@@ -2,10 +2,21 @@ type Attributes = Record<string, string | number | boolean>;
2
2
  export interface ObservabilityAdapter {
3
3
  count(name: string, value?: number, attributes?: Attributes): void;
4
4
  gauge(name: string, value: number, attributes?: Attributes): void;
5
- startAction(platform: string, action: string): (error?: boolean) => void;
5
+ distribution(name: string, value: number, unit: string, attributes?: Attributes): void;
6
+ startAction(platform: string, action: string, attributes?: Attributes): (error?: boolean) => void;
6
7
  }
7
8
  export declare function setObservabilityAdapter(next: ObservabilityAdapter): void;
8
9
  export declare const observability: ObservabilityAdapter;
10
+ export interface ConnectionTelemetry {
11
+ recordPlatform(platform: string): void;
12
+ end(): void;
13
+ }
14
+ /**
15
+ * Aggregate one socket connection without exporting its socket/session id.
16
+ * Platform names have already come from the validated registry by the time
17
+ * recordPlatform is called.
18
+ */
19
+ export declare function startConnectionTelemetry(): ConnectionTelemetry;
9
20
  export declare function resetObservabilityForTesting(): void;
10
21
  /** Remove common network/user identifiers before forwarding operational logs. */
11
22
  export declare function redactObservabilityLog(message: string): string;
package/dist/platform.js CHANGED
@@ -26685,7 +26685,7 @@ var init_package = __esm(() => {
26685
26685
  package_default = {
26686
26686
  name: "@sockethub/schemas",
26687
26687
  description: "JSON schema files for validating Sockethub Activity Streams",
26688
- version: "3.0.0-alpha.22",
26688
+ version: "3.0.0-alpha.24",
26689
26689
  type: "module",
26690
26690
  private: false,
26691
26691
  author: "Nick Jennings <nick@silverbucket.net>",
@@ -26755,7 +26755,7 @@ var init_package = __esm(() => {
26755
26755
  "ajv-formats": "^2.1.1",
26756
26756
  "ajv-formats-draft2019": "^1.6.1"
26757
26757
  },
26758
- gitHead: "1630010f605e85cc548e3323cb9694fbe3a7a18a",
26758
+ gitHead: "e778256d7067e2743cd6807a15d39a0cc65a358d",
26759
26759
  types: "./dist/index.d.ts"
26760
26760
  };
26761
26761
  });
@@ -71563,7 +71563,13 @@ function errorMessage(value) {
71563
71563
  }
71564
71564
  return String(value);
71565
71565
  }
71566
- var init_error = () => {};
71566
+ function isExpectedError(value) {
71567
+ return value instanceof Error && value[EXPECTED_ERROR] === true;
71568
+ }
71569
+ var EXPECTED_ERROR;
71570
+ var init_error = __esm(() => {
71571
+ EXPECTED_ERROR = Symbol.for("sockethub.expectedError");
71572
+ });
71567
71573
 
71568
71574
  // ../../node_modules/convict/node_modules/yargs-parser/build/index.cjs
71569
71575
  var require_build = __commonJS(function(exports, module) {
@@ -110492,6 +110498,7 @@ var init_observability = __esm(() => {
110492
110498
  noopAdapter = {
110493
110499
  count: () => {},
110494
110500
  gauge: () => {},
110501
+ distribution: () => {},
110495
110502
  startAction: () => () => {}
110496
110503
  };
110497
110504
  adapter = noopAdapter;
@@ -115189,6 +115196,7 @@ var exports_sentry = {};
115189
115196
  __export(exports_sentry, {
115190
115197
  SENTRY_FLUSH_TIMEOUT_MS: () => SENTRY_FLUSH_TIMEOUT_MS,
115191
115198
  count: () => count2,
115199
+ distribution: () => distribution2,
115192
115200
  flush: () => flush3,
115193
115201
  gauge: () => gauge2,
115194
115202
  reportError: () => reportError,
@@ -115212,9 +115220,14 @@ function gauge2(name, value, attributes = {}) {
115212
115220
  exports_public_api.gauge(name, value, { attributes });
115213
115221
  }
115214
115222
  }
115215
- function startAction(platform3, action) {
115223
+ function distribution2(name, value, unit, attributes = {}) {
115224
+ if (sentryConfig.enableMetrics) {
115225
+ exports_public_api.distribution(name, value, { unit, attributes });
115226
+ }
115227
+ }
115228
+ function startAction(platform3, action, additionalAttributes = {}) {
115216
115229
  const startedAt = performance.now();
115217
- const attributes = { platform: platform3, action };
115230
+ const attributes = { platform: platform3, action, ...additionalAttributes };
115218
115231
  count2("sockethub.action.started", 1, attributes);
115219
115232
  const span = startInactiveSpan({
115220
115233
  name: `${platform3}.${action}`,
@@ -115226,12 +115239,7 @@ function startAction(platform3, action) {
115226
115239
  span.setStatus({ code: error4 ? 2 : 1 });
115227
115240
  span.end();
115228
115241
  count2(error4 ? "sockethub.action.failed" : "sockethub.action.completed", 1, attributes);
115229
- if (sentryConfig.enableMetrics) {
115230
- exports_public_api.distribution("sockethub.action.duration", duration, {
115231
- unit: "millisecond",
115232
- attributes
115233
- });
115234
- }
115242
+ distribution2("sockethub.action.duration", duration, "millisecond", attributes);
115235
115243
  };
115236
115244
  }
115237
115245
  async function sendTestEvent() {
@@ -115284,7 +115292,7 @@ var init_sentry = __esm(async () => {
115284
115292
  setTag("service", "sockethub");
115285
115293
  setTag("process", process.env.SOCKETHUB_PLATFORM_CHILD === "1" ? "platform" : "server");
115286
115294
  logger2.info("initialized sentry observability");
115287
- setObservabilityAdapter({ count: count2, gauge: gauge2, startAction });
115295
+ setObservabilityAdapter({ count: count2, gauge: gauge2, distribution: distribution2, startAction });
115288
115296
  });
115289
115297
 
115290
115298
  // ../data-layer/src/index.ts
@@ -136951,7 +136959,14 @@ async function startPlatformProcess() {
136951
136959
  } catch {
136952
136960
  message = errorMessage(err);
136953
136961
  }
136954
- sentry.reportError(new Error(message));
136962
+ if (isExpectedError(err)) {
136963
+ sentry.count?.("platform.job.expected_failure", 1, {
136964
+ platform: platformName,
136965
+ type: job.msg.type
136966
+ });
136967
+ } else {
136968
+ sentry.reportError(new Error(message));
136969
+ }
136955
136970
  reject(new Error(message));
136956
136971
  } else {
136957
136972
  jobLog.debug(`completed ${job.title} ${job.msg.type}`);
@@ -137077,4 +137092,4 @@ export {
137077
137092
  mergePackageConfig
137078
137093
  };
137079
137094
 
137080
- //# debugId=6CD4B2D6787607E264756E2164756E21
137095
+ //# debugId=22D352D86E997D3764756E2164756E21