1// Copyright (c) 2017 Uber Technologies, Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15/** 16 * All timestamps are in microseconds 17 */ 18 19// TODO: Everett Tech Debt: Fix KeyValuePair types 20export type TraceKeyValuePair = { 21 key: string; 22 type?: string; 23 value: any; 24}; 25 26export type TraceLink = { 27 url: string; 28 text: string; 29}; 30 31export type TraceLog = { 32 timestamp: number; 33 fields: TraceKeyValuePair[]; 34}; 35 36export type TraceProcess = { 37 serviceName: string; 38 tags: TraceKeyValuePair[]; 39}; 40 41export type TraceSpanReference = { 42 refType: 'CHILD_OF' | 'FOLLOWS_FROM'; 43 // eslint-disable-next-line no-use-before-define 44 span?: TraceSpan | null | undefined; 45 spanID: string; 46 traceID: string; 47}; 48 49export type TraceSpanData = { 50 spanID: string; 51 traceID: string; 52 processID: string; 53 operationName: string; 54 // Times are in microseconds 55 startTime: number; 56 duration: number; 57 logs: TraceLog[]; 58 tags?: TraceKeyValuePair[]; 59 references?: TraceSpanReference[]; 60 warnings?: string[] | null; 61 stackTraces?: string[]; 62 flags: number; 63 errorIconColor?: string; 64 dataFrameRowIndex?: number; 65}; 66 67export type TraceSpan = TraceSpanData & { 68 depth: number; 69 hasChildren: boolean; 70 process: TraceProcess; 71 relativeStartTime: number; 72 tags: NonNullable<TraceSpanData['tags']>; 73 references: NonNullable<TraceSpanData['references']>; 74 warnings: NonNullable<TraceSpanData['warnings']>; 75 subsidiarilyReferencedBy: TraceSpanReference[]; 76}; 77 78export type TraceData = { 79 processes: Record<string, TraceProcess>; 80 traceID: string; 81 warnings?: string[] | null; 82}; 83 84export type TraceResponse = TraceData & { 85 spans: TraceSpanData[]; 86}; 87 88export type Trace = TraceData & { 89 duration: number; 90 endTime: number; 91 spans: TraceSpan[]; 92 startTime: number; 93 traceName: string; 94 services: Array<{ name: string; numberOfSpans: number }>; 95}; 96