@replit/river 0.203.0 → 0.203.1

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/dist/{chunk-XBPEUVWN.js → chunk-2FHJVQBE.js} +2 -2
  2. package/dist/{chunk-D5EIDBUT.js → chunk-7MKTFUJO.js} +3 -3
  3. package/dist/{chunk-SZHNMLKC.js → chunk-AK7NTFAM.js} +31 -10
  4. package/dist/{chunk-SZHNMLKC.js.map → chunk-AK7NTFAM.js.map} +1 -1
  5. package/dist/{chunk-DGT3MPD4.js → chunk-T4WWG42M.js} +3 -3
  6. package/dist/{chunk-FG22HHCY.js → chunk-TMOCPK63.js} +9 -6
  7. package/dist/chunk-TMOCPK63.js.map +1 -0
  8. package/dist/{chunk-LHH5LQ7C.js → chunk-WBGKPIFS.js} +11 -1
  9. package/dist/chunk-WBGKPIFS.js.map +1 -0
  10. package/dist/logging/index.cjs +1 -0
  11. package/dist/logging/index.cjs.map +1 -1
  12. package/dist/logging/index.js +1 -1
  13. package/dist/router/index.cjs +90 -103
  14. package/dist/router/index.cjs.map +1 -1
  15. package/dist/router/index.d.cts +1 -1
  16. package/dist/router/index.d.ts +1 -1
  17. package/dist/router/index.js +77 -95
  18. package/dist/router/index.js.map +1 -1
  19. package/dist/testUtil/index.cjs +36 -9
  20. package/dist/testUtil/index.cjs.map +1 -1
  21. package/dist/testUtil/index.js +5 -5
  22. package/dist/transport/impls/ws/client.cjs +41 -14
  23. package/dist/transport/impls/ws/client.cjs.map +1 -1
  24. package/dist/transport/impls/ws/client.js +5 -5
  25. package/dist/transport/impls/ws/server.cjs +39 -12
  26. package/dist/transport/impls/ws/server.cjs.map +1 -1
  27. package/dist/transport/impls/ws/server.js +5 -5
  28. package/dist/transport/index.cjs +43 -16
  29. package/dist/transport/index.cjs.map +1 -1
  30. package/dist/transport/index.js +5 -5
  31. package/package.json +2 -2
  32. package/dist/chunk-FG22HHCY.js.map +0 -1
  33. package/dist/chunk-LHH5LQ7C.js.map +0 -1
  34. /package/dist/{chunk-XBPEUVWN.js.map → chunk-2FHJVQBE.js.map} +0 -0
  35. /package/dist/{chunk-D5EIDBUT.js.map → chunk-7MKTFUJO.js.map} +0 -0
  36. /package/dist/{chunk-DGT3MPD4.js.map → chunk-T4WWG42M.js.map} +0 -0
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  ClientTransport
3
- } from "../../../chunk-DGT3MPD4.js";
3
+ } from "../../../chunk-T4WWG42M.js";
4
4
  import {
5
5
  WebSocketConnection
6
- } from "../../../chunk-XBPEUVWN.js";
7
- import "../../../chunk-FG22HHCY.js";
8
- import "../../../chunk-SZHNMLKC.js";
9
- import "../../../chunk-LHH5LQ7C.js";
6
+ } from "../../../chunk-2FHJVQBE.js";
7
+ import "../../../chunk-TMOCPK63.js";
8
+ import "../../../chunk-AK7NTFAM.js";
9
+ import "../../../chunk-WBGKPIFS.js";
10
10
  import "../../../chunk-AJGIY2UB.js";
11
11
 
12
12
  // transport/impls/ws/client.ts
@@ -40,8 +40,8 @@ var Connection = class {
40
40
  }
