@dxos/edge-client 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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 (30) hide show
  1. package/dist/lib/{browser → neutral}/index.mjs +118 -76
  2. package/dist/lib/neutral/index.mjs.map +7 -0
  3. package/dist/lib/neutral/meta.json +1 -0
  4. package/dist/types/src/edge-client.d.ts +3 -2
  5. package/dist/types/src/edge-client.d.ts.map +1 -1
  6. package/dist/types/src/edge-http-client.d.ts +39 -29
  7. package/dist/types/src/edge-http-client.d.ts.map +1 -1
  8. package/dist/types/tsconfig.tsbuildinfo +1 -1
  9. package/package.json +23 -24
  10. package/src/edge-client.test.ts +16 -11
  11. package/src/edge-client.ts +25 -3
  12. package/src/edge-http-client.test.ts +2 -1
  13. package/src/edge-http-client.ts +135 -51
  14. package/dist/lib/browser/index.mjs.map +0 -7
  15. package/dist/lib/browser/meta.json +0 -1
  16. package/dist/lib/node-esm/chunk-JTBFRYNM.mjs +0 -303
  17. package/dist/lib/node-esm/chunk-JTBFRYNM.mjs.map +0 -7
  18. package/dist/lib/node-esm/edge-ws-muxer.mjs +0 -12
  19. package/dist/lib/node-esm/edge-ws-muxer.mjs.map +0 -7
  20. package/dist/lib/node-esm/index.mjs +0 -1375
  21. package/dist/lib/node-esm/index.mjs.map +0 -7
  22. package/dist/lib/node-esm/meta.json +0 -1
  23. package/dist/lib/node-esm/testing/index.mjs +0 -186
  24. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  25. /package/dist/lib/{browser → neutral}/chunk-VESGVCLQ.mjs +0 -0
  26. /package/dist/lib/{browser → neutral}/chunk-VESGVCLQ.mjs.map +0 -0
  27. /package/dist/lib/{browser → neutral}/edge-ws-muxer.mjs +0 -0
  28. /package/dist/lib/{browser → neutral}/edge-ws-muxer.mjs.map +0 -0
  29. /package/dist/lib/{browser → neutral}/testing/index.mjs +0 -0
  30. /package/dist/lib/{browser → neutral}/testing/index.mjs.map +0 -0
@@ -123,10 +123,12 @@ var createStubEdgeIdentity = () => {
123
123
  };
124
124
 
125
125
  // src/edge-client.ts
126
+ import { propagation } from "@opentelemetry/api";
126
127
  import { Event, PersistentLifecycle, Trigger, TriggerState, scheduleMicroTask, scheduleTaskInterval as scheduleTaskInterval2 } from "@dxos/async";
127
128
  import { Resource as Resource2 } from "@dxos/context";
128
129
  import { log as log2, logInfo as logInfo2 } from "@dxos/log";
129
130
  import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
131
+ import { TRACE_PROCESSOR, TRACE_SPAN_ATTRIBUTE } from "@dxos/tracing";
130
132
 
131
133
  // src/edge-identity.ts
132
134
  import { invariant as invariant2 } from "@dxos/invariant";
@@ -600,7 +602,7 @@ var EdgeClient = class extends Resource2 {
600
602
  oldIdentity: this._identity
601
603
  }, {
602
604
  F: __dxlog_file4,
603
- L: 118,
605
+ L: 121,
604
606
  S: this,
605
607
  C: (f, a) => f(...a)
606
608
  });
