@miradorlabs/web-grpc 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,6 +113,64 @@ export function derivedMetricOutcomeToJSON(object: DerivedMetricOutcome): string
113
113
  }
114
114
  }
115
115
 
116
+ export enum DerivedMetricAttributeType {
117
+ DERIVED_METRIC_ATTRIBUTE_TYPE_UNSPECIFIED = 0,
118
+ DERIVED_METRIC_ATTRIBUTE_TYPE_STRING = 1,
119
+ DERIVED_METRIC_ATTRIBUTE_TYPE_BOOL = 2,
120
+ DERIVED_METRIC_ATTRIBUTE_TYPE_INT = 3,
121
+ DERIVED_METRIC_ATTRIBUTE_TYPE_DOUBLE = 4,
122
+ /** DERIVED_METRIC_ATTRIBUTE_TYPE_MIXED - The key was observed with more than one type across traces. */
123
+ DERIVED_METRIC_ATTRIBUTE_TYPE_MIXED = 5,
124
+ UNRECOGNIZED = -1,
125
+ }
126
+
127
+ export function derivedMetricAttributeTypeFromJSON(object: any): DerivedMetricAttributeType {
128
+ switch (object) {
129
+ case 0:
130
+ case "DERIVED_METRIC_ATTRIBUTE_TYPE_UNSPECIFIED":
131
+ return DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_UNSPECIFIED;
132
+ case 1:
133
+ case "DERIVED_METRIC_ATTRIBUTE_TYPE_STRING":
134
+ return DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_STRING;
135
+ case 2:
136
+ case "DERIVED_METRIC_ATTRIBUTE_TYPE_BOOL":
137
+ return DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_BOOL;
138
+ case 3:
139
+ case "DERIVED_METRIC_ATTRIBUTE_TYPE_INT":
140
+ return DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_INT;
141
+ case 4:
142
+ case "DERIVED_METRIC_ATTRIBUTE_TYPE_DOUBLE":
143
+ return DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_DOUBLE;
144
+ case 5:
145
+ case "DERIVED_METRIC_ATTRIBUTE_TYPE_MIXED":
146
+ return DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_MIXED;
147
+ case -1:
148
+ case "UNRECOGNIZED":
149
+ default:
150
+ return DerivedMetricAttributeType.UNRECOGNIZED;
151
+ }
152
+ }
153
+
154
+ export function derivedMetricAttributeTypeToJSON(object: DerivedMetricAttributeType): string {
155
+ switch (object) {
156
+ case DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_UNSPECIFIED:
157
+ return "DERIVED_METRIC_ATTRIBUTE_TYPE_UNSPECIFIED";
158
+ case DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_STRING:
159
+ return "DERIVED_METRIC_ATTRIBUTE_TYPE_STRING";
160
+ case DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_BOOL:
161
+ return "DERIVED_METRIC_ATTRIBUTE_TYPE_BOOL";
162
+ case DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_INT:
163
+ return "DERIVED_METRIC_ATTRIBUTE_TYPE_INT";
164
+ case DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_DOUBLE:
165
+ return "DERIVED_METRIC_ATTRIBUTE_TYPE_DOUBLE";
166
+ case DerivedMetricAttributeType.DERIVED_METRIC_ATTRIBUTE_TYPE_MIXED:
167
+ return "DERIVED_METRIC_ATTRIBUTE_TYPE_MIXED";
168
+ case DerivedMetricAttributeType.UNRECOGNIZED:
169
+ default:
170
+ return "UNRECOGNIZED";
171
+ }
172
+ }
173
+
116
174
  export interface DerivedMetric {
117
175
  id: string;
118
176
  organizationId: string;
@@ -140,10 +198,13 @@ export interface DerivedMetricProgram {
140
198
  /** Evaluates to a number, or to an empty optional meaning no sample. */
141
199
  valueExpression: string;
142
200
  /**
143
- * Optional. Evaluates to a string selecting the series -- one series per distinct value, the same
144
- * way any other metric groups. Empty, or unresolved, yields one unlabelled series.
201
+ * Trace attribute keys stamped onto every emitted point, so any dashboard widget can group or
202
+ * filter by any of them at read time -- one measurement, many groupings. At most four (the read
203
+ * side resolves four group-by keys). Values render canonically; a missing attribute becomes the
204
+ * empty string, never a dropped sample. Immutable after create: changing dimensions rewrites
205
+ * every series identity.
145
206
  */
146
- groupByExpression: string;
207
+ dimensions: string[];
147
208
  }
148
209
 
149
210
  export interface CreateDerivedMetricRequest {
@@ -196,7 +257,7 @@ export interface UpdateDerivedMetricRequest_DerivedMetricUpdates {
196
257
  | string
197
258
  | undefined;
198
259
  /**
199
- * The measurement (population, value, group-by, unit, slug) is immutable -- changing it
260
+ * The measurement (population, value, dimensions, unit, slug) is immutable -- changing it
200
261
  * means a new metric.
201
262
  */
202
263
  enabled?: boolean | undefined;
@@ -249,8 +310,16 @@ export interface DryRunTraceResult {
249
310
 
250
311
  export interface DryRunEmission {
251
312
  value: number;
252
- /** The series this trace would land in. Empty when ungrouped or the group-by did not resolve. */
253
- groupValue: string;
313
+ /**
314
+ * Exactly one entry per declared dimension, rendered and truncated precisely as the persisted
315
+ * point attribute would be -- the preview must never disagree with the stored series.
316
+ */
317
+ resolvedDimensions: { [key: string]: string };
318
+ }
319
+
320
+ export interface DryRunEmission_ResolvedDimensionsEntry {
321
+ key: string;
322
+ value: string;
254
323
  }
255
324
 
256
325
  export interface DryRunNonEmission {
@@ -264,6 +333,48 @@ export interface DerivedMetricOutcomeCount {
264
333
  count: number;
265
334
  }
266
335
 
336
+ export interface ListDerivedMetricAttributesRequest {
337
+ organizationId: string;
338
+ projectId: string;
339
+ }
340
+
341
+ export interface ListDerivedMetricAttributesResponse {
342
+ status:
343
+ | ResponseStatus
344
+ | undefined;
345
+ /** Trace-level attributes: usable as dimensions, population filters, or trace-attribute operands. */
346
+ traceAttributes: DerivedMetricAttribute[];
347
+ /** Events observed on recent traces, each with the attribute keys seen on that event name. */
348
+ events: DerivedMetricEventAttributes[];
349
+ /**
350
+ * Finished traces the walk covered (oversized/unreadable histories count -- permanent skips are
351
+ * not truncation). traces_sampled < traces_selected means the request budget expired mid-walk and
352
+ * the catalog is a truncated sample a retry can improve on, same contract as the dry run.
353
+ */
354
+ tracesSampled: number;
355
+ /** Finished traces the walk selected; zero means the project has no history yet. */
356
+ tracesSelected: number;
357
+ /**
358
+ * True when an output cap (distinct event names or total keys) dropped entries -- the catalog is
359
+ * complete for what it lists, but more keys exist than fit in one response.
360
+ */
361
+ catalogCapped: boolean;
362
+ }
363
+
364
+ export interface DerivedMetricAttribute {
365
+ key: string;
366
+ /** The stored type, from the typed attribute payloads -- not inferred from rendered strings. */
367
+ type: DerivedMetricAttributeType;
368
+ /** A few observed values, rendered canonically. Never exhaustive. */
369
+ sampleValues: string[];
370
+ }
371
+
372
+ export interface DerivedMetricEventAttributes {
373
+ /** The event's author-facing name; only info/warn/error events carry one. */
374
+ name: string;
375
+ attributes: DerivedMetricAttribute[];
376
+ }
377
+
267
378
  function createBaseDerivedMetric(): DerivedMetric {
268
379
  return {
269
380
  id: "",
@@ -540,7 +651,7 @@ export const DerivedMetric: MessageFns<DerivedMetric> = {
540
651
  };
541
652
 
542
653
  function createBaseDerivedMetricProgram(): DerivedMetricProgram {
543
- return { populationExpression: "", valueExpression: "", groupByExpression: "" };
654
+ return { populationExpression: "", valueExpression: "", dimensions: [] };
544
655
  }
545
656
 
546
657
  export const DerivedMetricProgram: MessageFns<DerivedMetricProgram> = {
@@ -551,8 +662,8 @@ export const DerivedMetricProgram: MessageFns<DerivedMetricProgram> = {
551
662
  if (message.valueExpression !== "") {
552
663
  writer.uint32(18).string(message.valueExpression);
553
664
  }
554
- if (message.groupByExpression !== "") {
555
- writer.uint32(26).string(message.groupByExpression);
665
+ for (const v of message.dimensions) {
666
+ writer.uint32(34).string(v!);
556
667
  }
557
668
  return writer;
558
669
  },
@@ -580,12 +691,12 @@ export const DerivedMetricProgram: MessageFns<DerivedMetricProgram> = {
580
691
  message.valueExpression = reader.string();
581
692
  continue;
582
693
  }
583
- case 3: {
584
- if (tag !== 26) {
694
+ case 4: {
695
+ if (tag !== 34) {
585
696
  break;
586
697
  }
587
698
 
588
- message.groupByExpression = reader.string();
699
+ message.dimensions.push(reader.string());
589
700
  continue;
590
701
  }
591
702
  }
@@ -609,11 +720,9 @@ export const DerivedMetricProgram: MessageFns<DerivedMetricProgram> = {
609
720
  : isSet(object.value_expression)
610
721
  ? globalThis.String(object.value_expression)
611
722
  : "",
612
- groupByExpression: isSet(object.groupByExpression)
613
- ? globalThis.String(object.groupByExpression)
614
- : isSet(object.group_by_expression)
615
- ? globalThis.String(object.group_by_expression)
616
- : "",
723
+ dimensions: globalThis.Array.isArray(object?.dimensions)
724
+ ? object.dimensions.map((e: any) => globalThis.String(e))
725
+ : [],
617
726
  };
618
727
  },
619
728
 
@@ -625,8 +734,8 @@ export const DerivedMetricProgram: MessageFns<DerivedMetricProgram> = {
625
734
  if (message.valueExpression !== "") {
626
735
  obj.valueExpression = message.valueExpression;
627
736
  }
628
- if (message.groupByExpression !== "") {
629
- obj.groupByExpression = message.groupByExpression;
737
+ if (message.dimensions?.length) {
738
+ obj.dimensions = message.dimensions;
630
739
  }
631
740
  return obj;
632
741
  },
@@ -638,7 +747,7 @@ export const DerivedMetricProgram: MessageFns<DerivedMetricProgram> = {
638
747
  const message = createBaseDerivedMetricProgram();
639
748
  message.populationExpression = object.populationExpression ?? "";
640
749
  message.valueExpression = object.valueExpression ?? "";
641
- message.groupByExpression = object.groupByExpression ?? "";
750
+ message.dimensions = object.dimensions?.map((e) => e) || [];
642
751
  return message;
643
752
  },
644
753
  };
@@ -2102,7 +2211,7 @@ export const DryRunTraceResult: MessageFns<DryRunTraceResult> = {
2102
2211
  };
2103
2212
 
2104
2213
  function createBaseDryRunEmission(): DryRunEmission {
2105
- return { value: 0, groupValue: "" };
2214
+ return { value: 0, resolvedDimensions: {} };
2106
2215
  }
2107
2216
 
2108
2217
  export const DryRunEmission: MessageFns<DryRunEmission> = {
@@ -2110,9 +2219,9 @@ export const DryRunEmission: MessageFns<DryRunEmission> = {
2110
2219
  if (message.value !== 0) {
2111
2220
  writer.uint32(9).double(message.value);
2112
2221
  }
2113
- if (message.groupValue !== "") {
2114
- writer.uint32(18).string(message.groupValue);
2115
- }
2222
+ globalThis.Object.entries(message.resolvedDimensions).forEach(([key, value]: [string, string]) => {
2223
+ DryRunEmission_ResolvedDimensionsEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).join();
2224
+ });
2116
2225
  return writer;
2117
2226
  },
2118
2227
 
@@ -2131,12 +2240,15 @@ export const DryRunEmission: MessageFns<DryRunEmission> = {
2131
2240
  message.value = reader.double();
2132
2241
  continue;
2133
2242
  }
2134
- case 2: {
2135
- if (tag !== 18) {
2243
+ case 3: {
2244
+ if (tag !== 26) {
2136
2245
  break;
2137
2246
  }
2138
2247
 
2139
- message.groupValue = reader.string();
2248
+ const entry3 = DryRunEmission_ResolvedDimensionsEntry.decode(reader, reader.uint32());
2249
+ if (entry3.value !== undefined) {
2250
+ message.resolvedDimensions[entry3.key] = entry3.value;
2251
+ }
2140
2252
  continue;
2141
2253
  }
2142
2254
  }
@@ -2151,11 +2263,23 @@ export const DryRunEmission: MessageFns<DryRunEmission> = {
2151
2263
  fromJSON(object: any): DryRunEmission {
2152
2264
  return {
2153
2265
  value: isSet(object.value) ? globalThis.Number(object.value) : 0,
2154
- groupValue: isSet(object.groupValue)
2155
- ? globalThis.String(object.groupValue)
2156
- : isSet(object.group_value)
2157
- ? globalThis.String(object.group_value)
2158
- : "",
2266
+ resolvedDimensions: isObject(object.resolvedDimensions)
2267
+ ? (globalThis.Object.entries(object.resolvedDimensions) as [string, any][]).reduce(
2268
+ (acc: { [key: string]: string }, [key, value]: [string, any]) => {
2269
+ acc[key] = globalThis.String(value);
2270
+ return acc;
2271
+ },
2272
+ {},
2273
+ )
2274
+ : isObject(object.resolved_dimensions)
2275
+ ? (globalThis.Object.entries(object.resolved_dimensions) as [string, any][]).reduce(
2276
+ (acc: { [key: string]: string }, [key, value]: [string, any]) => {
2277
+ acc[key] = globalThis.String(value);
2278
+ return acc;
2279
+ },
2280
+ {},
2281
+ )
2282
+ : {},
2159
2283
  };
2160
2284
  },
2161
2285
 
@@ -2164,8 +2288,14 @@ export const DryRunEmission: MessageFns<DryRunEmission> = {
2164
2288
  if (message.value !== 0) {
2165
2289
  obj.value = message.value;
2166
2290
  }
2167
- if (message.groupValue !== "") {
2168
- obj.groupValue = message.groupValue;
2291
+ if (message.resolvedDimensions) {
2292
+ const entries = globalThis.Object.entries(message.resolvedDimensions) as [string, string][];
2293
+ if (entries.length > 0) {
2294
+ obj.resolvedDimensions = {};
2295
+ entries.forEach(([k, v]) => {
2296
+ obj.resolvedDimensions[k] = v;
2297
+ });
2298
+ }
2169
2299
  }
2170
2300
  return obj;
2171
2301
  },
@@ -2176,7 +2306,93 @@ export const DryRunEmission: MessageFns<DryRunEmission> = {
2176
2306
  fromPartial<I extends Exact<DeepPartial<DryRunEmission>, I>>(object: I): DryRunEmission {
2177
2307
  const message = createBaseDryRunEmission();
2178
2308
  message.value = object.value ?? 0;
2179
- message.groupValue = object.groupValue ?? "";
2309
+ message.resolvedDimensions = (globalThis.Object.entries(object.resolvedDimensions ?? {}) as [string, string][])
2310
+ .reduce((acc: { [key: string]: string }, [key, value]: [string, string]) => {
2311
+ if (value !== undefined) {
2312
+ acc[key] = globalThis.String(value);
2313
+ }
2314
+ return acc;
2315
+ }, {});
2316
+ return message;
2317
+ },
2318
+ };
2319
+
2320
+ function createBaseDryRunEmission_ResolvedDimensionsEntry(): DryRunEmission_ResolvedDimensionsEntry {
2321
+ return { key: "", value: "" };
2322
+ }
2323
+
2324
+ export const DryRunEmission_ResolvedDimensionsEntry: MessageFns<DryRunEmission_ResolvedDimensionsEntry> = {
2325
+ encode(message: DryRunEmission_ResolvedDimensionsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2326
+ if (message.key !== "") {
2327
+ writer.uint32(10).string(message.key);
2328
+ }
2329
+ if (message.value !== "") {
2330
+ writer.uint32(18).string(message.value);
2331
+ }
2332
+ return writer;
2333
+ },
2334
+
2335
+ decode(input: BinaryReader | Uint8Array, length?: number): DryRunEmission_ResolvedDimensionsEntry {
2336
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2337
+ const end = length === undefined ? reader.len : reader.pos + length;
2338
+ const message = createBaseDryRunEmission_ResolvedDimensionsEntry();
2339
+ while (reader.pos < end) {
2340
+ const tag = reader.uint32();
2341
+ switch (tag >>> 3) {
2342
+ case 1: {
2343
+ if (tag !== 10) {
2344
+ break;
2345
+ }
2346
+
2347
+ message.key = reader.string();
2348
+ continue;
2349
+ }
2350
+ case 2: {
2351
+ if (tag !== 18) {
2352
+ break;
2353
+ }
2354
+
2355
+ message.value = reader.string();
2356
+ continue;
2357
+ }
2358
+ }
2359
+ if ((tag & 7) === 4 || tag === 0) {
2360
+ break;
2361
+ }
2362
+ reader.skip(tag & 7);
2363
+ }
2364
+ return message;
2365
+ },
2366
+
2367
+ fromJSON(object: any): DryRunEmission_ResolvedDimensionsEntry {
2368
+ return {
2369
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
2370
+ value: isSet(object.value) ? globalThis.String(object.value) : "",
2371
+ };
2372
+ },
2373
+
2374
+ toJSON(message: DryRunEmission_ResolvedDimensionsEntry): unknown {
2375
+ const obj: any = {};
2376
+ if (message.key !== "") {
2377
+ obj.key = message.key;
2378
+ }
2379
+ if (message.value !== "") {
2380
+ obj.value = message.value;
2381
+ }
2382
+ return obj;
2383
+ },
2384
+
2385
+ create<I extends Exact<DeepPartial<DryRunEmission_ResolvedDimensionsEntry>, I>>(
2386
+ base?: I,
2387
+ ): DryRunEmission_ResolvedDimensionsEntry {
2388
+ return DryRunEmission_ResolvedDimensionsEntry.fromPartial(base ?? ({} as any));
2389
+ },
2390
+ fromPartial<I extends Exact<DeepPartial<DryRunEmission_ResolvedDimensionsEntry>, I>>(
2391
+ object: I,
2392
+ ): DryRunEmission_ResolvedDimensionsEntry {
2393
+ const message = createBaseDryRunEmission_ResolvedDimensionsEntry();
2394
+ message.key = object.key ?? "";
2395
+ message.value = object.value ?? "";
2180
2396
  return message;
2181
2397
  },
2182
2398
  };
@@ -2333,6 +2549,439 @@ export const DerivedMetricOutcomeCount: MessageFns<DerivedMetricOutcomeCount> =
2333
2549
  },
2334
2550
  };
2335
2551
 
2552
+ function createBaseListDerivedMetricAttributesRequest(): ListDerivedMetricAttributesRequest {
2553
+ return { organizationId: "", projectId: "" };
2554
+ }
2555
+
2556
+ export const ListDerivedMetricAttributesRequest: MessageFns<ListDerivedMetricAttributesRequest> = {
2557
+ encode(message: ListDerivedMetricAttributesRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2558
+ if (message.organizationId !== "") {
2559
+ writer.uint32(10).string(message.organizationId);
2560
+ }
2561
+ if (message.projectId !== "") {
2562
+ writer.uint32(18).string(message.projectId);
2563
+ }
2564
+ return writer;
2565
+ },
2566
+
2567
+ decode(input: BinaryReader | Uint8Array, length?: number): ListDerivedMetricAttributesRequest {
2568
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2569
+ const end = length === undefined ? reader.len : reader.pos + length;
2570
+ const message = createBaseListDerivedMetricAttributesRequest();
2571
+ while (reader.pos < end) {
2572
+ const tag = reader.uint32();
2573
+ switch (tag >>> 3) {
2574
+ case 1: {
2575
+ if (tag !== 10) {
2576
+ break;
2577
+ }
2578
+
2579
+ message.organizationId = reader.string();
2580
+ continue;
2581
+ }
2582
+ case 2: {
2583
+ if (tag !== 18) {
2584
+ break;
2585
+ }
2586
+
2587
+ message.projectId = reader.string();
2588
+ continue;
2589
+ }
2590
+ }
2591
+ if ((tag & 7) === 4 || tag === 0) {
2592
+ break;
2593
+ }
2594
+ reader.skip(tag & 7);
2595
+ }
2596
+ return message;
2597
+ },
2598
+
2599
+ fromJSON(object: any): ListDerivedMetricAttributesRequest {
2600
+ return {
2601
+ organizationId: isSet(object.organizationId)
2602
+ ? globalThis.String(object.organizationId)
2603
+ : isSet(object.organization_id)
2604
+ ? globalThis.String(object.organization_id)
2605
+ : "",
2606
+ projectId: isSet(object.projectId)
2607
+ ? globalThis.String(object.projectId)
2608
+ : isSet(object.project_id)
2609
+ ? globalThis.String(object.project_id)
2610
+ : "",
2611
+ };
2612
+ },
2613
+
2614
+ toJSON(message: ListDerivedMetricAttributesRequest): unknown {
2615
+ const obj: any = {};
2616
+ if (message.organizationId !== "") {
2617
+ obj.organizationId = message.organizationId;
2618
+ }
2619
+ if (message.projectId !== "") {
2620
+ obj.projectId = message.projectId;
2621
+ }
2622
+ return obj;
2623
+ },
2624
+
2625
+ create<I extends Exact<DeepPartial<ListDerivedMetricAttributesRequest>, I>>(
2626
+ base?: I,
2627
+ ): ListDerivedMetricAttributesRequest {
2628
+ return ListDerivedMetricAttributesRequest.fromPartial(base ?? ({} as any));
2629
+ },
2630
+ fromPartial<I extends Exact<DeepPartial<ListDerivedMetricAttributesRequest>, I>>(
2631
+ object: I,
2632
+ ): ListDerivedMetricAttributesRequest {
2633
+ const message = createBaseListDerivedMetricAttributesRequest();
2634
+ message.organizationId = object.organizationId ?? "";
2635
+ message.projectId = object.projectId ?? "";
2636
+ return message;
2637
+ },
2638
+ };
2639
+
2640
+ function createBaseListDerivedMetricAttributesResponse(): ListDerivedMetricAttributesResponse {
2641
+ return {
2642
+ status: undefined,
2643
+ traceAttributes: [],
2644
+ events: [],
2645
+ tracesSampled: 0,
2646
+ tracesSelected: 0,
2647
+ catalogCapped: false,
2648
+ };
2649
+ }
2650
+
2651
+ export const ListDerivedMetricAttributesResponse: MessageFns<ListDerivedMetricAttributesResponse> = {
2652
+ encode(message: ListDerivedMetricAttributesResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2653
+ if (message.status !== undefined) {
2654
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
2655
+ }
2656
+ for (const v of message.traceAttributes) {
2657
+ DerivedMetricAttribute.encode(v!, writer.uint32(18).fork()).join();
2658
+ }
2659
+ for (const v of message.events) {
2660
+ DerivedMetricEventAttributes.encode(v!, writer.uint32(26).fork()).join();
2661
+ }
2662
+ if (message.tracesSampled !== 0) {
2663
+ writer.uint32(32).uint32(message.tracesSampled);
2664
+ }
2665
+ if (message.tracesSelected !== 0) {
2666
+ writer.uint32(40).uint32(message.tracesSelected);
2667
+ }
2668
+ if (message.catalogCapped !== false) {
2669
+ writer.uint32(48).bool(message.catalogCapped);
2670
+ }
2671
+ return writer;
2672
+ },
2673
+
2674
+ decode(input: BinaryReader | Uint8Array, length?: number): ListDerivedMetricAttributesResponse {
2675
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2676
+ const end = length === undefined ? reader.len : reader.pos + length;
2677
+ const message = createBaseListDerivedMetricAttributesResponse();
2678
+ while (reader.pos < end) {
2679
+ const tag = reader.uint32();
2680
+ switch (tag >>> 3) {
2681
+ case 1: {
2682
+ if (tag !== 10) {
2683
+ break;
2684
+ }
2685
+
2686
+ message.status = ResponseStatus.decode(reader, reader.uint32());
2687
+ continue;
2688
+ }
2689
+ case 2: {
2690
+ if (tag !== 18) {
2691
+ break;
2692
+ }
2693
+
2694
+ message.traceAttributes.push(DerivedMetricAttribute.decode(reader, reader.uint32()));
2695
+ continue;
2696
+ }
2697
+ case 3: {
2698
+ if (tag !== 26) {
2699
+ break;
2700
+ }
2701
+
2702
+ message.events.push(DerivedMetricEventAttributes.decode(reader, reader.uint32()));
2703
+ continue;
2704
+ }
2705
+ case 4: {
2706
+ if (tag !== 32) {
2707
+ break;
2708
+ }
2709
+
2710
+ message.tracesSampled = reader.uint32();
2711
+ continue;
2712
+ }
2713
+ case 5: {
2714
+ if (tag !== 40) {
2715
+ break;
2716
+ }
2717
+
2718
+ message.tracesSelected = reader.uint32();
2719
+ continue;
2720
+ }
2721
+ case 6: {
2722
+ if (tag !== 48) {
2723
+ break;
2724
+ }
2725
+
2726
+ message.catalogCapped = reader.bool();
2727
+ continue;
2728
+ }
2729
+ }
2730
+ if ((tag & 7) === 4 || tag === 0) {
2731
+ break;
2732
+ }
2733
+ reader.skip(tag & 7);
2734
+ }
2735
+ return message;
2736
+ },
2737
+
2738
+ fromJSON(object: any): ListDerivedMetricAttributesResponse {
2739
+ return {
2740
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
2741
+ traceAttributes: globalThis.Array.isArray(object?.traceAttributes)
2742
+ ? object.traceAttributes.map((e: any) => DerivedMetricAttribute.fromJSON(e))
2743
+ : globalThis.Array.isArray(object?.trace_attributes)
2744
+ ? object.trace_attributes.map((e: any) => DerivedMetricAttribute.fromJSON(e))
2745
+ : [],
2746
+ events: globalThis.Array.isArray(object?.events)
2747
+ ? object.events.map((e: any) => DerivedMetricEventAttributes.fromJSON(e))
2748
+ : [],
2749
+ tracesSampled: isSet(object.tracesSampled)
2750
+ ? globalThis.Number(object.tracesSampled)
2751
+ : isSet(object.traces_sampled)
2752
+ ? globalThis.Number(object.traces_sampled)
2753
+ : 0,
2754
+ tracesSelected: isSet(object.tracesSelected)
2755
+ ? globalThis.Number(object.tracesSelected)
2756
+ : isSet(object.traces_selected)
2757
+ ? globalThis.Number(object.traces_selected)
2758
+ : 0,
2759
+ catalogCapped: isSet(object.catalogCapped)
2760
+ ? globalThis.Boolean(object.catalogCapped)
2761
+ : isSet(object.catalog_capped)
2762
+ ? globalThis.Boolean(object.catalog_capped)
2763
+ : false,
2764
+ };
2765
+ },
2766
+
2767
+ toJSON(message: ListDerivedMetricAttributesResponse): unknown {
2768
+ const obj: any = {};
2769
+ if (message.status !== undefined) {
2770
+ obj.status = ResponseStatus.toJSON(message.status);
2771
+ }
2772
+ if (message.traceAttributes?.length) {
2773
+ obj.traceAttributes = message.traceAttributes.map((e) => DerivedMetricAttribute.toJSON(e));
2774
+ }
2775
+ if (message.events?.length) {
2776
+ obj.events = message.events.map((e) => DerivedMetricEventAttributes.toJSON(e));
2777
+ }
2778
+ if (message.tracesSampled !== 0) {
2779
+ obj.tracesSampled = Math.round(message.tracesSampled);
2780
+ }
2781
+ if (message.tracesSelected !== 0) {
2782
+ obj.tracesSelected = Math.round(message.tracesSelected);
2783
+ }
2784
+ if (message.catalogCapped !== false) {
2785
+ obj.catalogCapped = message.catalogCapped;
2786
+ }
2787
+ return obj;
2788
+ },
2789
+
2790
+ create<I extends Exact<DeepPartial<ListDerivedMetricAttributesResponse>, I>>(
2791
+ base?: I,
2792
+ ): ListDerivedMetricAttributesResponse {
2793
+ return ListDerivedMetricAttributesResponse.fromPartial(base ?? ({} as any));
2794
+ },
2795
+ fromPartial<I extends Exact<DeepPartial<ListDerivedMetricAttributesResponse>, I>>(
2796
+ object: I,
2797
+ ): ListDerivedMetricAttributesResponse {
2798
+ const message = createBaseListDerivedMetricAttributesResponse();
2799
+ message.status = (object.status !== undefined && object.status !== null)
2800
+ ? ResponseStatus.fromPartial(object.status)
2801
+ : undefined;
2802
+ message.traceAttributes = object.traceAttributes?.map((e) => DerivedMetricAttribute.fromPartial(e)) || [];
2803
+ message.events = object.events?.map((e) => DerivedMetricEventAttributes.fromPartial(e)) || [];
2804
+ message.tracesSampled = object.tracesSampled ?? 0;
2805
+ message.tracesSelected = object.tracesSelected ?? 0;
2806
+ message.catalogCapped = object.catalogCapped ?? false;
2807
+ return message;
2808
+ },
2809
+ };
2810
+
2811
+ function createBaseDerivedMetricAttribute(): DerivedMetricAttribute {
2812
+ return { key: "", type: 0, sampleValues: [] };
2813
+ }
2814
+
2815
+ export const DerivedMetricAttribute: MessageFns<DerivedMetricAttribute> = {
2816
+ encode(message: DerivedMetricAttribute, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2817
+ if (message.key !== "") {
2818
+ writer.uint32(10).string(message.key);
2819
+ }
2820
+ if (message.type !== 0) {
2821
+ writer.uint32(16).int32(message.type);
2822
+ }
2823
+ for (const v of message.sampleValues) {
2824
+ writer.uint32(26).string(v!);
2825
+ }
2826
+ return writer;
2827
+ },
2828
+
2829
+ decode(input: BinaryReader | Uint8Array, length?: number): DerivedMetricAttribute {
2830
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2831
+ const end = length === undefined ? reader.len : reader.pos + length;
2832
+ const message = createBaseDerivedMetricAttribute();
2833
+ while (reader.pos < end) {
2834
+ const tag = reader.uint32();
2835
+ switch (tag >>> 3) {
2836
+ case 1: {
2837
+ if (tag !== 10) {
2838
+ break;
2839
+ }
2840
+
2841
+ message.key = reader.string();
2842
+ continue;
2843
+ }
2844
+ case 2: {
2845
+ if (tag !== 16) {
2846
+ break;
2847
+ }
2848
+
2849
+ message.type = reader.int32() as any;
2850
+ continue;
2851
+ }
2852
+ case 3: {
2853
+ if (tag !== 26) {
2854
+ break;
2855
+ }
2856
+
2857
+ message.sampleValues.push(reader.string());
2858
+ continue;
2859
+ }
2860
+ }
2861
+ if ((tag & 7) === 4 || tag === 0) {
2862
+ break;
2863
+ }
2864
+ reader.skip(tag & 7);
2865
+ }
2866
+ return message;
2867
+ },
2868
+
2869
+ fromJSON(object: any): DerivedMetricAttribute {
2870
+ return {
2871
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
2872
+ type: isSet(object.type) ? derivedMetricAttributeTypeFromJSON(object.type) : 0,
2873
+ sampleValues: globalThis.Array.isArray(object?.sampleValues)
2874
+ ? object.sampleValues.map((e: any) => globalThis.String(e))
2875
+ : globalThis.Array.isArray(object?.sample_values)
2876
+ ? object.sample_values.map((e: any) => globalThis.String(e))
2877
+ : [],
2878
+ };
2879
+ },
2880
+
2881
+ toJSON(message: DerivedMetricAttribute): unknown {
2882
+ const obj: any = {};
2883
+ if (message.key !== "") {
2884
+ obj.key = message.key;
2885
+ }
2886
+ if (message.type !== 0) {
2887
+ obj.type = derivedMetricAttributeTypeToJSON(message.type);
2888
+ }
2889
+ if (message.sampleValues?.length) {
2890
+ obj.sampleValues = message.sampleValues;
2891
+ }
2892
+ return obj;
2893
+ },
2894
+
2895
+ create<I extends Exact<DeepPartial<DerivedMetricAttribute>, I>>(base?: I): DerivedMetricAttribute {
2896
+ return DerivedMetricAttribute.fromPartial(base ?? ({} as any));
2897
+ },
2898
+ fromPartial<I extends Exact<DeepPartial<DerivedMetricAttribute>, I>>(object: I): DerivedMetricAttribute {
2899
+ const message = createBaseDerivedMetricAttribute();
2900
+ message.key = object.key ?? "";
2901
+ message.type = object.type ?? 0;
2902
+ message.sampleValues = object.sampleValues?.map((e) => e) || [];
2903
+ return message;
2904
+ },
2905
+ };
2906
+
2907
+ function createBaseDerivedMetricEventAttributes(): DerivedMetricEventAttributes {
2908
+ return { name: "", attributes: [] };
2909
+ }
2910
+
2911
+ export const DerivedMetricEventAttributes: MessageFns<DerivedMetricEventAttributes> = {
2912
+ encode(message: DerivedMetricEventAttributes, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
2913
+ if (message.name !== "") {
2914
+ writer.uint32(10).string(message.name);
2915
+ }
2916
+ for (const v of message.attributes) {
2917
+ DerivedMetricAttribute.encode(v!, writer.uint32(18).fork()).join();
2918
+ }
2919
+ return writer;
2920
+ },
2921
+
2922
+ decode(input: BinaryReader | Uint8Array, length?: number): DerivedMetricEventAttributes {
2923
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2924
+ const end = length === undefined ? reader.len : reader.pos + length;
2925
+ const message = createBaseDerivedMetricEventAttributes();
2926
+ while (reader.pos < end) {
2927
+ const tag = reader.uint32();
2928
+ switch (tag >>> 3) {
2929
+ case 1: {
2930
+ if (tag !== 10) {
2931
+ break;
2932
+ }
2933
+
2934
+ message.name = reader.string();
2935
+ continue;
2936
+ }
2937
+ case 2: {
2938
+ if (tag !== 18) {
2939
+ break;
2940
+ }
2941
+
2942
+ message.attributes.push(DerivedMetricAttribute.decode(reader, reader.uint32()));
2943
+ continue;
2944
+ }
2945
+ }
2946
+ if ((tag & 7) === 4 || tag === 0) {
2947
+ break;
2948
+ }
2949
+ reader.skip(tag & 7);
2950
+ }
2951
+ return message;
2952
+ },
2953
+
2954
+ fromJSON(object: any): DerivedMetricEventAttributes {
2955
+ return {
2956
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
2957
+ attributes: globalThis.Array.isArray(object?.attributes)
2958
+ ? object.attributes.map((e: any) => DerivedMetricAttribute.fromJSON(e))
2959
+ : [],
2960
+ };
2961
+ },
2962
+
2963
+ toJSON(message: DerivedMetricEventAttributes): unknown {
2964
+ const obj: any = {};
2965
+ if (message.name !== "") {
2966
+ obj.name = message.name;
2967
+ }
2968
+ if (message.attributes?.length) {
2969
+ obj.attributes = message.attributes.map((e) => DerivedMetricAttribute.toJSON(e));
2970
+ }
2971
+ return obj;
2972
+ },
2973
+
2974
+ create<I extends Exact<DeepPartial<DerivedMetricEventAttributes>, I>>(base?: I): DerivedMetricEventAttributes {
2975
+ return DerivedMetricEventAttributes.fromPartial(base ?? ({} as any));
2976
+ },
2977
+ fromPartial<I extends Exact<DeepPartial<DerivedMetricEventAttributes>, I>>(object: I): DerivedMetricEventAttributes {
2978
+ const message = createBaseDerivedMetricEventAttributes();
2979
+ message.name = object.name ?? "";
2980
+ message.attributes = object.attributes?.map((e) => DerivedMetricAttribute.fromPartial(e)) || [];
2981
+ return message;
2982
+ },
2983
+ };
2984
+
2336
2985
  /**
2337
2986
  * DerivedMetricGatewayService provides web client access to derived metrics: definitions that turn
2338
2987
  * each finished trace into one gauge datapoint. The resulting series is queried through
@@ -2346,6 +2995,14 @@ export interface DerivedMetricGatewayService {
2346
2995
  DeleteDerivedMetric(request: DeleteDerivedMetricRequest, metadata?: Metadata): Promise<DeleteDerivedMetricResponse>;
2347
2996
  /** Evaluates an unsaved program against recent finished traces; persists nothing. */
2348
2997
  DryRunDerivedMetric(request: DryRunDerivedMetricRequest, metadata?: Metadata): Promise<DryRunDerivedMetricResponse>;
2998
+ /**
2999
+ * The authoring catalog: attribute keys, types and sample values observed on recent finished
3000
+ * traces -- trace-level and per-event -- so a builder offers real keys instead of free text.
3001
+ */
3002
+ ListDerivedMetricAttributes(
3003
+ request: ListDerivedMetricAttributesRequest,
3004
+ metadata?: Metadata,
3005
+ ): Promise<ListDerivedMetricAttributesResponse>;
2349
3006
  }
2350
3007
 
2351
3008
  export const DerivedMetricGatewayServiceServiceName = "gateway.web.v1.DerivedMetricGatewayService";
@@ -2361,6 +3018,7 @@ export class DerivedMetricGatewayServiceClientImpl implements DerivedMetricGatew
2361
3018
  this.UpdateDerivedMetric = this.UpdateDerivedMetric.bind(this);
2362
3019
  this.DeleteDerivedMetric = this.DeleteDerivedMetric.bind(this);
2363
3020
  this.DryRunDerivedMetric = this.DryRunDerivedMetric.bind(this);
3021
+ this.ListDerivedMetricAttributes = this.ListDerivedMetricAttributes.bind(this);
2364
3022
  }
2365
3023
  CreateDerivedMetric(request: CreateDerivedMetricRequest, metadata?: Metadata): Promise<CreateDerivedMetricResponse> {
2366
3024
  const data = CreateDerivedMetricRequest.encode(request).finish();
@@ -2397,6 +3055,15 @@ export class DerivedMetricGatewayServiceClientImpl implements DerivedMetricGatew
2397
3055
  const promise = this.rpc.request(this.service, "DryRunDerivedMetric", data, metadata);
2398
3056
  return promise.then((data) => DryRunDerivedMetricResponse.decode(new BinaryReader(data)));
2399
3057
  }
3058
+
3059
+ ListDerivedMetricAttributes(
3060
+ request: ListDerivedMetricAttributesRequest,
3061
+ metadata?: Metadata,
3062
+ ): Promise<ListDerivedMetricAttributesResponse> {
3063
+ const data = ListDerivedMetricAttributesRequest.encode(request).finish();
3064
+ const promise = this.rpc.request(this.service, "ListDerivedMetricAttributes", data, metadata);
3065
+ return promise.then((data) => ListDerivedMetricAttributesResponse.decode(new BinaryReader(data)));
3066
+ }
2400
3067
  }
2401
3068
 
2402
3069
  interface Rpc {
@@ -2437,6 +3104,10 @@ function fromJsonTimestamp(o: any): Date {
2437
3104
  }
2438
3105
  }
2439
3106
 
3107
+ function isObject(value: any): boolean {
3108
+ return typeof value === "object" && value !== null;
3109
+ }
3110
+
2440
3111
  function isSet(value: any): boolean {
2441
3112
  return value !== null && value !== undefined;
2442
3113
  }