spanIdCell.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 {useDomainViewFilters} from 'sentry/views/insights/pages/useFilters';
  9. import type {ModuleName} from 'sentry/views/insights/types';
  10. interface Props {
  11. location: Location;
  12. moduleName: ModuleName;
  13. projectSlug: string;
  14. spanId: string;
  15. timestamp: string;
  16. traceId: string;
  17. transactionId: string;
  18. source?: string;
  19. }
  20. export function SpanIdCell({
  21. moduleName,
  22. projectSlug,
  23. traceId,
  24. transactionId,
  25. spanId,
  26. timestamp,
  27. source,
  28. location,
  29. }: Props) {
  30. const organization = useOrganization();
  31. const domainViewFilters = useDomainViewFilters();
  32. const url = normalizeUrl(
  33. generateLinkToEventInTraceView({
  34. eventId: transactionId,
  35. projectSlug,
  36. traceSlug: traceId,
  37. timestamp,
  38. organization,
  39. location,
  40. spanId,
  41. source,
  42. view: domainViewFilters.view,
  43. })
  44. );
  45. return (
  46. <Link
  47. onClick={() =>
  48. trackAnalytics('performance_views.sample_spans.span_clicked', {
  49. organization,
  50. source: moduleName,
  51. })
  52. }
  53. to={url}
  54. >
  55. {spanId.slice(0, SPAN_ID_DISPLAY_LENGTH)}
  56. </Link>
  57. );
  58. }