@@ -613,11 +615,11 @@ var EdgeClient = class extends Resource2 {
613
615
  * Send message.
614
616
  * NOTE: The message is guaranteed to be delivered but the service must respond with a message to confirm processing.
615
617
  */
616
- async send(message) {
618
+ async send(ctx, message) {
617
619
  if (this._ready.state !== TriggerState.RESOLVED) {
618
620
  log2("waiting for websocket", void 0, {
619
621
  F: __dxlog_file4,
620
- L: 131,
622
+ L: 134,
621
623
  S: this,
622
624
  C: (f, a) => f(...a)
623
625
  });
@@ -631,6 +633,17 @@ var EdgeClient = class extends Resource2 {
631
633
  if (message.source && (message.source.peerKey !== this._identity.peerKey || message.source.identityKey !== this.identityKey)) {
632
634
  throw new EdgeIdentityChangedError();
633
635
  }
636
+ const spanId = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE);
637
+ const otlpContext = typeof spanId === "number" ? TRACE_PROCESSOR.remoteTracing.getSpanContext(spanId) : void 0;
638
+ if (otlpContext) {
639
+ const activeSpan = {};
640
+ propagation.inject(otlpContext, activeSpan);
641
+ message.traceContext = {
642
+ $typeName: "dxos.edge.messenger.TraceContext",
643
+ traceparent: activeSpan.traceparent,
644
+ tracestate: activeSpan.tracestate
645
+ };
646
+ }
634
647
  this._currentConnection.send(message);
635
648
  }
636
649
  onMessage(listener) {
@@ -647,7 +660,7 @@ var EdgeClient = class extends Resource2 {
647
660
  } catch (error) {
648
661
  log2.catch(error, void 0, {
649
662
  F: __dxlog_file4,
650
- L: 164,
663
+ L: 186,
651
664
  S: this,
652
665
  C: (f, a) => f(...a)
653
666
  });
@@ -665,7 +678,7 @@ var EdgeClient = class extends Resource2 {
665
678
  info: this.info
666
679
  }, {
667
680
  F: __dxlog_file4,
668
- L: 177,
681
+ L: 199,
669
682
  S: this,
670
683
  C: (f, a) => f(...a)
671
684
  });
@@ -674,7 +687,7 @@ var EdgeClient = class extends Resource2 {
674
687
  err
675
688
  }, {
676
689
  F: __dxlog_file4,
677
- L: 179,
690
+ L: 201,
678
691
  S: this,
679
692
  C: (f, a) => f(...a)
680
693
  });
@@ -694,7 +707,7 @@ var EdgeClient = class extends Resource2 {
694
707
  peerKey: this._identity.peerKey
695
708
  }, {
696
709
  F: __dxlog_file4,
697
- L: 199,
710
+ L: 221,
698
711
  S: this,
699
712
  C: (f, a) => f(...a)
700
713
  });
@@ -711,7 +724,7 @@ var EdgeClient = class extends Resource2 {
711
724
  if (this._identity !== identity) {
712
725
  log2("identity changed during auth header request", void 0, {
713
726
  F: __dxlog_file4,
714
- L: 213,
727
+ L: 235,
715
728
  S: this,
716
729
  C: (f, a) => f(...a)
717
730
  });
@@ -724,7 +737,7 @@ var EdgeClient = class extends Resource2 {
724
737
  protocolHeader
725
738
  }, {
726
739
  F: __dxlog_file4,
727
- L: 219,
740
+ L: 241,
728
741
  S: this,
729
742
  C: (f, a) => f(...a)
730
743
  });
@@ -739,7 +752,7 @@ var EdgeClient = class extends Resource2 {
739
752
  } else {
740
753
  log2.verbose("connected callback ignored, because connection is not active", void 0, {
741
754
  F: __dxlog_file4,
742
- L: 229,
755
+ L: 251,
743
756
  S: this,
744
757
  C: (f, a) => f(...a)
745
758
  });
@@ -752,7 +765,7 @@ var EdgeClient = class extends Resource2 {
752
765
  } else {
753
766
  log2.verbose("restart requested by inactive connection", void 0, {
754
767
  F: __dxlog_file4,
755
- L: 237,
768
+ L: 259,
756
769
  S: this,
757
770
  C: (f, a) => f(...a)
758
771
  });
@@ -768,7 +781,7 @@ var EdgeClient = class extends Resource2 {
768
781
  type: message.payload?.typeUrl
769
782
  }, {
770
783
  F: __dxlog_file4,
771
- L: 245,
784
+ L: 267,
772
785
  S: this,
773
786
  C: (f, a) => f(...a)
774
787
  });
@@ -805,7 +818,7 @@ var EdgeClient = class extends Resource2 {
805
818
  err
806
819
  }, {
807
820
  F: __dxlog_file4,
808
- L: 280,
821
+ L: 302,
809
822
  S: this,
810
823
  C: (f, a) => f(...a)
811
824
  });
@@ -822,7 +835,7 @@ var EdgeClient = class extends Resource2 {
822
835
  payload: protocol.getPayloadType(message)
823
836
  }, {
824
837
  F: __dxlog_file4,
825
- L: 290,
838
+ L: 312,
826
839
  S: this,
827
840
  C: (f, a) => f(...a)
828
841
  });
@@ -843,7 +856,7 @@ var EdgeClient = class extends Resource2 {
843
856
  statusText: response.statusText
844
857
  }, {
845
858
  F: __dxlog_file4,
846
- L: 302,
859
+ L: 324,
847
860
  S: this,
848
861
  C: (f, a) => f(...a)
849
862
  });
@@ -865,12 +878,13 @@ import * as FetchHttpClient from "@effect/platform/FetchHttpClient";
865
878
  import * as HttpClient from "@effect/platform/HttpClient";
866
879
  import * as Effect2 from "effect/Effect";
867
880
  import * as Function from "effect/Function";
881
+ import { propagation as propagation2 } from "@opentelemetry/api";
868
882
  import { sleep } from "@dxos/async";
869
- import { Context as Context3 } from "@dxos/context";
870
883
  import { runAndForwardErrors } from "@dxos/effect";
871
884
  import { invariant as invariant4 } from "@dxos/invariant";
872
885
  import { log as log4 } from "@dxos/log";
873
- import { EdgeAuthChallengeError, EdgeCallFailedError } from "@dxos/protocols";
886
+ import { EDGE_CLIENT_TAG_HEADER, EdgeAuthChallengeError, EdgeCallFailedError } from "@dxos/protocols";
887
+ import { TRACE_PROCESSOR as TRACE_PROCESSOR2, TRACE_SPAN_ATTRIBUTE as TRACE_SPAN_ATTRIBUTE2 } from "@dxos/tracing";
874
888
  import { createUrl } from "@dxos/util";
875
889
 
876
890
  // src/http-client.ts
@@ -924,18 +938,20 @@ var DEFAULT_MAX_RETRIES_COUNT = 3;
924
938
  var WARNING_BODY_SIZE = 10 * 1024 * 1024;
925
939
  var EdgeHttpClient = class {
926
940
  _baseUrl;
941
+ _clientTag;
927
942
  _edgeIdentity;
928
943
  /**
929
944
  * Auth header is cached until receiving the next 401 from EDGE, at which point it gets refreshed.
930
945
  */
931
946
  _authHeader;
932
- constructor(baseUrl) {
947
+ constructor(baseUrl, options) {
933
948
  this._baseUrl = getEdgeUrlWithProtocol(baseUrl, "http");
949
+ this._clientTag = options?.clientTag;
934
950
  log4("created", {
935
951
  url: this._baseUrl
936
952
  }, {
937
953
  F: __dxlog_file6,
938
- L: 107,
954
+ L: 122,
939
955
  S: this,
940
956
  C: (f, a) => f(...a)
941
957
  });
@@ -952,8 +968,8 @@ var EdgeHttpClient = class {
952
968
  //
953
969
  // Status
954
970
  //
955
- async getStatus(args) {
956
- return this._call(new URL("/status", this.baseUrl), {
971
+ async getStatus(ctx, args) {
972
+ return this._call(ctx, new URL("/status", this.baseUrl), {
957
973
  ...args,
958
974
  method: "GET",
959
975
  auth: true
@@ -962,15 +978,15 @@ var EdgeHttpClient = class {
962
978
  //
963
979
  // Agents
964
980
  //
965
- createAgent(body, args) {
966
- return this._call(new URL("/agents/create", this.baseUrl), {
981
+ createAgent(ctx, body, args) {
982
+ return this._call(ctx, new URL("/agents/create", this.baseUrl), {
967
983
  ...args,
968
984
  method: "POST",
969
985
  body
970
986
  });
971
987
  }
972
- getAgentStatus(request, args) {
973
- return this._call(new URL(`/users/${request.ownerIdentityKey.toHex()}/agent/status`, this.baseUrl), {
988
+ getAgentStatus(ctx, request, args) {
989
+ return this._call(ctx, new URL(`/users/${request.ownerIdentityKey.toHex()}/agent/status`, this.baseUrl), {
974
990
  ...args,
975
991
  method: "GET"
976
992
  });
@@ -978,14 +994,14 @@ var EdgeHttpClient = class {
978
994
  //
979
995
  // Credentials
980
996
  //
981
- getCredentialsForNotarization(spaceId, args) {
982
- return this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
997
+ getCredentialsForNotarization(ctx, spaceId, args) {
998
+ return this._call(ctx, new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
983
999
  ...args,
984
1000
  method: "GET"
985
1001
  });
986
1002
  }
987
- async notarizeCredentials(spaceId, body, args) {
988
- await this._call(new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
1003
+ async notarizeCredentials(ctx, spaceId, body, args) {
1004
+ await this._call(ctx, new URL(`/spaces/${spaceId}/notarization`, this.baseUrl), {
989
1005
  ...args,
990
1006
  body,
991
1007
  method: "POST"
@@ -994,8 +1010,8 @@ var EdgeHttpClient = class {
994
1010
  //
995
1011
  // Identity
996
1012
  //
997
- async recoverIdentity(body, args) {
998
- return this._call(new URL("/identity/recover", this.baseUrl), {
1013
+ async recoverIdentity(ctx, body, args) {
1014
+ return this._call(ctx, new URL("/identity/recover", this.baseUrl), {
999
1015
  ...args,
1000
1016
  body,
1001
1017
  method: "POST"
@@ -1004,8 +1020,8 @@ var EdgeHttpClient = class {
1004
1020
  //
1005
1021
  // Invitations
1006
1022
  //
1007
- async joinSpaceByInvitation(spaceId, body, args) {
1008
- return this._call(new URL(`/spaces/${spaceId}/join`, this.baseUrl), {
1023
+ async joinSpaceByInvitation(ctx, spaceId, body, args) {
1024
+ return this._call(ctx, new URL(`/spaces/${spaceId}/join`, this.baseUrl), {
1009
1025
  ...args,
1010
1026
  body,
1011
1027
  method: "POST"
@@ -1014,8 +1030,8 @@ var EdgeHttpClient = class {
1014
1030
  //
1015
1031
  // OAuth and credentials
1016
1032
  //
1017
- async initiateOAuthFlow(body, args) {
1018
- return this._call(new URL("/oauth/initiate", this.baseUrl), {
1033
+ async initiateOAuthFlow(ctx, body, args) {
1034
+ return this._call(ctx, new URL("/oauth/initiate", this.baseUrl), {
1019
1035
  ...args,
1020
1036
  body,
1021
1037
  method: "POST"
@@ -1024,8 +1040,8 @@ var EdgeHttpClient = class {
1024
1040
  //
1025
1041
  // Spaces
1026
1042
  //
1027
- async createSpace(body, args) {
1028
- return this._call(new URL("/spaces/create", this.baseUrl), {
1043
+ async createSpace(ctx, body, args) {
1044
+ return this._call(ctx, new URL("/spaces/create", this.baseUrl), {
1029
1045
  ...args,
1030
1046
  body,
1031
1047
  method: "POST"
@@ -1034,18 +1050,18 @@ var EdgeHttpClient = class {
1034
1050
  //
1035
1051
  // Queues
1036
1052
  //
1037
- async queryQueue(subspaceTag, spaceId, query, args) {
1053
+ async queryQueue(ctx, subspaceTag, spaceId, query, args) {
1038
1054
  const queueId = query.queueIds?.[0];
1039
1055
  invariant4(queueId, "queueId required", {
1040
1056
  F: __dxlog_file6,
1041
- L: 216,
1057
+ L: 245,
1042
1058
  S: this,
1043
1059
  A: [
1044
1060
  "queueId",
1045
1061
  "'queueId required'"
1046
1062
  ]
1047
1063
  });
1048
- return this._call(createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {
1064
+ return this._call(ctx, createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query`, this.baseUrl), {
1049
1065
  after: query.after,
1050
1066
  before: query.before,
1051
1067
  limit: query.limit,
@@ -1056,8 +1072,8 @@ var EdgeHttpClient = class {
1056
1072
  method: "GET"
1057
1073
  });
1058
1074
  }
1059
- async insertIntoQueue(subspaceTag, spaceId, queueId, objects, args) {
1060
- return this._call(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
1075
+ async insertIntoQueue(ctx, subspaceTag, spaceId, queueId, objects, args) {
1076
+ return this._call(ctx, new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
1061
1077
  ...args,
1062
1078
  body: {
1063
1079
  objects
@@ -1065,8 +1081,8 @@ var EdgeHttpClient = class {
1065
1081
  method: "POST"
1066
1082
  });
1067
1083
  }
1068
- async deleteFromQueue(subspaceTag, spaceId, queueId, objectIds, args) {
1069
- return this._call(createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
1084
+ async deleteFromQueue(ctx, subspaceTag, spaceId, queueId, objectIds, args) {
1085
+ return this._call(ctx, createUrl(new URL(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, this.baseUrl), {
1070
1086
  ids: objectIds.join(",")
1071
1087
  }), {
1072
1088
  ...args,
@@ -1076,7 +1092,7 @@ var EdgeHttpClient = class {
1076
1092
  //
1077
1093
  // Functions
1078
1094
  //
1079
- async uploadFunction(pathParts, body, args) {
1095
+ async uploadFunction(ctx, pathParts, body, args) {
1080
1096
  const formData = new FormData();
1081
1097
  formData.append("name", body.name ?? "");
1082
1098
  formData.append("version", body.version);
@@ -1096,20 +1112,20 @@ var EdgeHttpClient = class {
1096
1112
  pathParts.functionId
1097
1113
  ] : []
1098
1114
  ].join("/");
1099
- return this._call(new URL(path, this.baseUrl), {
1115
+ return this._call(ctx, new URL(path, this.baseUrl), {
1100
1116
  ...args,
1101
1117
  body: formData,
1102
1118
  method: "PUT",
1103
1119
  json: false
1104
1120
  });
1105
1121
  }
1106
- async listFunctions(args) {
1107
- return this._call(new URL("/functions", this.baseUrl), {
1122
+ async listFunctions(ctx, args) {
1123
+ return this._call(ctx, new URL("/functions", this.baseUrl), {
1108
1124
  ...args,
1109
1125
  method: "GET"
1110
1126
  });
1111
1127
  }
1112
- async invokeFunction(params, input, args) {
1128
+ async invokeFunction(ctx, params, input, args) {
1113
1129
  const url = new URL(`/functions/${params.functionId}`, this.baseUrl);
1114
1130
  if (params.version) {
1115
1131
  url.searchParams.set("version", params.version);
@@ -1123,7 +1139,7 @@ var EdgeHttpClient = class {
1123
1139
  if (params.subrequestsLimit) {
1124
1140
  url.searchParams.set("subrequestsLimit", params.subrequestsLimit.toString());
1125
1141
  }
1126
- return this._call(url, {
1142
+ return this._call(ctx, url, {
1127
1143
  ...args,
1128
1144
  body: input,
1129
1145
  method: "POST"
@@ -1132,8 +1148,8 @@ var EdgeHttpClient = class {
1132
1148
  //
1133
1149
  // Workflows
1134
1150
  //
1135
- async executeWorkflow(spaceId, graphId, input, args) {
1136
- return this._call(new URL(`/workflows/${spaceId}/${graphId}`, this.baseUrl), {
1151
+ async executeWorkflow(ctx, spaceId, graphId, input, args) {
1152
+ return this._call(ctx, new URL(`/workflows/${spaceId}/${graphId}`, this.baseUrl), {
1137
1153
  ...args,
1138
1154
  body: input,
1139
1155
  method: "POST"
@@ -1142,28 +1158,41 @@ var EdgeHttpClient = class {
1142
1158
  //
1143
1159
  // Triggers
1144
1160
  //
1145
- async getCronTriggers(spaceId) {
1146
- return this._call(new URL(`/test/functions/${spaceId}/triggers/crons`, this.baseUrl), {
1161
+ async getCronTriggers(ctx, spaceId) {
1162
+ return this._call(ctx, new URL(`/functions/${spaceId}/triggers/crons`, this.baseUrl), {
1147
1163
  method: "GET"
1148
1164
  });
1149
1165
  }
1150
- async forceRunCronTrigger(spaceId, triggerId) {
1151
- return this._call(new URL(`/test/functions/${spaceId}/triggers/crons/${triggerId}/run`, this.baseUrl), {
1166
+ async forceRunCronTrigger(ctx, spaceId, triggerId) {
1167
+ return this._call(ctx, new URL(`/functions/${spaceId}/triggers/crons/${triggerId}/run`, this.baseUrl), {
1168
+ method: "POST"
1169
+ });
1170
+ }
1171
+ //
1172
+ // Query
1173
+ //
1174
+ /**
1175
+ * Execute a QueryAST query against a space.
1176
+ */
1177
+ async execQuery(ctx, spaceId, body, args) {
1178
+ return this._call(ctx, new URL(`/spaces/${spaceId}/exec-query`, this.baseUrl), {
1179
+ ...args,
1180
+ body,
1152
1181
  method: "POST"
1153
1182
  });
1154
1183
  }
1155
1184
  //
1156
1185
  // Import/Export space.
1157
1186
  //
1158
- async importBundle(spaceId, body, args) {
1159
- return this._call(new URL(`/spaces/${spaceId}/import`, this.baseUrl), {
1187
+ async importBundle(ctx, spaceId, body, args) {
1188
+ return this._call(ctx, new URL(`/spaces/${spaceId}/import`, this.baseUrl), {
1160
1189
  ...args,
1161
1190
  body,
1162
1191
  method: "PUT"
1163
1192
  });
1164
1193
  }
1165
- async exportBundle(spaceId, body, args) {
1166
- return this._call(new URL(`/spaces/${spaceId}/export`, this.baseUrl), {
1194
+ async exportBundle(ctx, spaceId, body, args) {
1195
+ return this._call(ctx, new URL(`/spaces/${spaceId}/export`, this.baseUrl), {
1167
1196
  ...args,
1168
1197
  body,
1169
1198
  method: "POST"
@@ -1176,21 +1205,18 @@ var EdgeHttpClient = class {
1176
1205
  return Function.pipe(HttpClient.get(url), withLogging, withRetryConfig, Effect2.provide(FetchHttpClient.layer), Effect2.provide(HttpConfig.default), Effect2.withSpan("EdgeHttpClient"), runAndForwardErrors);
1177
1206
  }
1178
1207
  // TODO(burdon): Refactor with effect (see edge-http-client.test.ts).
1179
- async _call(url, args) {
1208
+ async _call(ctx, url, args) {
1180
1209
  const shouldRetry = createRetryHandler(args);
1181
- const requestContext = args.context ?? Context3.default(void 0, {
1182
- F: __dxlog_file6,
1183
- L: 408
1184
- });
1185
1210
  log4("fetch", {
1186
1211
  url,
1187
1212
  request: args.body
1188
1213
  }, {
1189
1214
  F: __dxlog_file6,
1190
- L: 409,
1215
+ L: 462,
1191
1216
  S: this,
1192
1217
  C: (f, a) => f(...a)
1193
1218
  });
1219
+ const traceHeaders = getTraceHeaders(ctx);
1194
1220
  let handledAuth = false;
1195
1221
  const tryCount = 1;
1196
1222
  while (true) {
@@ -1202,14 +1228,14 @@ var EdgeHttpClient = class {
1202
1228
  this._authHeader = await this._handleUnauthorized(response2);
1203
1229
  }
1204
1230
  }
1205
- const request = createRequest(args, this._authHeader);
1231
+ const request = createRequest(args, this._authHeader, traceHeaders, this._clientTag);
1206
1232
  log4("call edge", {
1207
1233
  url,
1208
1234
  tryCount,
1209
1235
  authHeader: !!this._authHeader
1210
1236
  }, {
1211
1237
  F: __dxlog_file6,
1212
- L: 424,
1238
+ L: 479,
1213
1239
  S: this,
1214
1240
  C: (f, a) => f(...a)
1215
1241
  });
@@ -1218,7 +1244,7 @@ var EdgeHttpClient = class {
1218
1244
  const body2 = await response.clone().json();
1219
1245
  invariant4(body2, "Expected body to be present", {
1220
1246
  F: __dxlog_file6,
1221
- L: 429,
1247
+ L: 484,
1222
1248
  S: this,
1223
1249
  A: [
1224
1250
  "body",
@@ -1239,7 +1265,7 @@ var EdgeHttpClient = class {
1239
1265
  const body = response.headers.get("Content-Type") === "application/json" ? await response.clone().json() : void 0;
1240
1266
  invariant4(!body?.success, "Expected body to not be a failure response or undefined.", {
1241
1267
  F: __dxlog_file6,
1242
- L: 445,
1268
+ L: 500,
1243
1269
  S: this,
1244
1270
  A: [
1245
1271
  "!body?.success",
@@ -1253,7 +1279,7 @@ var EdgeHttpClient = class {
1253
1279
  } else {
1254
1280
  invariant4(!response.ok, "Expected response to not be ok.", {
1255
1281
  F: __dxlog_file6,
1256
- L: 452,
1282
+ L: 507,
1257
1283
  S: this,
1258
1284
  A: [
1259
1285
  "!response.ok",
@@ -1265,13 +1291,13 @@ var EdgeHttpClient = class {
1265
1291
  } catch (error) {
1266
1292
  processingError = EdgeCallFailedError.fromProcessingFailureCause(error);
1267
1293
  }
1268
- if (processingError?.isRetryable && await shouldRetry(requestContext, processingError.retryAfterMs)) {
1294
+ if (processingError?.isRetryable && await shouldRetry(ctx, processingError.retryAfterMs)) {
1269
1295
  log4.verbose("retrying edge request", {
1270
1296
  url,
1271
1297
  processingError
1272
1298
  }, {
1273
1299
  F: __dxlog_file6,
1274
- L: 460,
1300
+ L: 515,
1275
1301
  S: this,
1276
1302
  C: (f, a) => f(...a)
1277
1303
  });
@@ -1284,7 +1310,7 @@ var EdgeHttpClient = class {
1284
1310
  if (!this._edgeIdentity) {
1285
1311
  log4.warn("unauthorized response received before identity was set", void 0, {
1286
1312
  F: __dxlog_file6,
1287
- L: 469,
1313
+ L: 524,
1288
1314
  S: this,
1289
1315
  C: (f, a) => f(...a)
1290
1316
  });
@@ -1294,7 +1320,7 @@ var EdgeHttpClient = class {
1294
1320
  return encodeAuthHeader(challenge);
1295
1321
  }
1296
1322
  };
1297
- var createRequest = ({ method, body, json = true }, authHeader) => {
1323
+ var createRequest = ({ method, body, json = true }, authHeader, traceHeaders, clientTag) => {
1298
1324
  let requestBody;
1299
1325
  const headers = {};
1300
1326
  if (json) {
@@ -1308,7 +1334,7 @@ var createRequest = ({ method, body, json = true }, authHeader) => {
1308
1334
  bodySize: requestBody.length
1309
1335
  }, {
1310
1336
  F: __dxlog_file6,
1311
- L: 493,
1337
+ L: 550,
1312
1338
  S: void 0,
1313
1339
  C: (f, a) => f(...a)
1314
1340
  });
@@ -1316,12 +1342,28 @@ var createRequest = ({ method, body, json = true }, authHeader) => {
1316
1342
  if (authHeader) {
1317
1343
  headers["Authorization"] = authHeader;
1318
1344
  }
1345
+ if (traceHeaders) {
1346
+ Object.assign(headers, traceHeaders);
1347
+ }
1348
+ if (clientTag) {
1349
+ headers[EDGE_CLIENT_TAG_HEADER] = clientTag;
1350
+ }
1319
1351
  return {
1320
1352
  method,
1321
1353
  body: requestBody,
1322
1354
  headers
1323
1355
  };
1324
1356
  };
1357
+ var getTraceHeaders = (ctx) => {
1358
+ const spanId = ctx.getAttribute(TRACE_SPAN_ATTRIBUTE2);
1359
+ const otlpContext = typeof spanId === "number" ? TRACE_PROCESSOR2.remoteTracing.getSpanContext(spanId) : void 0;
1360
+ if (!otlpContext) {
1361
+ return void 0;
1362
+ }
1363
+ const headers = {};
1364
+ propagation2.inject(otlpContext, headers);
1365
+ return Object.keys(headers).length > 0 ? headers : void 0;
1366
+ };
1325
1367
  var createRetryHandler = ({ retry: retry2 }) => {
1326
1368
  if (!retry2 || retry2.count < 1) {
1327
1369
  return async () => false;