spanEvidenceKeyValueList.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {t} from 'sentry/locale';
  2. import {KeyValueListData} from 'sentry/types';
  3. import KeyValueList from '../keyValueList';
  4. import {RawSpanType} from '../spans/types';
  5. import {TraceContextSpanProxy} from './spanEvidence';
  6. type SpanEvidenceKeyValueListProps = {
  7. parentSpan: RawSpanType | TraceContextSpanProxy;
  8. repeatingSpan: RawSpanType | TraceContextSpanProxy;
  9. transactionName: string;
  10. };
  11. export function SpanEvidenceKeyValueList({
  12. transactionName,
  13. parentSpan,
  14. repeatingSpan,
  15. }: SpanEvidenceKeyValueListProps) {
  16. const data: KeyValueListData = [
  17. {
  18. key: '0',
  19. subject: t('Transaction'),
  20. value: transactionName,
  21. },
  22. {
  23. key: '1',
  24. subject: t('Parent Span'),
  25. value: getSpanEvidenceValue(parentSpan),
  26. },
  27. {
  28. key: '2',
  29. subject: t('Repeating Span'),
  30. value: getSpanEvidenceValue(repeatingSpan),
  31. },
  32. ];
  33. return <KeyValueList data={data} />;
  34. }
  35. function getSpanEvidenceValue(span: RawSpanType | TraceContextSpanProxy) {
  36. if (!span.op && !span.description) {
  37. return t('(no value)');
  38. }
  39. if (!span.op && span.description) {
  40. return span.description;
  41. }
  42. if (span.op && !span.description) {
  43. return span.op;
  44. }
  45. return `${span.op} - ${span.description}`;
  46. }