spanIdCell.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import type {Location} from 'history';
  2. import Link from 'sentry/components/links/link';
  3. import {trackAnalytics} from 'sentry/utils/analytics';
  4. import {generateLinkToEventInTraceView} from 'sentry/utils/discover/urls';
  5. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {SPAN_ID_DISPLAY_LENGTH} from 'sentry/views/insights/http/settings';
  8. import type {ModuleName} from 'sentry/views/insights/types';
  9. interface Props {
  10. location: Location;
  11. moduleName: ModuleName;
  12. projectSlug: string;
  13. spanId: string;
  14. timestamp: string;
  15. traceId: string;
  16. transactionId: string;
  17. source?: string;
  18. }
  19. export function SpanIdCell({
  20. moduleName,
  21. projectSlug,
  22. traceId,
  23. transactionId,
  24. spanId,
  25. timestamp,
  26. source,
  27. location,
  28. }: Props) {
  29. const organization = useOrganization();
  30. const url = normalizeUrl(
  31. generateLinkToEventInTraceView({
  32. eventId: transactionId,
  33. projectSlug,
  34. traceSlug: traceId,
  35. timestamp,
  36. organization,
  37. location,
  38. spanId,
  39. source,
  40. })
  41. );
  42. return (
  43. <Link
  44. onClick={() =>
  45. trackAnalytics('performance_views.sample_spans.span_clicked', {
  46. organization,
  47. source: moduleName,
  48. })
  49. }
  50. to={url}
  51. >
  52. {spanId.slice(0, SPAN_ID_DISPLAY_LENGTH)}
  53. </Link>
  54. );
  55. }