spanIdCell.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import Link from 'sentry/components/links/link';
  2. import EventView from 'sentry/utils/discover/eventView';
  3. import {
  4. generateEventSlug,
  5. generateLinkToEventInTraceView,
  6. } from 'sentry/utils/discover/urls';
  7. import {useLocation} from 'sentry/utils/useLocation';
  8. import useOrganization from 'sentry/utils/useOrganization';
  9. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  10. import {SPAN_ID_DISPLAY_LENGTH} from 'sentry/views/performance/http/settings';
  11. interface Props {
  12. projectSlug: string;
  13. spanId: string;
  14. timestamp: string;
  15. traceId: string;
  16. transactionId: string;
  17. }
  18. export function SpanIdCell({
  19. projectSlug,
  20. traceId,
  21. transactionId,
  22. spanId,
  23. timestamp,
  24. }: Props) {
  25. const organization = useOrganization();
  26. const location = useLocation();
  27. const url = normalizeUrl(
  28. generateLinkToEventInTraceView({
  29. eventSlug: generateEventSlug({
  30. id: transactionId,
  31. project: projectSlug,
  32. }),
  33. organization,
  34. location,
  35. eventView: EventView.fromLocation(location),
  36. dataRow: {
  37. id: transactionId,
  38. trace: traceId,
  39. timestamp,
  40. },
  41. spanId,
  42. })
  43. );
  44. return <Link to={url}>{spanId.slice(0, SPAN_ID_DISPLAY_LENGTH)}</Link>;
  45. }