service-bridge 1.8.5-dev.49 → 2.0.0-alpha

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.
@@ -0,0 +1,2706 @@
1
+ // src/telemetry/context.ts
2
+ import { AsyncLocalStorage } from "async_hooks";
3
+ var als = new AsyncLocalStorage();
4
+ function runWithTrace(ctx, fn) {
5
+ return als.run(ctx, fn);
6
+ }
7
+
8
+ // src/telemetry/ops.ts
9
+ import { uuidv7 as uuidv72 } from "uuidv7";
10
+
11
+ // src/pb/servicebridge/v1/telemetry.ts
12
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
13
+ import {
14
+ makeGenericClientConstructor
15
+ } from "@grpc/grpc-js";
16
+ function createBaseTelemetryBatch() {
17
+ return { ops: void 0, logs: void 0, metrics: void 0, payloads: void 0 };
18
+ }
19
+ var TelemetryBatch = {
20
+ encode(message, writer = new BinaryWriter()) {
21
+ if (message.ops !== void 0) {
22
+ OpBatch.encode(message.ops, writer.uint32(10).fork()).join();
23
+ }
24
+ if (message.logs !== void 0) {
25
+ LogBatch.encode(message.logs, writer.uint32(18).fork()).join();
26
+ }
27
+ if (message.metrics !== void 0) {
28
+ MetricBatch.encode(message.metrics, writer.uint32(26).fork()).join();
29
+ }
30
+ if (message.payloads !== void 0) {
31
+ PayloadBatch.encode(message.payloads, writer.uint32(34).fork()).join();
32
+ }
33
+ return writer;
34
+ },
35
+ decode(input, length) {
36
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
37
+ const end = length === void 0 ? reader.len : reader.pos + length;
38
+ const message = createBaseTelemetryBatch();
39
+ while (reader.pos < end) {
40
+ const tag = reader.uint32();
41
+ switch (tag >>> 3) {
42
+ case 1: {
43
+ if (tag !== 10) {
44
+ break;
45
+ }
46
+ message.ops = OpBatch.decode(reader, reader.uint32());
47
+ continue;
48
+ }
49
+ case 2: {
50
+ if (tag !== 18) {
51
+ break;
52
+ }
53
+ message.logs = LogBatch.decode(reader, reader.uint32());
54
+ continue;
55
+ }
56
+ case 3: {
57
+ if (tag !== 26) {
58
+ break;
59
+ }
60
+ message.metrics = MetricBatch.decode(reader, reader.uint32());
61
+ continue;
62
+ }
63
+ case 4: {
64
+ if (tag !== 34) {
65
+ break;
66
+ }
67
+ message.payloads = PayloadBatch.decode(reader, reader.uint32());
68
+ continue;
69
+ }
70
+ }
71
+ if ((tag & 7) === 4 || tag === 0) {
72
+ break;
73
+ }
74
+ reader.skip(tag & 7);
75
+ }
76
+ return message;
77
+ },
78
+ create(base) {
79
+ return TelemetryBatch.fromPartial(base ?? {});
80
+ },
81
+ fromPartial(object) {
82
+ const message = createBaseTelemetryBatch();
83
+ message.ops = object.ops !== void 0 && object.ops !== null ? OpBatch.fromPartial(object.ops) : void 0;
84
+ message.logs = object.logs !== void 0 && object.logs !== null ? LogBatch.fromPartial(object.logs) : void 0;
85
+ message.metrics = object.metrics !== void 0 && object.metrics !== null ? MetricBatch.fromPartial(object.metrics) : void 0;
86
+ message.payloads = object.payloads !== void 0 && object.payloads !== null ? PayloadBatch.fromPartial(object.payloads) : void 0;
87
+ return message;
88
+ }
89
+ };
90
+ function createBaseOpBatch() {
91
+ return { items: [] };
92
+ }
93
+ var OpBatch = {
94
+ encode(message, writer = new BinaryWriter()) {
95
+ for (const v of message.items) {
96
+ OpReport.encode(v, writer.uint32(10).fork()).join();
97
+ }
98
+ return writer;
99
+ },
100
+ decode(input, length) {
101
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
102
+ const end = length === void 0 ? reader.len : reader.pos + length;
103
+ const message = createBaseOpBatch();
104
+ while (reader.pos < end) {
105
+ const tag = reader.uint32();
106
+ switch (tag >>> 3) {
107
+ case 1: {
108
+ if (tag !== 10) {
109
+ break;
110
+ }
111
+ message.items.push(OpReport.decode(reader, reader.uint32()));
112
+ continue;
113
+ }
114
+ }
115
+ if ((tag & 7) === 4 || tag === 0) {
116
+ break;
117
+ }
118
+ reader.skip(tag & 7);
119
+ }
120
+ return message;
121
+ },
122
+ create(base) {
123
+ return OpBatch.fromPartial(base ?? {});
124
+ },
125
+ fromPartial(object) {
126
+ const message = createBaseOpBatch();
127
+ message.items = object.items?.map((e) => OpReport.fromPartial(e)) || [];
128
+ return message;
129
+ }
130
+ };
131
+ function createBaseLogBatch() {
132
+ return { items: [] };
133
+ }
134
+ var LogBatch = {
135
+ encode(message, writer = new BinaryWriter()) {
136
+ for (const v of message.items) {
137
+ Log.encode(v, writer.uint32(10).fork()).join();
138
+ }
139
+ return writer;
140
+ },
141
+ decode(input, length) {
142
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
143
+ const end = length === void 0 ? reader.len : reader.pos + length;
144
+ const message = createBaseLogBatch();
145
+ while (reader.pos < end) {
146
+ const tag = reader.uint32();
147
+ switch (tag >>> 3) {
148
+ case 1: {
149
+ if (tag !== 10) {
150
+ break;
151
+ }
152
+ message.items.push(Log.decode(reader, reader.uint32()));
153
+ continue;
154
+ }
155
+ }
156
+ if ((tag & 7) === 4 || tag === 0) {
157
+ break;
158
+ }
159
+ reader.skip(tag & 7);
160
+ }
161
+ return message;
162
+ },
163
+ create(base) {
164
+ return LogBatch.fromPartial(base ?? {});
165
+ },
166
+ fromPartial(object) {
167
+ const message = createBaseLogBatch();
168
+ message.items = object.items?.map((e) => Log.fromPartial(e)) || [];
169
+ return message;
170
+ }
171
+ };
172
+ function createBaseMetricBatch() {
173
+ return { items: [] };
174
+ }
175
+ var MetricBatch = {
176
+ encode(message, writer = new BinaryWriter()) {
177
+ for (const v of message.items) {
178
+ MetricPoint.encode(v, writer.uint32(10).fork()).join();
179
+ }
180
+ return writer;
181
+ },
182
+ decode(input, length) {
183
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
184
+ const end = length === void 0 ? reader.len : reader.pos + length;
185
+ const message = createBaseMetricBatch();
186
+ while (reader.pos < end) {
187
+ const tag = reader.uint32();
188
+ switch (tag >>> 3) {
189
+ case 1: {
190
+ if (tag !== 10) {
191
+ break;
192
+ }
193
+ message.items.push(MetricPoint.decode(reader, reader.uint32()));
194
+ continue;
195
+ }
196
+ }
197
+ if ((tag & 7) === 4 || tag === 0) {
198
+ break;
199
+ }
200
+ reader.skip(tag & 7);
201
+ }
202
+ return message;
203
+ },
204
+ create(base) {
205
+ return MetricBatch.fromPartial(base ?? {});
206
+ },
207
+ fromPartial(object) {
208
+ const message = createBaseMetricBatch();
209
+ message.items = object.items?.map((e) => MetricPoint.fromPartial(e)) || [];
210
+ return message;
211
+ }
212
+ };
213
+ function createBasePayloadBatch() {
214
+ return { items: [] };
215
+ }
216
+ var PayloadBatch = {
217
+ encode(message, writer = new BinaryWriter()) {
218
+ for (const v of message.items) {
219
+ PayloadAttachment.encode(v, writer.uint32(10).fork()).join();
220
+ }
221
+ return writer;
222
+ },
223
+ decode(input, length) {
224
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
225
+ const end = length === void 0 ? reader.len : reader.pos + length;
226
+ const message = createBasePayloadBatch();
227
+ while (reader.pos < end) {
228
+ const tag = reader.uint32();
229
+ switch (tag >>> 3) {
230
+ case 1: {
231
+ if (tag !== 10) {
232
+ break;
233
+ }
234
+ message.items.push(PayloadAttachment.decode(reader, reader.uint32()));
235
+ continue;
236
+ }
237
+ }
238
+ if ((tag & 7) === 4 || tag === 0) {
239
+ break;
240
+ }
241
+ reader.skip(tag & 7);
242
+ }
243
+ return message;
244
+ },
245
+ create(base) {
246
+ return PayloadBatch.fromPartial(base ?? {});
247
+ },
248
+ fromPartial(object) {
249
+ const message = createBasePayloadBatch();
250
+ message.items = object.items?.map((e) => PayloadAttachment.fromPartial(e)) || [];
251
+ return message;
252
+ }
253
+ };
254
+ function createBaseOpReport() {
255
+ return {
256
+ traceId: "",
257
+ opId: "",
258
+ parentOpId: "",
259
+ channel: 0,
260
+ kind: 0,
261
+ subject: "",
262
+ peerServiceId: "",
263
+ businessKey: "",
264
+ attempt: 0,
265
+ startedAtMs: 0,
266
+ finishedAtMs: void 0,
267
+ status: 0,
268
+ statusMessage: "",
269
+ metaJson: Buffer.alloc(0),
270
+ attrsJson: Buffer.alloc(0)
271
+ };
272
+ }
273
+ var OpReport = {
274
+ encode(message, writer = new BinaryWriter()) {
275
+ if (message.traceId !== "") {
276
+ writer.uint32(10).string(message.traceId);
277
+ }
278
+ if (message.opId !== "") {
279
+ writer.uint32(18).string(message.opId);
280
+ }
281
+ if (message.parentOpId !== "") {
282
+ writer.uint32(26).string(message.parentOpId);
283
+ }
284
+ if (message.channel !== 0) {
285
+ writer.uint32(32).int32(message.channel);
286
+ }
287
+ if (message.kind !== 0) {
288
+ writer.uint32(40).uint32(message.kind);
289
+ }
290
+ if (message.subject !== "") {
291
+ writer.uint32(50).string(message.subject);
292
+ }
293
+ if (message.peerServiceId !== "") {
294
+ writer.uint32(74).string(message.peerServiceId);
295
+ }
296
+ if (message.businessKey !== "") {
297
+ writer.uint32(82).string(message.businessKey);
298
+ }
299
+ if (message.attempt !== 0) {
300
+ writer.uint32(88).int32(message.attempt);
301
+ }
302
+ if (message.startedAtMs !== 0) {
303
+ writer.uint32(96).int64(message.startedAtMs);
304
+ }
305
+ if (message.finishedAtMs !== void 0) {
306
+ writer.uint32(104).int64(message.finishedAtMs);
307
+ }
308
+ if (message.status !== 0) {
309
+ writer.uint32(112).int32(message.status);
310
+ }
311
+ if (message.statusMessage !== "") {
312
+ writer.uint32(122).string(message.statusMessage);
313
+ }
314
+ if (message.metaJson.length !== 0) {
315
+ writer.uint32(130).bytes(message.metaJson);
316
+ }
317
+ if (message.attrsJson.length !== 0) {
318
+ writer.uint32(138).bytes(message.attrsJson);
319
+ }
320
+ return writer;
321
+ },
322
+ decode(input, length) {
323
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
324
+ const end = length === void 0 ? reader.len : reader.pos + length;
325
+ const message = createBaseOpReport();
326
+ while (reader.pos < end) {
327
+ const tag = reader.uint32();
328
+ switch (tag >>> 3) {
329
+ case 1: {
330
+ if (tag !== 10) {
331
+ break;
332
+ }
333
+ message.traceId = reader.string();
334
+ continue;
335
+ }
336
+ case 2: {
337
+ if (tag !== 18) {
338
+ break;
339
+ }
340
+ message.opId = reader.string();
341
+ continue;
342
+ }
343
+ case 3: {
344
+ if (tag !== 26) {
345
+ break;
346
+ }
347
+ message.parentOpId = reader.string();
348
+ continue;
349
+ }
350
+ case 4: {
351
+ if (tag !== 32) {
352
+ break;
353
+ }
354
+ message.channel = reader.int32();
355
+ continue;
356
+ }
357
+ case 5: {
358
+ if (tag !== 40) {
359
+ break;
360
+ }
361
+ message.kind = reader.uint32();
362
+ continue;
363
+ }
364
+ case 6: {
365
+ if (tag !== 50) {
366
+ break;
367
+ }
368
+ message.subject = reader.string();
369
+ continue;
370
+ }
371
+ case 9: {
372
+ if (tag !== 74) {
373
+ break;
374
+ }
375
+ message.peerServiceId = reader.string();
376
+ continue;
377
+ }
378
+ case 10: {
379
+ if (tag !== 82) {
380
+ break;
381
+ }
382
+ message.businessKey = reader.string();
383
+ continue;
384
+ }
385
+ case 11: {
386
+ if (tag !== 88) {
387
+ break;
388
+ }
389
+ message.attempt = reader.int32();
390
+ continue;
391
+ }
392
+ case 12: {
393
+ if (tag !== 96) {
394
+ break;
395
+ }
396
+ message.startedAtMs = longToNumber(reader.int64());
397
+ continue;
398
+ }
399
+ case 13: {
400
+ if (tag !== 104) {
401
+ break;
402
+ }
403
+ message.finishedAtMs = longToNumber(reader.int64());
404
+ continue;
405
+ }
406
+ case 14: {
407
+ if (tag !== 112) {
408
+ break;
409
+ }
410
+ message.status = reader.int32();
411
+ continue;
412
+ }
413
+ case 15: {
414
+ if (tag !== 122) {
415
+ break;
416
+ }
417
+ message.statusMessage = reader.string();
418
+ continue;
419
+ }
420
+ case 16: {
421
+ if (tag !== 130) {
422
+ break;
423
+ }
424
+ message.metaJson = Buffer.from(reader.bytes());
425
+ continue;
426
+ }
427
+ case 17: {
428
+ if (tag !== 138) {
429
+ break;
430
+ }
431
+ message.attrsJson = Buffer.from(reader.bytes());
432
+ continue;
433
+ }
434
+ }
435
+ if ((tag & 7) === 4 || tag === 0) {
436
+ break;
437
+ }
438
+ reader.skip(tag & 7);
439
+ }
440
+ return message;
441
+ },
442
+ create(base) {
443
+ return OpReport.fromPartial(base ?? {});
444
+ },
445
+ fromPartial(object) {
446
+ const message = createBaseOpReport();
447
+ message.traceId = object.traceId ?? "";
448
+ message.opId = object.opId ?? "";
449
+ message.parentOpId = object.parentOpId ?? "";
450
+ message.channel = object.channel ?? 0;
451
+ message.kind = object.kind ?? 0;
452
+ message.subject = object.subject ?? "";
453
+ message.peerServiceId = object.peerServiceId ?? "";
454
+ message.businessKey = object.businessKey ?? "";
455
+ message.attempt = object.attempt ?? 0;
456
+ message.startedAtMs = object.startedAtMs ?? 0;
457
+ message.finishedAtMs = object.finishedAtMs ?? void 0;
458
+ message.status = object.status ?? 0;
459
+ message.statusMessage = object.statusMessage ?? "";
460
+ message.metaJson = object.metaJson ?? Buffer.alloc(0);
461
+ message.attrsJson = object.attrsJson ?? Buffer.alloc(0);
462
+ return message;
463
+ }
464
+ };
465
+ function createBaseLog() {
466
+ return {
467
+ atUnixMs: 0,
468
+ level: 0,
469
+ message: "",
470
+ fieldsJson: Buffer.alloc(0),
471
+ traceId: "",
472
+ opId: "",
473
+ instanceId: "",
474
+ source: ""
475
+ };
476
+ }
477
+ var Log = {
478
+ encode(message, writer = new BinaryWriter()) {
479
+ if (message.atUnixMs !== 0) {
480
+ writer.uint32(8).int64(message.atUnixMs);
481
+ }
482
+ if (message.level !== 0) {
483
+ writer.uint32(16).int32(message.level);
484
+ }
485
+ if (message.message !== "") {
486
+ writer.uint32(26).string(message.message);
487
+ }
488
+ if (message.fieldsJson.length !== 0) {
489
+ writer.uint32(34).bytes(message.fieldsJson);
490
+ }
491
+ if (message.traceId !== "") {
492
+ writer.uint32(42).string(message.traceId);
493
+ }
494
+ if (message.opId !== "") {
495
+ writer.uint32(50).string(message.opId);
496
+ }
497
+ if (message.instanceId !== "") {
498
+ writer.uint32(58).string(message.instanceId);
499
+ }
500
+ if (message.source !== "") {
501
+ writer.uint32(66).string(message.source);
502
+ }
503
+ return writer;
504
+ },
505
+ decode(input, length) {
506
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
507
+ const end = length === void 0 ? reader.len : reader.pos + length;
508
+ const message = createBaseLog();
509
+ while (reader.pos < end) {
510
+ const tag = reader.uint32();
511
+ switch (tag >>> 3) {
512
+ case 1: {
513
+ if (tag !== 8) {
514
+ break;
515
+ }
516
+ message.atUnixMs = longToNumber(reader.int64());
517
+ continue;
518
+ }
519
+ case 2: {
520
+ if (tag !== 16) {
521
+ break;
522
+ }
523
+ message.level = reader.int32();
524
+ continue;
525
+ }
526
+ case 3: {
527
+ if (tag !== 26) {
528
+ break;
529
+ }
530
+ message.message = reader.string();
531
+ continue;
532
+ }
533
+ case 4: {
534
+ if (tag !== 34) {
535
+ break;
536
+ }
537
+ message.fieldsJson = Buffer.from(reader.bytes());
538
+ continue;
539
+ }
540
+ case 5: {
541
+ if (tag !== 42) {
542
+ break;
543
+ }
544
+ message.traceId = reader.string();
545
+ continue;
546
+ }
547
+ case 6: {
548
+ if (tag !== 50) {
549
+ break;
550
+ }
551
+ message.opId = reader.string();
552
+ continue;
553
+ }
554
+ case 7: {
555
+ if (tag !== 58) {
556
+ break;
557
+ }
558
+ message.instanceId = reader.string();
559
+ continue;
560
+ }
561
+ case 8: {
562
+ if (tag !== 66) {
563
+ break;
564
+ }
565
+ message.source = reader.string();
566
+ continue;
567
+ }
568
+ }
569
+ if ((tag & 7) === 4 || tag === 0) {
570
+ break;
571
+ }
572
+ reader.skip(tag & 7);
573
+ }
574
+ return message;
575
+ },
576
+ create(base) {
577
+ return Log.fromPartial(base ?? {});
578
+ },
579
+ fromPartial(object) {
580
+ const message = createBaseLog();
581
+ message.atUnixMs = object.atUnixMs ?? 0;
582
+ message.level = object.level ?? 0;
583
+ message.message = object.message ?? "";
584
+ message.fieldsJson = object.fieldsJson ?? Buffer.alloc(0);
585
+ message.traceId = object.traceId ?? "";
586
+ message.opId = object.opId ?? "";
587
+ message.instanceId = object.instanceId ?? "";
588
+ message.source = object.source ?? "";
589
+ return message;
590
+ }
591
+ };
592
+ function createBaseMetricPoint() {
593
+ return {
594
+ atUnixMs: 0,
595
+ name: "",
596
+ kind: 0,
597
+ labels: {},
598
+ instanceId: "",
599
+ value: 0,
600
+ unit: "",
601
+ bucketsJson: Buffer.alloc(0)
602
+ };
603
+ }
604
+ var MetricPoint = {
605
+ encode(message, writer = new BinaryWriter()) {
606
+ if (message.atUnixMs !== 0) {
607
+ writer.uint32(8).int64(message.atUnixMs);
608
+ }
609
+ if (message.name !== "") {
610
+ writer.uint32(18).string(message.name);
611
+ }
612
+ if (message.kind !== 0) {
613
+ writer.uint32(24).int32(message.kind);
614
+ }
615
+ globalThis.Object.entries(message.labels).forEach(([key, value]) => {
616
+ MetricPoint_LabelsEntry.encode({ key, value }, writer.uint32(34).fork()).join();
617
+ });
618
+ if (message.instanceId !== "") {
619
+ writer.uint32(42).string(message.instanceId);
620
+ }
621
+ if (message.value !== 0) {
622
+ writer.uint32(49).double(message.value);
623
+ }
624
+ if (message.unit !== "") {
625
+ writer.uint32(58).string(message.unit);
626
+ }
627
+ if (message.bucketsJson.length !== 0) {
628
+ writer.uint32(66).bytes(message.bucketsJson);
629
+ }
630
+ return writer;
631
+ },
632
+ decode(input, length) {
633
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
634
+ const end = length === void 0 ? reader.len : reader.pos + length;
635
+ const message = createBaseMetricPoint();
636
+ while (reader.pos < end) {
637
+ const tag = reader.uint32();
638
+ switch (tag >>> 3) {
639
+ case 1: {
640
+ if (tag !== 8) {
641
+ break;
642
+ }
643
+ message.atUnixMs = longToNumber(reader.int64());
644
+ continue;
645
+ }
646
+ case 2: {
647
+ if (tag !== 18) {
648
+ break;
649
+ }
650
+ message.name = reader.string();
651
+ continue;
652
+ }
653
+ case 3: {
654
+ if (tag !== 24) {
655
+ break;
656
+ }
657
+ message.kind = reader.int32();
658
+ continue;
659
+ }
660
+ case 4: {
661
+ if (tag !== 34) {
662
+ break;
663
+ }
664
+ const entry4 = MetricPoint_LabelsEntry.decode(reader, reader.uint32());
665
+ if (entry4.value !== void 0) {
666
+ message.labels[entry4.key] = entry4.value;
667
+ }
668
+ continue;
669
+ }
670
+ case 5: {
671
+ if (tag !== 42) {
672
+ break;
673
+ }
674
+ message.instanceId = reader.string();
675
+ continue;
676
+ }
677
+ case 6: {
678
+ if (tag !== 49) {
679
+ break;
680
+ }
681
+ message.value = reader.double();
682
+ continue;
683
+ }
684
+ case 7: {
685
+ if (tag !== 58) {
686
+ break;
687
+ }
688
+ message.unit = reader.string();
689
+ continue;
690
+ }
691
+ case 8: {
692
+ if (tag !== 66) {
693
+ break;
694
+ }
695
+ message.bucketsJson = Buffer.from(reader.bytes());
696
+ continue;
697
+ }
698
+ }
699
+ if ((tag & 7) === 4 || tag === 0) {
700
+ break;
701
+ }
702
+ reader.skip(tag & 7);
703
+ }
704
+ return message;
705
+ },
706
+ create(base) {
707
+ return MetricPoint.fromPartial(base ?? {});
708
+ },
709
+ fromPartial(object) {
710
+ const message = createBaseMetricPoint();
711
+ message.atUnixMs = object.atUnixMs ?? 0;
712
+ message.name = object.name ?? "";
713
+ message.kind = object.kind ?? 0;
714
+ message.labels = globalThis.Object.entries(object.labels ?? {}).reduce(
715
+ (acc, [key, value]) => {
716
+ if (value !== void 0) {
717
+ acc[key] = globalThis.String(value);
718
+ }
719
+ return acc;
720
+ },
721
+ {}
722
+ );
723
+ message.instanceId = object.instanceId ?? "";
724
+ message.value = object.value ?? 0;
725
+ message.unit = object.unit ?? "";
726
+ message.bucketsJson = object.bucketsJson ?? Buffer.alloc(0);
727
+ return message;
728
+ }
729
+ };
730
+ function createBaseMetricPoint_LabelsEntry() {
731
+ return { key: "", value: "" };
732
+ }
733
+ var MetricPoint_LabelsEntry = {
734
+ encode(message, writer = new BinaryWriter()) {
735
+ if (message.key !== "") {
736
+ writer.uint32(10).string(message.key);
737
+ }
738
+ if (message.value !== "") {
739
+ writer.uint32(18).string(message.value);
740
+ }
741
+ return writer;
742
+ },
743
+ decode(input, length) {
744
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
745
+ const end = length === void 0 ? reader.len : reader.pos + length;
746
+ const message = createBaseMetricPoint_LabelsEntry();
747
+ while (reader.pos < end) {
748
+ const tag = reader.uint32();
749
+ switch (tag >>> 3) {
750
+ case 1: {
751
+ if (tag !== 10) {
752
+ break;
753
+ }
754
+ message.key = reader.string();
755
+ continue;
756
+ }
757
+ case 2: {
758
+ if (tag !== 18) {
759
+ break;
760
+ }
761
+ message.value = reader.string();
762
+ continue;
763
+ }
764
+ }
765
+ if ((tag & 7) === 4 || tag === 0) {
766
+ break;
767
+ }
768
+ reader.skip(tag & 7);
769
+ }
770
+ return message;
771
+ },
772
+ create(base) {
773
+ return MetricPoint_LabelsEntry.fromPartial(base ?? {});
774
+ },
775
+ fromPartial(object) {
776
+ const message = createBaseMetricPoint_LabelsEntry();
777
+ message.key = object.key ?? "";
778
+ message.value = object.value ?? "";
779
+ return message;
780
+ }
781
+ };
782
+ function createBasePayloadAttachment() {
783
+ return { traceId: "", opId: "", direction: 0, bytes: Buffer.alloc(0), originalSize: 0, contractHash: "" };
784
+ }
785
+ var PayloadAttachment = {
786
+ encode(message, writer = new BinaryWriter()) {
787
+ if (message.traceId !== "") {
788
+ writer.uint32(10).string(message.traceId);
789
+ }
790
+ if (message.opId !== "") {
791
+ writer.uint32(18).string(message.opId);
792
+ }
793
+ if (message.direction !== 0) {
794
+ writer.uint32(24).uint32(message.direction);
795
+ }
796
+ if (message.bytes.length !== 0) {
797
+ writer.uint32(34).bytes(message.bytes);
798
+ }
799
+ if (message.originalSize !== 0) {
800
+ writer.uint32(40).int32(message.originalSize);
801
+ }
802
+ if (message.contractHash !== "") {
803
+ writer.uint32(50).string(message.contractHash);
804
+ }
805
+ return writer;
806
+ },
807
+ decode(input, length) {
808
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
809
+ const end = length === void 0 ? reader.len : reader.pos + length;
810
+ const message = createBasePayloadAttachment();
811
+ while (reader.pos < end) {
812
+ const tag = reader.uint32();
813
+ switch (tag >>> 3) {
814
+ case 1: {
815
+ if (tag !== 10) {
816
+ break;
817
+ }
818
+ message.traceId = reader.string();
819
+ continue;
820
+ }
821
+ case 2: {
822
+ if (tag !== 18) {
823
+ break;
824
+ }
825
+ message.opId = reader.string();
826
+ continue;
827
+ }
828
+ case 3: {
829
+ if (tag !== 24) {
830
+ break;
831
+ }
832
+ message.direction = reader.uint32();
833
+ continue;
834
+ }
835
+ case 4: {
836
+ if (tag !== 34) {
837
+ break;
838
+ }
839
+ message.bytes = Buffer.from(reader.bytes());
840
+ continue;
841
+ }
842
+ case 5: {
843
+ if (tag !== 40) {
844
+ break;
845
+ }
846
+ message.originalSize = reader.int32();
847
+ continue;
848
+ }
849
+ case 6: {
850
+ if (tag !== 50) {
851
+ break;
852
+ }
853
+ message.contractHash = reader.string();
854
+ continue;
855
+ }
856
+ }
857
+ if ((tag & 7) === 4 || tag === 0) {
858
+ break;
859
+ }
860
+ reader.skip(tag & 7);
861
+ }
862
+ return message;
863
+ },
864
+ create(base) {
865
+ return PayloadAttachment.fromPartial(base ?? {});
866
+ },
867
+ fromPartial(object) {
868
+ const message = createBasePayloadAttachment();
869
+ message.traceId = object.traceId ?? "";
870
+ message.opId = object.opId ?? "";
871
+ message.direction = object.direction ?? 0;
872
+ message.bytes = object.bytes ?? Buffer.alloc(0);
873
+ message.originalSize = object.originalSize ?? 0;
874
+ message.contractHash = object.contractHash ?? "";
875
+ return message;
876
+ }
877
+ };
878
+ function createBaseTelemetryAck() {
879
+ return { receivedBytesHighWater: 0, backpressureLevel: 0, dropCountServerSide: 0, drainReason: "" };
880
+ }
881
+ var TelemetryAck = {
882
+ encode(message, writer = new BinaryWriter()) {
883
+ if (message.receivedBytesHighWater !== 0) {
884
+ writer.uint32(8).uint64(message.receivedBytesHighWater);
885
+ }
886
+ if (message.backpressureLevel !== 0) {
887
+ writer.uint32(16).uint32(message.backpressureLevel);
888
+ }
889
+ if (message.dropCountServerSide !== 0) {
890
+ writer.uint32(24).uint64(message.dropCountServerSide);
891
+ }
892
+ if (message.drainReason !== "") {
893
+ writer.uint32(34).string(message.drainReason);
894
+ }
895
+ return writer;
896
+ },
897
+ decode(input, length) {
898
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
899
+ const end = length === void 0 ? reader.len : reader.pos + length;
900
+ const message = createBaseTelemetryAck();
901
+ while (reader.pos < end) {
902
+ const tag = reader.uint32();
903
+ switch (tag >>> 3) {
904
+ case 1: {
905
+ if (tag !== 8) {
906
+ break;
907
+ }
908
+ message.receivedBytesHighWater = longToNumber(reader.uint64());
909
+ continue;
910
+ }
911
+ case 2: {
912
+ if (tag !== 16) {
913
+ break;
914
+ }
915
+ message.backpressureLevel = reader.uint32();
916
+ continue;
917
+ }
918
+ case 3: {
919
+ if (tag !== 24) {
920
+ break;
921
+ }
922
+ message.dropCountServerSide = longToNumber(reader.uint64());
923
+ continue;
924
+ }
925
+ case 4: {
926
+ if (tag !== 34) {
927
+ break;
928
+ }
929
+ message.drainReason = reader.string();
930
+ continue;
931
+ }
932
+ }
933
+ if ((tag & 7) === 4 || tag === 0) {
934
+ break;
935
+ }
936
+ reader.skip(tag & 7);
937
+ }
938
+ return message;
939
+ },
940
+ create(base) {
941
+ return TelemetryAck.fromPartial(base ?? {});
942
+ },
943
+ fromPartial(object) {
944
+ const message = createBaseTelemetryAck();
945
+ message.receivedBytesHighWater = object.receivedBytesHighWater ?? 0;
946
+ message.backpressureLevel = object.backpressureLevel ?? 0;
947
+ message.dropCountServerSide = object.dropCountServerSide ?? 0;
948
+ message.drainReason = object.drainReason ?? "";
949
+ return message;
950
+ }
951
+ };
952
+ function createBaseListTracesRequest() {
953
+ return {
954
+ channelFilter: [],
955
+ statusFilter: [],
956
+ fromMs: 0,
957
+ toMs: 0,
958
+ serviceId: "",
959
+ textQuery: "",
960
+ limit: 0,
961
+ cursor: ""
962
+ };
963
+ }
964
+ var ListTracesRequest = {
965
+ encode(message, writer = new BinaryWriter()) {
966
+ writer.uint32(10).fork();
967
+ for (const v of message.channelFilter) {
968
+ writer.int32(v);
969
+ }
970
+ writer.join();
971
+ writer.uint32(18).fork();
972
+ for (const v of message.statusFilter) {
973
+ writer.int32(v);
974
+ }
975
+ writer.join();
976
+ if (message.fromMs !== 0) {
977
+ writer.uint32(24).int64(message.fromMs);
978
+ }
979
+ if (message.toMs !== 0) {
980
+ writer.uint32(32).int64(message.toMs);
981
+ }
982
+ if (message.serviceId !== "") {
983
+ writer.uint32(42).string(message.serviceId);
984
+ }
985
+ if (message.textQuery !== "") {
986
+ writer.uint32(50).string(message.textQuery);
987
+ }
988
+ if (message.limit !== 0) {
989
+ writer.uint32(56).uint32(message.limit);
990
+ }
991
+ if (message.cursor !== "") {
992
+ writer.uint32(66).string(message.cursor);
993
+ }
994
+ return writer;
995
+ },
996
+ decode(input, length) {
997
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
998
+ const end = length === void 0 ? reader.len : reader.pos + length;
999
+ const message = createBaseListTracesRequest();
1000
+ while (reader.pos < end) {
1001
+ const tag = reader.uint32();
1002
+ switch (tag >>> 3) {
1003
+ case 1: {
1004
+ if (tag === 8) {
1005
+ message.channelFilter.push(reader.int32());
1006
+ continue;
1007
+ }
1008
+ if (tag === 10) {
1009
+ const end2 = reader.uint32() + reader.pos;
1010
+ while (reader.pos < end2) {
1011
+ message.channelFilter.push(reader.int32());
1012
+ }
1013
+ continue;
1014
+ }
1015
+ break;
1016
+ }
1017
+ case 2: {
1018
+ if (tag === 16) {
1019
+ message.statusFilter.push(reader.int32());
1020
+ continue;
1021
+ }
1022
+ if (tag === 18) {
1023
+ const end2 = reader.uint32() + reader.pos;
1024
+ while (reader.pos < end2) {
1025
+ message.statusFilter.push(reader.int32());
1026
+ }
1027
+ continue;
1028
+ }
1029
+ break;
1030
+ }
1031
+ case 3: {
1032
+ if (tag !== 24) {
1033
+ break;
1034
+ }
1035
+ message.fromMs = longToNumber(reader.int64());
1036
+ continue;
1037
+ }
1038
+ case 4: {
1039
+ if (tag !== 32) {
1040
+ break;
1041
+ }
1042
+ message.toMs = longToNumber(reader.int64());
1043
+ continue;
1044
+ }
1045
+ case 5: {
1046
+ if (tag !== 42) {
1047
+ break;
1048
+ }
1049
+ message.serviceId = reader.string();
1050
+ continue;
1051
+ }
1052
+ case 6: {
1053
+ if (tag !== 50) {
1054
+ break;
1055
+ }
1056
+ message.textQuery = reader.string();
1057
+ continue;
1058
+ }
1059
+ case 7: {
1060
+ if (tag !== 56) {
1061
+ break;
1062
+ }
1063
+ message.limit = reader.uint32();
1064
+ continue;
1065
+ }
1066
+ case 8: {
1067
+ if (tag !== 66) {
1068
+ break;
1069
+ }
1070
+ message.cursor = reader.string();
1071
+ continue;
1072
+ }
1073
+ }
1074
+ if ((tag & 7) === 4 || tag === 0) {
1075
+ break;
1076
+ }
1077
+ reader.skip(tag & 7);
1078
+ }
1079
+ return message;
1080
+ },
1081
+ create(base) {
1082
+ return ListTracesRequest.fromPartial(base ?? {});
1083
+ },
1084
+ fromPartial(object) {
1085
+ const message = createBaseListTracesRequest();
1086
+ message.channelFilter = object.channelFilter?.map((e) => e) || [];
1087
+ message.statusFilter = object.statusFilter?.map((e) => e) || [];
1088
+ message.fromMs = object.fromMs ?? 0;
1089
+ message.toMs = object.toMs ?? 0;
1090
+ message.serviceId = object.serviceId ?? "";
1091
+ message.textQuery = object.textQuery ?? "";
1092
+ message.limit = object.limit ?? 0;
1093
+ message.cursor = object.cursor ?? "";
1094
+ return message;
1095
+ }
1096
+ };
1097
+ function createBaseTraceSummary() {
1098
+ return {
1099
+ traceId: "",
1100
+ rootSubject: "",
1101
+ rootServiceId: "",
1102
+ startedAtMs: 0,
1103
+ durationMs: 0,
1104
+ opCount: 0,
1105
+ overallStatus: 0,
1106
+ hasRunning: false
1107
+ };
1108
+ }
1109
+ var TraceSummary = {
1110
+ encode(message, writer = new BinaryWriter()) {
1111
+ if (message.traceId !== "") {
1112
+ writer.uint32(10).string(message.traceId);
1113
+ }
1114
+ if (message.rootSubject !== "") {
1115
+ writer.uint32(18).string(message.rootSubject);
1116
+ }
1117
+ if (message.rootServiceId !== "") {
1118
+ writer.uint32(26).string(message.rootServiceId);
1119
+ }
1120
+ if (message.startedAtMs !== 0) {
1121
+ writer.uint32(32).int64(message.startedAtMs);
1122
+ }
1123
+ if (message.durationMs !== 0) {
1124
+ writer.uint32(40).int64(message.durationMs);
1125
+ }
1126
+ if (message.opCount !== 0) {
1127
+ writer.uint32(48).uint32(message.opCount);
1128
+ }
1129
+ if (message.overallStatus !== 0) {
1130
+ writer.uint32(56).int32(message.overallStatus);
1131
+ }
1132
+ if (message.hasRunning !== false) {
1133
+ writer.uint32(64).bool(message.hasRunning);
1134
+ }
1135
+ return writer;
1136
+ },
1137
+ decode(input, length) {
1138
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1139
+ const end = length === void 0 ? reader.len : reader.pos + length;
1140
+ const message = createBaseTraceSummary();
1141
+ while (reader.pos < end) {
1142
+ const tag = reader.uint32();
1143
+ switch (tag >>> 3) {
1144
+ case 1: {
1145
+ if (tag !== 10) {
1146
+ break;
1147
+ }
1148
+ message.traceId = reader.string();
1149
+ continue;
1150
+ }
1151
+ case 2: {
1152
+ if (tag !== 18) {
1153
+ break;
1154
+ }
1155
+ message.rootSubject = reader.string();
1156
+ continue;
1157
+ }
1158
+ case 3: {
1159
+ if (tag !== 26) {
1160
+ break;
1161
+ }
1162
+ message.rootServiceId = reader.string();
1163
+ continue;
1164
+ }
1165
+ case 4: {
1166
+ if (tag !== 32) {
1167
+ break;
1168
+ }
1169
+ message.startedAtMs = longToNumber(reader.int64());
1170
+ continue;
1171
+ }
1172
+ case 5: {
1173
+ if (tag !== 40) {
1174
+ break;
1175
+ }
1176
+ message.durationMs = longToNumber(reader.int64());
1177
+ continue;
1178
+ }
1179
+ case 6: {
1180
+ if (tag !== 48) {
1181
+ break;
1182
+ }
1183
+ message.opCount = reader.uint32();
1184
+ continue;
1185
+ }
1186
+ case 7: {
1187
+ if (tag !== 56) {
1188
+ break;
1189
+ }
1190
+ message.overallStatus = reader.int32();
1191
+ continue;
1192
+ }
1193
+ case 8: {
1194
+ if (tag !== 64) {
1195
+ break;
1196
+ }
1197
+ message.hasRunning = reader.bool();
1198
+ continue;
1199
+ }
1200
+ }
1201
+ if ((tag & 7) === 4 || tag === 0) {
1202
+ break;
1203
+ }
1204
+ reader.skip(tag & 7);
1205
+ }
1206
+ return message;
1207
+ },
1208
+ create(base) {
1209
+ return TraceSummary.fromPartial(base ?? {});
1210
+ },
1211
+ fromPartial(object) {
1212
+ const message = createBaseTraceSummary();
1213
+ message.traceId = object.traceId ?? "";
1214
+ message.rootSubject = object.rootSubject ?? "";
1215
+ message.rootServiceId = object.rootServiceId ?? "";
1216
+ message.startedAtMs = object.startedAtMs ?? 0;
1217
+ message.durationMs = object.durationMs ?? 0;
1218
+ message.opCount = object.opCount ?? 0;
1219
+ message.overallStatus = object.overallStatus ?? 0;
1220
+ message.hasRunning = object.hasRunning ?? false;
1221
+ return message;
1222
+ }
1223
+ };
1224
+ function createBaseListTracesResponse() {
1225
+ return { traces: [], nextCursor: "" };
1226
+ }
1227
+ var ListTracesResponse = {
1228
+ encode(message, writer = new BinaryWriter()) {
1229
+ for (const v of message.traces) {
1230
+ TraceSummary.encode(v, writer.uint32(10).fork()).join();
1231
+ }
1232
+ if (message.nextCursor !== "") {
1233
+ writer.uint32(18).string(message.nextCursor);
1234
+ }
1235
+ return writer;
1236
+ },
1237
+ decode(input, length) {
1238
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1239
+ const end = length === void 0 ? reader.len : reader.pos + length;
1240
+ const message = createBaseListTracesResponse();
1241
+ while (reader.pos < end) {
1242
+ const tag = reader.uint32();
1243
+ switch (tag >>> 3) {
1244
+ case 1: {
1245
+ if (tag !== 10) {
1246
+ break;
1247
+ }
1248
+ message.traces.push(TraceSummary.decode(reader, reader.uint32()));
1249
+ continue;
1250
+ }
1251
+ case 2: {
1252
+ if (tag !== 18) {
1253
+ break;
1254
+ }
1255
+ message.nextCursor = reader.string();
1256
+ continue;
1257
+ }
1258
+ }
1259
+ if ((tag & 7) === 4 || tag === 0) {
1260
+ break;
1261
+ }
1262
+ reader.skip(tag & 7);
1263
+ }
1264
+ return message;
1265
+ },
1266
+ create(base) {
1267
+ return ListTracesResponse.fromPartial(base ?? {});
1268
+ },
1269
+ fromPartial(object) {
1270
+ const message = createBaseListTracesResponse();
1271
+ message.traces = object.traces?.map((e) => TraceSummary.fromPartial(e)) || [];
1272
+ message.nextCursor = object.nextCursor ?? "";
1273
+ return message;
1274
+ }
1275
+ };
1276
+ function createBaseGetTraceRequest() {
1277
+ return { traceId: "", limit: 0, cursor: "" };
1278
+ }
1279
+ var GetTraceRequest = {
1280
+ encode(message, writer = new BinaryWriter()) {
1281
+ if (message.traceId !== "") {
1282
+ writer.uint32(10).string(message.traceId);
1283
+ }
1284
+ if (message.limit !== 0) {
1285
+ writer.uint32(16).uint32(message.limit);
1286
+ }
1287
+ if (message.cursor !== "") {
1288
+ writer.uint32(26).string(message.cursor);
1289
+ }
1290
+ return writer;
1291
+ },
1292
+ decode(input, length) {
1293
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1294
+ const end = length === void 0 ? reader.len : reader.pos + length;
1295
+ const message = createBaseGetTraceRequest();
1296
+ while (reader.pos < end) {
1297
+ const tag = reader.uint32();
1298
+ switch (tag >>> 3) {
1299
+ case 1: {
1300
+ if (tag !== 10) {
1301
+ break;
1302
+ }
1303
+ message.traceId = reader.string();
1304
+ continue;
1305
+ }
1306
+ case 2: {
1307
+ if (tag !== 16) {
1308
+ break;
1309
+ }
1310
+ message.limit = reader.uint32();
1311
+ continue;
1312
+ }
1313
+ case 3: {
1314
+ if (tag !== 26) {
1315
+ break;
1316
+ }
1317
+ message.cursor = reader.string();
1318
+ continue;
1319
+ }
1320
+ }
1321
+ if ((tag & 7) === 4 || tag === 0) {
1322
+ break;
1323
+ }
1324
+ reader.skip(tag & 7);
1325
+ }
1326
+ return message;
1327
+ },
1328
+ create(base) {
1329
+ return GetTraceRequest.fromPartial(base ?? {});
1330
+ },
1331
+ fromPartial(object) {
1332
+ const message = createBaseGetTraceRequest();
1333
+ message.traceId = object.traceId ?? "";
1334
+ message.limit = object.limit ?? 0;
1335
+ message.cursor = object.cursor ?? "";
1336
+ return message;
1337
+ }
1338
+ };
1339
+ function createBaseOperationView() {
1340
+ return {
1341
+ opId: "",
1342
+ traceId: "",
1343
+ parentOpId: "",
1344
+ channel: 0,
1345
+ kind: 0,
1346
+ subject: "",
1347
+ actorServiceId: "",
1348
+ actorInstanceId: "",
1349
+ peerServiceId: "",
1350
+ businessKey: "",
1351
+ attempt: 0,
1352
+ startedAtMs: 0,
1353
+ finishedAtMs: void 0,
1354
+ status: 0,
1355
+ statusMessage: "",
1356
+ metaJson: Buffer.alloc(0),
1357
+ attrsJson: Buffer.alloc(0)
1358
+ };
1359
+ }
1360
+ var OperationView = {
1361
+ encode(message, writer = new BinaryWriter()) {
1362
+ if (message.opId !== "") {
1363
+ writer.uint32(10).string(message.opId);
1364
+ }
1365
+ if (message.traceId !== "") {
1366
+ writer.uint32(18).string(message.traceId);
1367
+ }
1368
+ if (message.parentOpId !== "") {
1369
+ writer.uint32(26).string(message.parentOpId);
1370
+ }
1371
+ if (message.channel !== 0) {
1372
+ writer.uint32(32).int32(message.channel);
1373
+ }
1374
+ if (message.kind !== 0) {
1375
+ writer.uint32(40).uint32(message.kind);
1376
+ }
1377
+ if (message.subject !== "") {
1378
+ writer.uint32(50).string(message.subject);
1379
+ }
1380
+ if (message.actorServiceId !== "") {
1381
+ writer.uint32(58).string(message.actorServiceId);
1382
+ }
1383
+ if (message.actorInstanceId !== "") {
1384
+ writer.uint32(66).string(message.actorInstanceId);
1385
+ }
1386
+ if (message.peerServiceId !== "") {
1387
+ writer.uint32(74).string(message.peerServiceId);
1388
+ }
1389
+ if (message.businessKey !== "") {
1390
+ writer.uint32(82).string(message.businessKey);
1391
+ }
1392
+ if (message.attempt !== 0) {
1393
+ writer.uint32(88).int32(message.attempt);
1394
+ }
1395
+ if (message.startedAtMs !== 0) {
1396
+ writer.uint32(96).int64(message.startedAtMs);
1397
+ }
1398
+ if (message.finishedAtMs !== void 0) {
1399
+ writer.uint32(104).int64(message.finishedAtMs);
1400
+ }
1401
+ if (message.status !== 0) {
1402
+ writer.uint32(112).int32(message.status);
1403
+ }
1404
+ if (message.statusMessage !== "") {
1405
+ writer.uint32(122).string(message.statusMessage);
1406
+ }
1407
+ if (message.metaJson.length !== 0) {
1408
+ writer.uint32(130).bytes(message.metaJson);
1409
+ }
1410
+ if (message.attrsJson.length !== 0) {
1411
+ writer.uint32(138).bytes(message.attrsJson);
1412
+ }
1413
+ return writer;
1414
+ },
1415
+ decode(input, length) {
1416
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1417
+ const end = length === void 0 ? reader.len : reader.pos + length;
1418
+ const message = createBaseOperationView();
1419
+ while (reader.pos < end) {
1420
+ const tag = reader.uint32();
1421
+ switch (tag >>> 3) {
1422
+ case 1: {
1423
+ if (tag !== 10) {
1424
+ break;
1425
+ }
1426
+ message.opId = reader.string();
1427
+ continue;
1428
+ }
1429
+ case 2: {
1430
+ if (tag !== 18) {
1431
+ break;
1432
+ }
1433
+ message.traceId = reader.string();
1434
+ continue;
1435
+ }
1436
+ case 3: {
1437
+ if (tag !== 26) {
1438
+ break;
1439
+ }
1440
+ message.parentOpId = reader.string();
1441
+ continue;
1442
+ }
1443
+ case 4: {
1444
+ if (tag !== 32) {
1445
+ break;
1446
+ }
1447
+ message.channel = reader.int32();
1448
+ continue;
1449
+ }
1450
+ case 5: {
1451
+ if (tag !== 40) {
1452
+ break;
1453
+ }
1454
+ message.kind = reader.uint32();
1455
+ continue;
1456
+ }
1457
+ case 6: {
1458
+ if (tag !== 50) {
1459
+ break;
1460
+ }
1461
+ message.subject = reader.string();
1462
+ continue;
1463
+ }
1464
+ case 7: {
1465
+ if (tag !== 58) {
1466
+ break;
1467
+ }
1468
+ message.actorServiceId = reader.string();
1469
+ continue;
1470
+ }
1471
+ case 8: {
1472
+ if (tag !== 66) {
1473
+ break;
1474
+ }
1475
+ message.actorInstanceId = reader.string();
1476
+ continue;
1477
+ }
1478
+ case 9: {
1479
+ if (tag !== 74) {
1480
+ break;
1481
+ }
1482
+ message.peerServiceId = reader.string();
1483
+ continue;
1484
+ }
1485
+ case 10: {
1486
+ if (tag !== 82) {
1487
+ break;
1488
+ }
1489
+ message.businessKey = reader.string();
1490
+ continue;
1491
+ }
1492
+ case 11: {
1493
+ if (tag !== 88) {
1494
+ break;
1495
+ }
1496
+ message.attempt = reader.int32();
1497
+ continue;
1498
+ }
1499
+ case 12: {
1500
+ if (tag !== 96) {
1501
+ break;
1502
+ }
1503
+ message.startedAtMs = longToNumber(reader.int64());
1504
+ continue;
1505
+ }
1506
+ case 13: {
1507
+ if (tag !== 104) {
1508
+ break;
1509
+ }
1510
+ message.finishedAtMs = longToNumber(reader.int64());
1511
+ continue;
1512
+ }
1513
+ case 14: {
1514
+ if (tag !== 112) {
1515
+ break;
1516
+ }
1517
+ message.status = reader.int32();
1518
+ continue;
1519
+ }
1520
+ case 15: {
1521
+ if (tag !== 122) {
1522
+ break;
1523
+ }
1524
+ message.statusMessage = reader.string();
1525
+ continue;
1526
+ }
1527
+ case 16: {
1528
+ if (tag !== 130) {
1529
+ break;
1530
+ }
1531
+ message.metaJson = Buffer.from(reader.bytes());
1532
+ continue;
1533
+ }
1534
+ case 17: {
1535
+ if (tag !== 138) {
1536
+ break;
1537
+ }
1538
+ message.attrsJson = Buffer.from(reader.bytes());
1539
+ continue;
1540
+ }
1541
+ }
1542
+ if ((tag & 7) === 4 || tag === 0) {
1543
+ break;
1544
+ }
1545
+ reader.skip(tag & 7);
1546
+ }
1547
+ return message;
1548
+ },
1549
+ create(base) {
1550
+ return OperationView.fromPartial(base ?? {});
1551
+ },
1552
+ fromPartial(object) {
1553
+ const message = createBaseOperationView();
1554
+ message.opId = object.opId ?? "";
1555
+ message.traceId = object.traceId ?? "";
1556
+ message.parentOpId = object.parentOpId ?? "";
1557
+ message.channel = object.channel ?? 0;
1558
+ message.kind = object.kind ?? 0;
1559
+ message.subject = object.subject ?? "";
1560
+ message.actorServiceId = object.actorServiceId ?? "";
1561
+ message.actorInstanceId = object.actorInstanceId ?? "";
1562
+ message.peerServiceId = object.peerServiceId ?? "";
1563
+ message.businessKey = object.businessKey ?? "";
1564
+ message.attempt = object.attempt ?? 0;
1565
+ message.startedAtMs = object.startedAtMs ?? 0;
1566
+ message.finishedAtMs = object.finishedAtMs ?? void 0;
1567
+ message.status = object.status ?? 0;
1568
+ message.statusMessage = object.statusMessage ?? "";
1569
+ message.metaJson = object.metaJson ?? Buffer.alloc(0);
1570
+ message.attrsJson = object.attrsJson ?? Buffer.alloc(0);
1571
+ return message;
1572
+ }
1573
+ };
1574
+ function createBaseGetTraceResponse() {
1575
+ return { ops: [], nextCursor: "", truncated: false };
1576
+ }
1577
+ var GetTraceResponse = {
1578
+ encode(message, writer = new BinaryWriter()) {
1579
+ for (const v of message.ops) {
1580
+ OperationView.encode(v, writer.uint32(10).fork()).join();
1581
+ }
1582
+ if (message.nextCursor !== "") {
1583
+ writer.uint32(18).string(message.nextCursor);
1584
+ }
1585
+ if (message.truncated !== false) {
1586
+ writer.uint32(24).bool(message.truncated);
1587
+ }
1588
+ return writer;
1589
+ },
1590
+ decode(input, length) {
1591
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1592
+ const end = length === void 0 ? reader.len : reader.pos + length;
1593
+ const message = createBaseGetTraceResponse();
1594
+ while (reader.pos < end) {
1595
+ const tag = reader.uint32();
1596
+ switch (tag >>> 3) {
1597
+ case 1: {
1598
+ if (tag !== 10) {
1599
+ break;
1600
+ }
1601
+ message.ops.push(OperationView.decode(reader, reader.uint32()));
1602
+ continue;
1603
+ }
1604
+ case 2: {
1605
+ if (tag !== 18) {
1606
+ break;
1607
+ }
1608
+ message.nextCursor = reader.string();
1609
+ continue;
1610
+ }
1611
+ case 3: {
1612
+ if (tag !== 24) {
1613
+ break;
1614
+ }
1615
+ message.truncated = reader.bool();
1616
+ continue;
1617
+ }
1618
+ }
1619
+ if ((tag & 7) === 4 || tag === 0) {
1620
+ break;
1621
+ }
1622
+ reader.skip(tag & 7);
1623
+ }
1624
+ return message;
1625
+ },
1626
+ create(base) {
1627
+ return GetTraceResponse.fromPartial(base ?? {});
1628
+ },
1629
+ fromPartial(object) {
1630
+ const message = createBaseGetTraceResponse();
1631
+ message.ops = object.ops?.map((e) => OperationView.fromPartial(e)) || [];
1632
+ message.nextCursor = object.nextCursor ?? "";
1633
+ message.truncated = object.truncated ?? false;
1634
+ return message;
1635
+ }
1636
+ };
1637
+ function createBaseGetOperationRequest() {
1638
+ return { opId: "" };
1639
+ }
1640
+ var GetOperationRequest = {
1641
+ encode(message, writer = new BinaryWriter()) {
1642
+ if (message.opId !== "") {
1643
+ writer.uint32(10).string(message.opId);
1644
+ }
1645
+ return writer;
1646
+ },
1647
+ decode(input, length) {
1648
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1649
+ const end = length === void 0 ? reader.len : reader.pos + length;
1650
+ const message = createBaseGetOperationRequest();
1651
+ while (reader.pos < end) {
1652
+ const tag = reader.uint32();
1653
+ switch (tag >>> 3) {
1654
+ case 1: {
1655
+ if (tag !== 10) {
1656
+ break;
1657
+ }
1658
+ message.opId = reader.string();
1659
+ continue;
1660
+ }
1661
+ }
1662
+ if ((tag & 7) === 4 || tag === 0) {
1663
+ break;
1664
+ }
1665
+ reader.skip(tag & 7);
1666
+ }
1667
+ return message;
1668
+ },
1669
+ create(base) {
1670
+ return GetOperationRequest.fromPartial(base ?? {});
1671
+ },
1672
+ fromPartial(object) {
1673
+ const message = createBaseGetOperationRequest();
1674
+ message.opId = object.opId ?? "";
1675
+ return message;
1676
+ }
1677
+ };
1678
+ function createBaseGetOperationResponse() {
1679
+ return { op: void 0 };
1680
+ }
1681
+ var GetOperationResponse = {
1682
+ encode(message, writer = new BinaryWriter()) {
1683
+ if (message.op !== void 0) {
1684
+ OperationView.encode(message.op, writer.uint32(10).fork()).join();
1685
+ }
1686
+ return writer;
1687
+ },
1688
+ decode(input, length) {
1689
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1690
+ const end = length === void 0 ? reader.len : reader.pos + length;
1691
+ const message = createBaseGetOperationResponse();
1692
+ while (reader.pos < end) {
1693
+ const tag = reader.uint32();
1694
+ switch (tag >>> 3) {
1695
+ case 1: {
1696
+ if (tag !== 10) {
1697
+ break;
1698
+ }
1699
+ message.op = OperationView.decode(reader, reader.uint32());
1700
+ continue;
1701
+ }
1702
+ }
1703
+ if ((tag & 7) === 4 || tag === 0) {
1704
+ break;
1705
+ }
1706
+ reader.skip(tag & 7);
1707
+ }
1708
+ return message;
1709
+ },
1710
+ create(base) {
1711
+ return GetOperationResponse.fromPartial(base ?? {});
1712
+ },
1713
+ fromPartial(object) {
1714
+ const message = createBaseGetOperationResponse();
1715
+ message.op = object.op !== void 0 && object.op !== null ? OperationView.fromPartial(object.op) : void 0;
1716
+ return message;
1717
+ }
1718
+ };
1719
+ function createBaseGetPayloadRequest() {
1720
+ return { traceId: "", opId: "", direction: 0 };
1721
+ }
1722
+ var GetPayloadRequest = {
1723
+ encode(message, writer = new BinaryWriter()) {
1724
+ if (message.traceId !== "") {
1725
+ writer.uint32(10).string(message.traceId);
1726
+ }
1727
+ if (message.opId !== "") {
1728
+ writer.uint32(18).string(message.opId);
1729
+ }
1730
+ if (message.direction !== 0) {
1731
+ writer.uint32(24).uint32(message.direction);
1732
+ }
1733
+ return writer;
1734
+ },
1735
+ decode(input, length) {
1736
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1737
+ const end = length === void 0 ? reader.len : reader.pos + length;
1738
+ const message = createBaseGetPayloadRequest();
1739
+ while (reader.pos < end) {
1740
+ const tag = reader.uint32();
1741
+ switch (tag >>> 3) {
1742
+ case 1: {
1743
+ if (tag !== 10) {
1744
+ break;
1745
+ }
1746
+ message.traceId = reader.string();
1747
+ continue;
1748
+ }
1749
+ case 2: {
1750
+ if (tag !== 18) {
1751
+ break;
1752
+ }
1753
+ message.opId = reader.string();
1754
+ continue;
1755
+ }
1756
+ case 3: {
1757
+ if (tag !== 24) {
1758
+ break;
1759
+ }
1760
+ message.direction = reader.uint32();
1761
+ continue;
1762
+ }
1763
+ }
1764
+ if ((tag & 7) === 4 || tag === 0) {
1765
+ break;
1766
+ }
1767
+ reader.skip(tag & 7);
1768
+ }
1769
+ return message;
1770
+ },
1771
+ create(base) {
1772
+ return GetPayloadRequest.fromPartial(base ?? {});
1773
+ },
1774
+ fromPartial(object) {
1775
+ const message = createBaseGetPayloadRequest();
1776
+ message.traceId = object.traceId ?? "";
1777
+ message.opId = object.opId ?? "";
1778
+ message.direction = object.direction ?? 0;
1779
+ return message;
1780
+ }
1781
+ };
1782
+ function createBaseGetPayloadResponse() {
1783
+ return {
1784
+ rawBytes: Buffer.alloc(0),
1785
+ decodedBytes: Buffer.alloc(0),
1786
+ originalSize: 0,
1787
+ contractHash: "",
1788
+ schemaDrift: false
1789
+ };
1790
+ }
1791
+ var GetPayloadResponse = {
1792
+ encode(message, writer = new BinaryWriter()) {
1793
+ if (message.rawBytes.length !== 0) {
1794
+ writer.uint32(10).bytes(message.rawBytes);
1795
+ }
1796
+ if (message.decodedBytes.length !== 0) {
1797
+ writer.uint32(18).bytes(message.decodedBytes);
1798
+ }
1799
+ if (message.originalSize !== 0) {
1800
+ writer.uint32(24).int32(message.originalSize);
1801
+ }
1802
+ if (message.contractHash !== "") {
1803
+ writer.uint32(34).string(message.contractHash);
1804
+ }
1805
+ if (message.schemaDrift !== false) {
1806
+ writer.uint32(40).bool(message.schemaDrift);
1807
+ }
1808
+ return writer;
1809
+ },
1810
+ decode(input, length) {
1811
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1812
+ const end = length === void 0 ? reader.len : reader.pos + length;
1813
+ const message = createBaseGetPayloadResponse();
1814
+ while (reader.pos < end) {
1815
+ const tag = reader.uint32();
1816
+ switch (tag >>> 3) {
1817
+ case 1: {
1818
+ if (tag !== 10) {
1819
+ break;
1820
+ }
1821
+ message.rawBytes = Buffer.from(reader.bytes());
1822
+ continue;
1823
+ }
1824
+ case 2: {
1825
+ if (tag !== 18) {
1826
+ break;
1827
+ }
1828
+ message.decodedBytes = Buffer.from(reader.bytes());
1829
+ continue;
1830
+ }
1831
+ case 3: {
1832
+ if (tag !== 24) {
1833
+ break;
1834
+ }
1835
+ message.originalSize = reader.int32();
1836
+ continue;
1837
+ }
1838
+ case 4: {
1839
+ if (tag !== 34) {
1840
+ break;
1841
+ }
1842
+ message.contractHash = reader.string();
1843
+ continue;
1844
+ }
1845
+ case 5: {
1846
+ if (tag !== 40) {
1847
+ break;
1848
+ }
1849
+ message.schemaDrift = reader.bool();
1850
+ continue;
1851
+ }
1852
+ }
1853
+ if ((tag & 7) === 4 || tag === 0) {
1854
+ break;
1855
+ }
1856
+ reader.skip(tag & 7);
1857
+ }
1858
+ return message;
1859
+ },
1860
+ create(base) {
1861
+ return GetPayloadResponse.fromPartial(base ?? {});
1862
+ },
1863
+ fromPartial(object) {
1864
+ const message = createBaseGetPayloadResponse();
1865
+ message.rawBytes = object.rawBytes ?? Buffer.alloc(0);
1866
+ message.decodedBytes = object.decodedBytes ?? Buffer.alloc(0);
1867
+ message.originalSize = object.originalSize ?? 0;
1868
+ message.contractHash = object.contractHash ?? "";
1869
+ message.schemaDrift = object.schemaDrift ?? false;
1870
+ return message;
1871
+ }
1872
+ };
1873
+ function createBaseQueryLogsRequest() {
1874
+ return {
1875
+ serviceId: "",
1876
+ instanceId: "",
1877
+ fromUnixMs: 0,
1878
+ toUnixMs: 0,
1879
+ minLevel: 0,
1880
+ traceId: "",
1881
+ textQuery: "",
1882
+ limit: 0,
1883
+ cursor: ""
1884
+ };
1885
+ }
1886
+ var QueryLogsRequest = {
1887
+ encode(message, writer = new BinaryWriter()) {
1888
+ if (message.serviceId !== "") {
1889
+ writer.uint32(10).string(message.serviceId);
1890
+ }
1891
+ if (message.instanceId !== "") {
1892
+ writer.uint32(18).string(message.instanceId);
1893
+ }
1894
+ if (message.fromUnixMs !== 0) {
1895
+ writer.uint32(24).int64(message.fromUnixMs);
1896
+ }
1897
+ if (message.toUnixMs !== 0) {
1898
+ writer.uint32(32).int64(message.toUnixMs);
1899
+ }
1900
+ if (message.minLevel !== 0) {
1901
+ writer.uint32(40).int32(message.minLevel);
1902
+ }
1903
+ if (message.traceId !== "") {
1904
+ writer.uint32(50).string(message.traceId);
1905
+ }
1906
+ if (message.textQuery !== "") {
1907
+ writer.uint32(58).string(message.textQuery);
1908
+ }
1909
+ if (message.limit !== 0) {
1910
+ writer.uint32(64).uint32(message.limit);
1911
+ }
1912
+ if (message.cursor !== "") {
1913
+ writer.uint32(74).string(message.cursor);
1914
+ }
1915
+ return writer;
1916
+ },
1917
+ decode(input, length) {
1918
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
1919
+ const end = length === void 0 ? reader.len : reader.pos + length;
1920
+ const message = createBaseQueryLogsRequest();
1921
+ while (reader.pos < end) {
1922
+ const tag = reader.uint32();
1923
+ switch (tag >>> 3) {
1924
+ case 1: {
1925
+ if (tag !== 10) {
1926
+ break;
1927
+ }
1928
+ message.serviceId = reader.string();
1929
+ continue;
1930
+ }
1931
+ case 2: {
1932
+ if (tag !== 18) {
1933
+ break;
1934
+ }
1935
+ message.instanceId = reader.string();
1936
+ continue;
1937
+ }
1938
+ case 3: {
1939
+ if (tag !== 24) {
1940
+ break;
1941
+ }
1942
+ message.fromUnixMs = longToNumber(reader.int64());
1943
+ continue;
1944
+ }
1945
+ case 4: {
1946
+ if (tag !== 32) {
1947
+ break;
1948
+ }
1949
+ message.toUnixMs = longToNumber(reader.int64());
1950
+ continue;
1951
+ }
1952
+ case 5: {
1953
+ if (tag !== 40) {
1954
+ break;
1955
+ }
1956
+ message.minLevel = reader.int32();
1957
+ continue;
1958
+ }
1959
+ case 6: {
1960
+ if (tag !== 50) {
1961
+ break;
1962
+ }
1963
+ message.traceId = reader.string();
1964
+ continue;
1965
+ }
1966
+ case 7: {
1967
+ if (tag !== 58) {
1968
+ break;
1969
+ }
1970
+ message.textQuery = reader.string();
1971
+ continue;
1972
+ }
1973
+ case 8: {
1974
+ if (tag !== 64) {
1975
+ break;
1976
+ }
1977
+ message.limit = reader.uint32();
1978
+ continue;
1979
+ }
1980
+ case 9: {
1981
+ if (tag !== 74) {
1982
+ break;
1983
+ }
1984
+ message.cursor = reader.string();
1985
+ continue;
1986
+ }
1987
+ }
1988
+ if ((tag & 7) === 4 || tag === 0) {
1989
+ break;
1990
+ }
1991
+ reader.skip(tag & 7);
1992
+ }
1993
+ return message;
1994
+ },
1995
+ create(base) {
1996
+ return QueryLogsRequest.fromPartial(base ?? {});
1997
+ },
1998
+ fromPartial(object) {
1999
+ const message = createBaseQueryLogsRequest();
2000
+ message.serviceId = object.serviceId ?? "";
2001
+ message.instanceId = object.instanceId ?? "";
2002
+ message.fromUnixMs = object.fromUnixMs ?? 0;
2003
+ message.toUnixMs = object.toUnixMs ?? 0;
2004
+ message.minLevel = object.minLevel ?? 0;
2005
+ message.traceId = object.traceId ?? "";
2006
+ message.textQuery = object.textQuery ?? "";
2007
+ message.limit = object.limit ?? 0;
2008
+ message.cursor = object.cursor ?? "";
2009
+ return message;
2010
+ }
2011
+ };
2012
+ function createBaseQueryLogsResponse() {
2013
+ return { entries: [], nextCursor: "" };
2014
+ }
2015
+ var QueryLogsResponse = {
2016
+ encode(message, writer = new BinaryWriter()) {
2017
+ for (const v of message.entries) {
2018
+ Log.encode(v, writer.uint32(10).fork()).join();
2019
+ }
2020
+ if (message.nextCursor !== "") {
2021
+ writer.uint32(18).string(message.nextCursor);
2022
+ }
2023
+ return writer;
2024
+ },
2025
+ decode(input, length) {
2026
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2027
+ const end = length === void 0 ? reader.len : reader.pos + length;
2028
+ const message = createBaseQueryLogsResponse();
2029
+ while (reader.pos < end) {
2030
+ const tag = reader.uint32();
2031
+ switch (tag >>> 3) {
2032
+ case 1: {
2033
+ if (tag !== 10) {
2034
+ break;
2035
+ }
2036
+ message.entries.push(Log.decode(reader, reader.uint32()));
2037
+ continue;
2038
+ }
2039
+ case 2: {
2040
+ if (tag !== 18) {
2041
+ break;
2042
+ }
2043
+ message.nextCursor = reader.string();
2044
+ continue;
2045
+ }
2046
+ }
2047
+ if ((tag & 7) === 4 || tag === 0) {
2048
+ break;
2049
+ }
2050
+ reader.skip(tag & 7);
2051
+ }
2052
+ return message;
2053
+ },
2054
+ create(base) {
2055
+ return QueryLogsResponse.fromPartial(base ?? {});
2056
+ },
2057
+ fromPartial(object) {
2058
+ const message = createBaseQueryLogsResponse();
2059
+ message.entries = object.entries?.map((e) => Log.fromPartial(e)) || [];
2060
+ message.nextCursor = object.nextCursor ?? "";
2061
+ return message;
2062
+ }
2063
+ };
2064
+ function createBaseQueryMetricsRequest() {
2065
+ return {
2066
+ serviceId: "",
2067
+ instanceId: "",
2068
+ name: "",
2069
+ fromUnixMs: 0,
2070
+ toUnixMs: 0,
2071
+ labelFilters: {},
2072
+ stepSeconds: 0,
2073
+ percentiles: []
2074
+ };
2075
+ }
2076
+ var QueryMetricsRequest = {
2077
+ encode(message, writer = new BinaryWriter()) {
2078
+ if (message.serviceId !== "") {
2079
+ writer.uint32(10).string(message.serviceId);
2080
+ }
2081
+ if (message.instanceId !== "") {
2082
+ writer.uint32(18).string(message.instanceId);
2083
+ }
2084
+ if (message.name !== "") {
2085
+ writer.uint32(26).string(message.name);
2086
+ }
2087
+ if (message.fromUnixMs !== 0) {
2088
+ writer.uint32(32).int64(message.fromUnixMs);
2089
+ }
2090
+ if (message.toUnixMs !== 0) {
2091
+ writer.uint32(40).int64(message.toUnixMs);
2092
+ }
2093
+ globalThis.Object.entries(message.labelFilters).forEach(([key, value]) => {
2094
+ QueryMetricsRequest_LabelFiltersEntry.encode({ key, value }, writer.uint32(50).fork()).join();
2095
+ });
2096
+ if (message.stepSeconds !== 0) {
2097
+ writer.uint32(56).uint32(message.stepSeconds);
2098
+ }
2099
+ writer.uint32(66).fork();
2100
+ for (const v of message.percentiles) {
2101
+ writer.double(v);
2102
+ }
2103
+ writer.join();
2104
+ return writer;
2105
+ },
2106
+ decode(input, length) {
2107
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2108
+ const end = length === void 0 ? reader.len : reader.pos + length;
2109
+ const message = createBaseQueryMetricsRequest();
2110
+ while (reader.pos < end) {
2111
+ const tag = reader.uint32();
2112
+ switch (tag >>> 3) {
2113
+ case 1: {
2114
+ if (tag !== 10) {
2115
+ break;
2116
+ }
2117
+ message.serviceId = reader.string();
2118
+ continue;
2119
+ }
2120
+ case 2: {
2121
+ if (tag !== 18) {
2122
+ break;
2123
+ }
2124
+ message.instanceId = reader.string();
2125
+ continue;
2126
+ }
2127
+ case 3: {
2128
+ if (tag !== 26) {
2129
+ break;
2130
+ }
2131
+ message.name = reader.string();
2132
+ continue;
2133
+ }
2134
+ case 4: {
2135
+ if (tag !== 32) {
2136
+ break;
2137
+ }
2138
+ message.fromUnixMs = longToNumber(reader.int64());
2139
+ continue;
2140
+ }
2141
+ case 5: {
2142
+ if (tag !== 40) {
2143
+ break;
2144
+ }
2145
+ message.toUnixMs = longToNumber(reader.int64());
2146
+ continue;
2147
+ }
2148
+ case 6: {
2149
+ if (tag !== 50) {
2150
+ break;
2151
+ }
2152
+ const entry6 = QueryMetricsRequest_LabelFiltersEntry.decode(reader, reader.uint32());
2153
+ if (entry6.value !== void 0) {
2154
+ message.labelFilters[entry6.key] = entry6.value;
2155
+ }
2156
+ continue;
2157
+ }
2158
+ case 7: {
2159
+ if (tag !== 56) {
2160
+ break;
2161
+ }
2162
+ message.stepSeconds = reader.uint32();
2163
+ continue;
2164
+ }
2165
+ case 8: {
2166
+ if (tag === 65) {
2167
+ message.percentiles.push(reader.double());
2168
+ continue;
2169
+ }
2170
+ if (tag === 66) {
2171
+ const end2 = reader.uint32() + reader.pos;
2172
+ while (reader.pos < end2) {
2173
+ message.percentiles.push(reader.double());
2174
+ }
2175
+ continue;
2176
+ }
2177
+ break;
2178
+ }
2179
+ }
2180
+ if ((tag & 7) === 4 || tag === 0) {
2181
+ break;
2182
+ }
2183
+ reader.skip(tag & 7);
2184
+ }
2185
+ return message;
2186
+ },
2187
+ create(base) {
2188
+ return QueryMetricsRequest.fromPartial(base ?? {});
2189
+ },
2190
+ fromPartial(object) {
2191
+ const message = createBaseQueryMetricsRequest();
2192
+ message.serviceId = object.serviceId ?? "";
2193
+ message.instanceId = object.instanceId ?? "";
2194
+ message.name = object.name ?? "";
2195
+ message.fromUnixMs = object.fromUnixMs ?? 0;
2196
+ message.toUnixMs = object.toUnixMs ?? 0;
2197
+ message.labelFilters = globalThis.Object.entries(object.labelFilters ?? {}).reduce(
2198
+ (acc, [key, value]) => {
2199
+ if (value !== void 0) {
2200
+ acc[key] = globalThis.String(value);
2201
+ }
2202
+ return acc;
2203
+ },
2204
+ {}
2205
+ );
2206
+ message.stepSeconds = object.stepSeconds ?? 0;
2207
+ message.percentiles = object.percentiles?.map((e) => e) || [];
2208
+ return message;
2209
+ }
2210
+ };
2211
+ function createBaseQueryMetricsRequest_LabelFiltersEntry() {
2212
+ return { key: "", value: "" };
2213
+ }
2214
+ var QueryMetricsRequest_LabelFiltersEntry = {
2215
+ encode(message, writer = new BinaryWriter()) {
2216
+ if (message.key !== "") {
2217
+ writer.uint32(10).string(message.key);
2218
+ }
2219
+ if (message.value !== "") {
2220
+ writer.uint32(18).string(message.value);
2221
+ }
2222
+ return writer;
2223
+ },
2224
+ decode(input, length) {
2225
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2226
+ const end = length === void 0 ? reader.len : reader.pos + length;
2227
+ const message = createBaseQueryMetricsRequest_LabelFiltersEntry();
2228
+ while (reader.pos < end) {
2229
+ const tag = reader.uint32();
2230
+ switch (tag >>> 3) {
2231
+ case 1: {
2232
+ if (tag !== 10) {
2233
+ break;
2234
+ }
2235
+ message.key = reader.string();
2236
+ continue;
2237
+ }
2238
+ case 2: {
2239
+ if (tag !== 18) {
2240
+ break;
2241
+ }
2242
+ message.value = reader.string();
2243
+ continue;
2244
+ }
2245
+ }
2246
+ if ((tag & 7) === 4 || tag === 0) {
2247
+ break;
2248
+ }
2249
+ reader.skip(tag & 7);
2250
+ }
2251
+ return message;
2252
+ },
2253
+ create(base) {
2254
+ return QueryMetricsRequest_LabelFiltersEntry.fromPartial(base ?? {});
2255
+ },
2256
+ fromPartial(object) {
2257
+ const message = createBaseQueryMetricsRequest_LabelFiltersEntry();
2258
+ message.key = object.key ?? "";
2259
+ message.value = object.value ?? "";
2260
+ return message;
2261
+ }
2262
+ };
2263
+ function createBaseMetricSeries() {
2264
+ return { name: "", labels: {}, instanceId: "", tsUnixMs: [], values: [], maxValues: [] };
2265
+ }
2266
+ var MetricSeries = {
2267
+ encode(message, writer = new BinaryWriter()) {
2268
+ if (message.name !== "") {
2269
+ writer.uint32(10).string(message.name);
2270
+ }
2271
+ globalThis.Object.entries(message.labels).forEach(([key, value]) => {
2272
+ MetricSeries_LabelsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
2273
+ });
2274
+ if (message.instanceId !== "") {
2275
+ writer.uint32(26).string(message.instanceId);
2276
+ }
2277
+ writer.uint32(34).fork();
2278
+ for (const v of message.tsUnixMs) {
2279
+ writer.int64(v);
2280
+ }
2281
+ writer.join();
2282
+ writer.uint32(42).fork();
2283
+ for (const v of message.values) {
2284
+ writer.double(v);
2285
+ }
2286
+ writer.join();
2287
+ writer.uint32(50).fork();
2288
+ for (const v of message.maxValues) {
2289
+ writer.double(v);
2290
+ }
2291
+ writer.join();
2292
+ return writer;
2293
+ },
2294
+ decode(input, length) {
2295
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2296
+ const end = length === void 0 ? reader.len : reader.pos + length;
2297
+ const message = createBaseMetricSeries();
2298
+ while (reader.pos < end) {
2299
+ const tag = reader.uint32();
2300
+ switch (tag >>> 3) {
2301
+ case 1: {
2302
+ if (tag !== 10) {
2303
+ break;
2304
+ }
2305
+ message.name = reader.string();
2306
+ continue;
2307
+ }
2308
+ case 2: {
2309
+ if (tag !== 18) {
2310
+ break;
2311
+ }
2312
+ const entry2 = MetricSeries_LabelsEntry.decode(reader, reader.uint32());
2313
+ if (entry2.value !== void 0) {
2314
+ message.labels[entry2.key] = entry2.value;
2315
+ }
2316
+ continue;
2317
+ }
2318
+ case 3: {
2319
+ if (tag !== 26) {
2320
+ break;
2321
+ }
2322
+ message.instanceId = reader.string();
2323
+ continue;
2324
+ }
2325
+ case 4: {
2326
+ if (tag === 32) {
2327
+ message.tsUnixMs.push(longToNumber(reader.int64()));
2328
+ continue;
2329
+ }
2330
+ if (tag === 34) {
2331
+ const end2 = reader.uint32() + reader.pos;
2332
+ while (reader.pos < end2) {
2333
+ message.tsUnixMs.push(longToNumber(reader.int64()));
2334
+ }
2335
+ continue;
2336
+ }
2337
+ break;
2338
+ }
2339
+ case 5: {
2340
+ if (tag === 41) {
2341
+ message.values.push(reader.double());
2342
+ continue;
2343
+ }
2344
+ if (tag === 42) {
2345
+ const end2 = reader.uint32() + reader.pos;
2346
+ while (reader.pos < end2) {
2347
+ message.values.push(reader.double());
2348
+ }
2349
+ continue;
2350
+ }
2351
+ break;
2352
+ }
2353
+ case 6: {
2354
+ if (tag === 49) {
2355
+ message.maxValues.push(reader.double());
2356
+ continue;
2357
+ }
2358
+ if (tag === 50) {
2359
+ const end2 = reader.uint32() + reader.pos;
2360
+ while (reader.pos < end2) {
2361
+ message.maxValues.push(reader.double());
2362
+ }
2363
+ continue;
2364
+ }
2365
+ break;
2366
+ }
2367
+ }
2368
+ if ((tag & 7) === 4 || tag === 0) {
2369
+ break;
2370
+ }
2371
+ reader.skip(tag & 7);
2372
+ }
2373
+ return message;
2374
+ },
2375
+ create(base) {
2376
+ return MetricSeries.fromPartial(base ?? {});
2377
+ },
2378
+ fromPartial(object) {
2379
+ const message = createBaseMetricSeries();
2380
+ message.name = object.name ?? "";
2381
+ message.labels = globalThis.Object.entries(object.labels ?? {}).reduce(
2382
+ (acc, [key, value]) => {
2383
+ if (value !== void 0) {
2384
+ acc[key] = globalThis.String(value);
2385
+ }
2386
+ return acc;
2387
+ },
2388
+ {}
2389
+ );
2390
+ message.instanceId = object.instanceId ?? "";
2391
+ message.tsUnixMs = object.tsUnixMs?.map((e) => e) || [];
2392
+ message.values = object.values?.map((e) => e) || [];
2393
+ message.maxValues = object.maxValues?.map((e) => e) || [];
2394
+ return message;
2395
+ }
2396
+ };
2397
+ function createBaseMetricSeries_LabelsEntry() {
2398
+ return { key: "", value: "" };
2399
+ }
2400
+ var MetricSeries_LabelsEntry = {
2401
+ encode(message, writer = new BinaryWriter()) {
2402
+ if (message.key !== "") {
2403
+ writer.uint32(10).string(message.key);
2404
+ }
2405
+ if (message.value !== "") {
2406
+ writer.uint32(18).string(message.value);
2407
+ }
2408
+ return writer;
2409
+ },
2410
+ decode(input, length) {
2411
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2412
+ const end = length === void 0 ? reader.len : reader.pos + length;
2413
+ const message = createBaseMetricSeries_LabelsEntry();
2414
+ while (reader.pos < end) {
2415
+ const tag = reader.uint32();
2416
+ switch (tag >>> 3) {
2417
+ case 1: {
2418
+ if (tag !== 10) {
2419
+ break;
2420
+ }
2421
+ message.key = reader.string();
2422
+ continue;
2423
+ }
2424
+ case 2: {
2425
+ if (tag !== 18) {
2426
+ break;
2427
+ }
2428
+ message.value = reader.string();
2429
+ continue;
2430
+ }
2431
+ }
2432
+ if ((tag & 7) === 4 || tag === 0) {
2433
+ break;
2434
+ }
2435
+ reader.skip(tag & 7);
2436
+ }
2437
+ return message;
2438
+ },
2439
+ create(base) {
2440
+ return MetricSeries_LabelsEntry.fromPartial(base ?? {});
2441
+ },
2442
+ fromPartial(object) {
2443
+ const message = createBaseMetricSeries_LabelsEntry();
2444
+ message.key = object.key ?? "";
2445
+ message.value = object.value ?? "";
2446
+ return message;
2447
+ }
2448
+ };
2449
+ function createBaseQueryMetricsResponse() {
2450
+ return { series: [] };
2451
+ }
2452
+ var QueryMetricsResponse = {
2453
+ encode(message, writer = new BinaryWriter()) {
2454
+ for (const v of message.series) {
2455
+ MetricSeries.encode(v, writer.uint32(10).fork()).join();
2456
+ }
2457
+ return writer;
2458
+ },
2459
+ decode(input, length) {
2460
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2461
+ const end = length === void 0 ? reader.len : reader.pos + length;
2462
+ const message = createBaseQueryMetricsResponse();
2463
+ while (reader.pos < end) {
2464
+ const tag = reader.uint32();
2465
+ switch (tag >>> 3) {
2466
+ case 1: {
2467
+ if (tag !== 10) {
2468
+ break;
2469
+ }
2470
+ message.series.push(MetricSeries.decode(reader, reader.uint32()));
2471
+ continue;
2472
+ }
2473
+ }
2474
+ if ((tag & 7) === 4 || tag === 0) {
2475
+ break;
2476
+ }
2477
+ reader.skip(tag & 7);
2478
+ }
2479
+ return message;
2480
+ },
2481
+ create(base) {
2482
+ return QueryMetricsResponse.fromPartial(base ?? {});
2483
+ },
2484
+ fromPartial(object) {
2485
+ const message = createBaseQueryMetricsResponse();
2486
+ message.series = object.series?.map((e) => MetricSeries.fromPartial(e)) || [];
2487
+ return message;
2488
+ }
2489
+ };
2490
+ var TelemetryService = {
2491
+ report: {
2492
+ path: "/servicebridge.v1.Telemetry/Report",
2493
+ requestStream: true,
2494
+ responseStream: true,
2495
+ requestSerialize: (value) => Buffer.from(TelemetryBatch.encode(value).finish()),
2496
+ requestDeserialize: (value) => TelemetryBatch.decode(value),
2497
+ responseSerialize: (value) => Buffer.from(TelemetryAck.encode(value).finish()),
2498
+ responseDeserialize: (value) => TelemetryAck.decode(value)
2499
+ },
2500
+ listTraces: {
2501
+ path: "/servicebridge.v1.Telemetry/ListTraces",
2502
+ requestStream: false,
2503
+ responseStream: false,
2504
+ requestSerialize: (value) => Buffer.from(ListTracesRequest.encode(value).finish()),
2505
+ requestDeserialize: (value) => ListTracesRequest.decode(value),
2506
+ responseSerialize: (value) => Buffer.from(ListTracesResponse.encode(value).finish()),
2507
+ responseDeserialize: (value) => ListTracesResponse.decode(value)
2508
+ },
2509
+ getTrace: {
2510
+ path: "/servicebridge.v1.Telemetry/GetTrace",
2511
+ requestStream: false,
2512
+ responseStream: false,
2513
+ requestSerialize: (value) => Buffer.from(GetTraceRequest.encode(value).finish()),
2514
+ requestDeserialize: (value) => GetTraceRequest.decode(value),
2515
+ responseSerialize: (value) => Buffer.from(GetTraceResponse.encode(value).finish()),
2516
+ responseDeserialize: (value) => GetTraceResponse.decode(value)
2517
+ },
2518
+ getOperation: {
2519
+ path: "/servicebridge.v1.Telemetry/GetOperation",
2520
+ requestStream: false,
2521
+ responseStream: false,
2522
+ requestSerialize: (value) => Buffer.from(GetOperationRequest.encode(value).finish()),
2523
+ requestDeserialize: (value) => GetOperationRequest.decode(value),
2524
+ responseSerialize: (value) => Buffer.from(GetOperationResponse.encode(value).finish()),
2525
+ responseDeserialize: (value) => GetOperationResponse.decode(value)
2526
+ },
2527
+ getPayload: {
2528
+ path: "/servicebridge.v1.Telemetry/GetPayload",
2529
+ requestStream: false,
2530
+ responseStream: false,
2531
+ requestSerialize: (value) => Buffer.from(GetPayloadRequest.encode(value).finish()),
2532
+ requestDeserialize: (value) => GetPayloadRequest.decode(value),
2533
+ responseSerialize: (value) => Buffer.from(GetPayloadResponse.encode(value).finish()),
2534
+ responseDeserialize: (value) => GetPayloadResponse.decode(value)
2535
+ },
2536
+ queryLogs: {
2537
+ path: "/servicebridge.v1.Telemetry/QueryLogs",
2538
+ requestStream: false,
2539
+ responseStream: false,
2540
+ requestSerialize: (value) => Buffer.from(QueryLogsRequest.encode(value).finish()),
2541
+ requestDeserialize: (value) => QueryLogsRequest.decode(value),
2542
+ responseSerialize: (value) => Buffer.from(QueryLogsResponse.encode(value).finish()),
2543
+ responseDeserialize: (value) => QueryLogsResponse.decode(value)
2544
+ },
2545
+ queryMetrics: {
2546
+ path: "/servicebridge.v1.Telemetry/QueryMetrics",
2547
+ requestStream: false,
2548
+ responseStream: false,
2549
+ requestSerialize: (value) => Buffer.from(QueryMetricsRequest.encode(value).finish()),
2550
+ requestDeserialize: (value) => QueryMetricsRequest.decode(value),
2551
+ responseSerialize: (value) => Buffer.from(QueryMetricsResponse.encode(value).finish()),
2552
+ responseDeserialize: (value) => QueryMetricsResponse.decode(value)
2553
+ }
2554
+ };
2555
+ var TelemetryClient = makeGenericClientConstructor(
2556
+ TelemetryService,
2557
+ "servicebridge.v1.Telemetry"
2558
+ );
2559
+ function longToNumber(int64) {
2560
+ const num = globalThis.Number(int64.toString());
2561
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
2562
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
2563
+ }
2564
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
2565
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
2566
+ }
2567
+ return num;
2568
+ }
2569
+
2570
+ // src/telemetry/trace-context.ts
2571
+ import { uuidv7 } from "uuidv7";
2572
+ var ZERO_OP_ID = "00000000-0000-0000-0000-000000000000";
2573
+ function mintRootContext() {
2574
+ return {
2575
+ traceId: uuidv7(),
2576
+ parentOpId: ZERO_OP_ID
2577
+ };
2578
+ }
2579
+
2580
+ // src/telemetry/ops.ts
2581
+ var EMPTY_JSON_OBJECT = Buffer.from("{}");
2582
+ var HttpHandle = 1;
2583
+
2584
+ // src/http/_common/body-capture.ts
2585
+ var RAW_JSON_CONTRACT = "raw/json";
2586
+ var encoder = new TextEncoder();
2587
+ function bodyToBytes(body) {
2588
+ if (body === void 0 || body === null) return null;
2589
+ if (body instanceof Uint8Array) return body.byteLength ? body : null;
2590
+ if (typeof body === "string") {
2591
+ const s = body.trim();
2592
+ if (!s || s === "{}" || s === "null") return null;
2593
+ return encoder.encode(body);
2594
+ }
2595
+ try {
2596
+ const json = JSON.stringify(body);
2597
+ if (!json || json === "{}" || json === "null") return null;
2598
+ return encoder.encode(json);
2599
+ } catch {
2600
+ return null;
2601
+ }
2602
+ }
2603
+
2604
+ // src/telemetry/wire-trace.ts
2605
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2606
+ var UUID_LEN = 36;
2607
+ var HEADER_LEN = UUID_LEN + 1 + UUID_LEN;
2608
+ function parseXSbTrace(value) {
2609
+ if (!value) return null;
2610
+ if (value.length !== HEADER_LEN) return null;
2611
+ if (value[UUID_LEN] !== "-") return null;
2612
+ const traceId = value.slice(0, UUID_LEN);
2613
+ const parentOpId = value.slice(UUID_LEN + 1);
2614
+ if (!UUID_RE.test(traceId) || !UUID_RE.test(parentOpId)) return null;
2615
+ return { traceId, parentOpId };
2616
+ }
2617
+
2618
+ // src/http/_common/trace-wrap.ts
2619
+ function contextFromXSbTrace(header) {
2620
+ if (header == null) return mintRootContext();
2621
+ const parsed = parseXSbTrace(header);
2622
+ if (parsed == null) return mintRootContext();
2623
+ return parsed;
2624
+ }
2625
+
2626
+ // src/http/endpoint.ts
2627
+ var _warned = false;
2628
+ function resolveHttpAdvertiseHost(explicit) {
2629
+ if (explicit && explicit.length > 0) return explicit;
2630
+ if (!_warned) {
2631
+ _warned = true;
2632
+ console.warn(
2633
+ "[ServiceBridge] http advertise host not configured \u2014 falling back to 127.0.0.1. Pass { host } to the HTTP plugin for cross-host reachability."
2634
+ );
2635
+ }
2636
+ return "127.0.0.1";
2637
+ }
2638
+
2639
+ // src/http/hono/plugin.ts
2640
+ function collectHonoRoutes(app, sb) {
2641
+ for (const r of app.routes) {
2642
+ if (typeof r.method !== "string" || typeof r.path !== "string") continue;
2643
+ if (r.method.toUpperCase() === "ALL") continue;
2644
+ sb.routes.add({
2645
+ method: r.method.toUpperCase(),
2646
+ pattern: r.path,
2647
+ source: "hono"
2648
+ });
2649
+ }
2650
+ }
2651
+ function attachHono(app, sb, endpoint) {
2652
+ collectHonoRoutes(app, sb);
2653
+ const host = resolveHttpAdvertiseHost(endpoint.host);
2654
+ sb.routes.publishHttp({ host, port: endpoint.port });
2655
+ installHonoTracing(app, sb);
2656
+ }
2657
+ var TRACE_FLAG = /* @__PURE__ */ Symbol.for("servicebridge.hono.trace");
2658
+ function installHonoTracing(app, sb) {
2659
+ const tagged = app;
2660
+ if (tagged[TRACE_FLAG]) return;
2661
+ tagged[TRACE_FLAG] = true;
2662
+ const origFetch = app.fetch.bind(app);
2663
+ app.fetch = async (req, env, executionCtx) => {
2664
+ const ctx = contextFromXSbTrace(req.headers.get("x-sb-trace"));
2665
+ const url = new URL(req.url);
2666
+ const businessKey = req.headers.get("idempotency-key") ?? `${req.method} ${url.pathname}`;
2667
+ const reqClone = req.clone();
2668
+ return runWithTrace(ctx, async () => {
2669
+ const handle = sb.telemetry.startOp({
2670
+ channel: 1 /* HTTP */,
2671
+ kind: HttpHandle,
2672
+ subject: `http.handle:${req.method}/${url.pathname}`,
2673
+ businessKey
2674
+ });
2675
+ const captureBodies = async (res) => {
2676
+ try {
2677
+ const inBytes = bodyToBytes(await reqClone.text());
2678
+ if (inBytes) handle.captureIn(inBytes, RAW_JSON_CONTRACT);
2679
+ } catch {
2680
+ }
2681
+ try {
2682
+ const outBytes = bodyToBytes(await res.clone().text());
2683
+ if (outBytes) handle.captureOut(outBytes, RAW_JSON_CONTRACT);
2684
+ } catch {
2685
+ }
2686
+ };
2687
+ try {
2688
+ const res = await origFetch(req, env, executionCtx);
2689
+ await captureBodies(res);
2690
+ if (res.status >= 500) handle.end(3 /* ERROR */, `HTTP ${res.status}`);
2691
+ else if (res.status >= 400)
2692
+ handle.end(3 /* ERROR */, `HTTP ${res.status}`);
2693
+ else handle.end(2 /* SUCCESS */);
2694
+ return res;
2695
+ } catch (err) {
2696
+ handle.end(3 /* ERROR */, err.message);
2697
+ throw err;
2698
+ }
2699
+ });
2700
+ };
2701
+ }
2702
+ export {
2703
+ attachHono,
2704
+ collectHonoRoutes
2705
+ };
2706
+ //# sourceMappingURL=index.js.map