spanDescription.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import styled from '@emotion/styled';
  2. import {FormattedCode} from 'sentry/views/starfish/components/formattedCode';
  3. import {highlightSql} from 'sentry/views/starfish/utils/highlightSql';
  4. type SpanMeta = {
  5. 'span.action': string;
  6. 'span.description': string;
  7. 'span.domain': string;
  8. 'span.op': string;
  9. };
  10. export function SpanDescription({spanMeta}: {spanMeta: SpanMeta}) {
  11. if (spanMeta['span.op'].startsWith('db')) {
  12. return <DatabaseSpanDescription spanMeta={spanMeta} />;
  13. }
  14. return <DescriptionWrapper>{spanMeta['span.description']}</DescriptionWrapper>;
  15. }
  16. function DatabaseSpanDescription({spanMeta}: {spanMeta: SpanMeta}) {
  17. return (
  18. <CodeWrapper>
  19. <FormattedCode>
  20. {highlightSql(spanMeta['span.description'] || '', {
  21. action: spanMeta['span.action'] || '',
  22. domain: spanMeta['span.domain'] || '',
  23. })}
  24. </FormattedCode>
  25. </CodeWrapper>
  26. );
  27. }
  28. const CodeWrapper = styled('div')`
  29. font-size: ${p => p.theme.fontSizeMedium};
  30. `;
  31. const DescriptionWrapper = styled('div')`
  32. word-break: break-word;
  33. `;