testResponse.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { ArrayVector, FieldDTO } from '@grafana/data';
  2. import { ZipkinSpan } from '../types';
  3. export const testResponse: ZipkinSpan[] = [
  4. {
  5. traceId: '3fa414edcef6ad90',
  6. id: '3fa414edcef6ad90',
  7. name: 'HTTP GET - api_traces_traceid',
  8. timestamp: 1605873894680409,
  9. duration: 1049141,
  10. tags: {
  11. samplerType: 'probabilistic',
  12. samplerParam: '1',
  13. },
  14. localEndpoint: {
  15. serviceName: 'tempo-querier',
  16. },
  17. },
  18. {
  19. traceId: '3fa414edcef6ad90',
  20. id: '0f5c1808567e4403',
  21. name: '/tempopb.Querier/FindTraceByID',
  22. parentId: '3fa414edcef6ad90',
  23. timestamp: 1605873894680587,
  24. duration: 1847,
  25. tags: {
  26. component: 'gRPC',
  27. spanKind: 'client',
  28. },
  29. localEndpoint: {
  30. serviceName: 'tempo-querier',
  31. },
  32. },
  33. ];
  34. function toVectors(fields: FieldDTO[]) {
  35. return fields.map((f) => ({ ...f, values: new ArrayVector<any>(f.values as any[]) }));
  36. }
  37. export const testResponseDataFrameFields = toVectors([
  38. { name: 'traceID', values: ['3fa414edcef6ad90', '3fa414edcef6ad90'] },
  39. { name: 'spanID', values: ['3fa414edcef6ad90', '0f5c1808567e4403'] },
  40. { name: 'parentSpanID', values: [undefined, '3fa414edcef6ad90'] },
  41. { name: 'operationName', values: ['HTTP GET - api_traces_traceid', '/tempopb.Querier/FindTraceByID'] },
  42. { name: 'serviceName', values: ['tempo-querier', 'tempo-querier'] },
  43. {
  44. name: 'serviceTags',
  45. values: [
  46. [
  47. { key: 'cluster', type: 'string', value: 'ops-tools1' },
  48. { key: 'container', type: 'string', value: 'tempo-query' },
  49. ],
  50. [
  51. { key: 'cluster', type: 'string', value: 'ops-tools1' },
  52. { key: 'container', type: 'string', value: 'tempo-query' },
  53. ],
  54. ],
  55. },
  56. { name: 'startTime', values: [1605873894680.409, 1605873894680.587] },
  57. { name: 'duration', values: [1049.141, 1.847] },
  58. { name: 'logs', values: [[], []] },
  59. {
  60. name: 'tags',
  61. values: [
  62. [
  63. { key: 'sampler.type', type: 'string', value: 'probabilistic' },
  64. { key: 'sampler.param', type: 'float64', value: 1 },
  65. ],
  66. [
  67. { key: 'component', type: 'string', value: 'gRPC' },
  68. { key: 'span.kind', type: 'string', value: 'client' },
  69. ],
  70. ],
  71. },
  72. { name: 'warnings', values: [undefined, undefined] },
  73. { name: 'stackTraces', values: [undefined, undefined] },
  74. ]);
  75. export const testResponseNodesFields = toNodesFrame([
  76. ['3fa414edcef6ad90', '0f5c1808567e4403'],
  77. ['tempo-querier', 'tempo-querier'],
  78. ['HTTP GET - api_traces_traceid', '/tempopb.Querier/FindTraceByID'],
  79. ['1049.14ms (100%)', '1.85ms (0.18%)'],
  80. ['1047.29ms (99.82%)', '1.85ms (100%)'],
  81. [0.9982395121342127, 0.0017604878657873442],
  82. ]);
  83. export const testResponseEdgesFields = toEdgesFrame([
  84. ['3fa414edcef6ad90--0f5c1808567e4403'],
  85. ['0f5c1808567e4403'],
  86. ['3fa414edcef6ad90'],
  87. ]);
  88. export function toNodesFrame(values: any[]) {
  89. return toVectors([
  90. { name: 'id', values: values[0] },
  91. { name: 'title', values: values[1] },
  92. { name: 'subtitle', values: values[2] },
  93. { name: 'mainstat', values: values[3] },
  94. { name: 'secondarystat', values: values[4] },
  95. {
  96. name: 'color',
  97. config: {
  98. color: {
  99. mode: 'continuous-GrYlRd',
  100. },
  101. },
  102. values: values[5],
  103. },
  104. ]);
  105. }
  106. export function toEdgesFrame(values: any[]) {
  107. return toVectors([
  108. { name: 'id', values: values[0] },
  109. { name: 'target', values: values[1] },
  110. { name: 'source', values: values[2] },
  111. ]);
  112. }