github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/packages/pyroscope-models/src/trace.ts (about)

     1  import { z } from 'zod';
     2  
     3  const ReferencesSchema = z.object({
     4    refType: z.string(),
     5    traceID: z.string(),
     6    spanID: z.string(),
     7  });
     8  
     9  const TagsSchema = z.object({
    10    key: z.string(),
    11    type: z.string(),
    12    value: z.union([z.boolean(), z.number(), z.string()]),
    13  });
    14  
    15  const TraceSpanSchema = z.object({
    16    traceID: z.string(),
    17    spanID: z.string(),
    18    flags: z.string(),
    19    operationName: z.string(),
    20    references: z.array(ReferencesSchema),
    21    startTime: z.number(),
    22    duration: z.number(),
    23    tags: z.array(TagsSchema),
    24    logs: z.object({
    25      timestamp: z.number(),
    26      fields: z.array(TagsSchema),
    27    }),
    28    processID: z.string(),
    29    warnings: z.any(),
    30  });
    31  
    32  const ProcessSchema = z.object({
    33    serviceName: z.string(),
    34    tags: z.array(TagsSchema),
    35  });
    36  
    37  const TraceSchema = z.object({
    38    traceID: z.string(),
    39    spans: z.array(TraceSpanSchema),
    40    processes: z.record(ProcessSchema),
    41    warnings: z.any(),
    42  });
    43  
    44  export type Trace = z.infer<typeof TraceSchema>;
    45  export type TraceSpan = z.infer<typeof TraceSpanSchema>;