41
41
  get loggingMetadata() {
42
42
  const metadata = { connId: this.id };
43
- const spanContext = this.telemetry?.span.spanContext();
44
- if (this.telemetry?.span.isRecording() && spanContext) {
43
+ if (this.telemetry?.span.isRecording()) {
44
+ const spanContext = this.telemetry.span.spanContext();
45
45
  metadata.telemetry = {
46
46
  traceId: spanContext.traceId,
47
47
  spanId: spanContext.spanId
@@ -155,7 +155,7 @@ var WebSocketConnection = class extends Connection {
155
155
  };
156
156
 
157
157
  // transport/server.ts
158
- var import_api3 = require("@opentelemetry/api");
158
+ var import_api4 = require("@opentelemetry/api");
159
159
 
160
160
  // transport/message.ts
161
161
  var import_typebox = require("@sinclair/typebox");
@@ -350,6 +350,7 @@ var defaultServerTransportOptions = {
350
350
  };
351
351
 
352
352
  // logging/log.ts
353
+ var import_api = require("@opentelemetry/api");
353
354
  var LoggingLevels = {
354
355
  debug: -1,
355
356
  info: 0,
@@ -358,6 +359,15 @@ var LoggingLevels = {
358
359
  };
359
360
  var cleanedLogFn = (log) => {
360
361
  return (msg, metadata) => {
362
+ if (metadata && !metadata.telemetry) {
363
+ const span = import_api.trace.getSpan(import_api.context.active());
364
+ if (span) {
365
+ metadata.telemetry = {
366
+ traceId: span.spanContext().traceId,
367
+ spanId: span.spanContext().spanId
368
+ };
369
+ }
370
+ }
361
371
  if (!metadata?.transportMessage) {
362
372
  log(msg, metadata);
363
373
  return;
@@ -556,13 +566,13 @@ var IdentifiedSession = class extends CommonSession {
556
566
  this.protocolVersion = protocolVersion;
557
567
  }
558
568
  get loggingMetadata() {
559
- const spanContext = this.telemetry.span.spanContext();
560
569
  const metadata = {
561
570
  clientId: this.from,
562
571
  connectedTo: this.to,
563
572
  sessionId: this.id
564
573
  };
565
574
  if (this.telemetry.span.isRecording()) {
575
+ const spanContext = this.telemetry.span.spanContext();
566
576
  metadata.telemetry = {
567
577
  traceId: spanContext.traceId,
568
578
  spanId: spanContext.spanId
@@ -689,14 +699,14 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
689
699
  };
690
700
 
691
701
  // tracing/index.ts
692
- var import_api = require("@opentelemetry/api");
702
+ var import_api2 = require("@opentelemetry/api");
693
703
 
694
704
  // package.json
695
- var version = "0.203.0";
705
+ var version = "0.203.1";
696
706
 
697
707
  // tracing/index.ts
698
708
  function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
699
- const parentCtx = propagationCtx ? import_api.propagation.extract(import_api.context.active(), propagationCtx) : import_api.context.active();
709
+ const parentCtx = propagationCtx ? import_api2.propagation.extract(import_api2.context.active(), propagationCtx) : import_api2.context.active();
700
710
  const span = tracer.startSpan(
701
711
  `session ${sessionId}`,
702
712
  {
@@ -709,10 +719,25 @@ function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
709
719
  },
710
720
  parentCtx
711
721
  );
712
- const ctx = import_api.trace.setSpan(parentCtx, span);
722
+ const ctx = import_api2.trace.setSpan(parentCtx, span);
713
723
  return { span, ctx };
714
724
  }
715
- var tracer = import_api.trace.getTracer("river", version);
725
+ function createConnectionTelemetryInfo(connection, info) {
726
+ const span = tracer.startSpan(
727
+ `connection ${connection.id}`,
728
+ {
729
+ attributes: {
730
+ component: "river",
731
+ "river.connection.id": connection.id
732
+ },
733
+ links: [{ context: info.span.spanContext() }]
734
+ },
735
+ info.ctx
736
+ );
737
+ const ctx = import_api2.trace.setSpan(info.ctx, span);
738
+ return { span, ctx };
739
+ }
740
+ var tracer = import_api2.trace.getTracer("river", version);
716
741
 
717
742
  // transport/sessionStateMachine/SessionWaitingForHandshake.ts
718
743
  var SessionWaitingForHandshake = class extends CommonSession {
@@ -818,7 +843,7 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
818
843
  };
819
844
 
820
845
  // transport/sessionStateMachine/SessionConnected.ts
821
- var import_api2 = require("@opentelemetry/api");
846
+ var import_api3 = require("@opentelemetry/api");
822
847
  var SessionConnected = class extends IdentifiedSession {
823
848
  state = "Connected" /* Connected */;
824
849
  conn;
@@ -922,7 +947,7 @@ var SessionConnected = class extends IdentifiedSession {
922
947
  tags: ["invariant-violation"]
923
948
  });
924
949
  this.telemetry.span.setStatus({
925
- code: import_api2.SpanStatusCode.ERROR,
950
+ code: import_api3.SpanStatusCode.ERROR,
926
951
  message: reason
927
952
  });
928
953
  this.closeConnection();
@@ -1094,6 +1119,7 @@ var SessionStateGraph = {
1094
1119
  listeners,
1095
1120
  ...carriedState
1096
1121
  });
1122
+ conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
1097
1123
  session.log?.info(
1098
1124
  `session ${session.id} transition from Connecting to Handshaking`,
1099
1125
  {
@@ -1154,6 +1180,7 @@ var SessionStateGraph = {
1154
1180
  listeners,
1155
1181
  ...carriedState
1156
1182
  });
1183
+ conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
1157
1184
  session.log?.info(
1158
1185
  `session ${session.id} transition from WaitingForHandshake to Connected`,
1159
1186
  {
@@ -1610,7 +1637,7 @@ var ServerTransport = class extends Transport {
1610
1637
  }
1611
1638
  rejectHandshakeRequest(session, to, reason, code, metadata) {
1612
1639
  session.conn.telemetry?.span.setStatus({
1613
- code: import_api3.SpanStatusCode.ERROR,
1640
+ code: import_api4.SpanStatusCode.ERROR,
1614
1641
  message: reason
1615
1642
  });
1616
1643
  this.log?.warn(reason, metadata);