utils.tsx 866 B

12345678910111213141516171819202122232425262728
  1. import type {SpanResult, TraceResult} from './content';
  2. import type {Field} from './data';
  3. export function normalizeTraces(traces: TraceResult<string>[] | undefined) {
  4. if (!traces) {
  5. return traces;
  6. }
  7. return traces.sort(
  8. // Only sort name == null to the end, the rest leave in the original order.
  9. (t1, t2) => (t1.name ? '0' : '1').localeCompare(t2.name ? '0' : '1')
  10. );
  11. }
  12. export function getStylingSliceName(
  13. sliceName: string | null,
  14. sliceSecondaryName: string | null
  15. ) {
  16. if (sliceSecondaryName) {
  17. // Our color picking relies on the first 4 letters. Since we want to differentiate sdknames and project names we have to include part of the sdk name.
  18. return sliceSecondaryName.slice(-2) + (sliceName ?? '');
  19. }
  20. return sliceName;
  21. }
  22. export function getSecondaryNameFromSpan(span: SpanResult<Field>) {
  23. return span['sdk.name'];
  24. }