From cc247847981fae562a4e6e6212d57bf9dda9e5ea Mon Sep 17 00:00:00 2001 From: George Gritsouk <989898+gggritso@users.noreply.github.com> Date: Wed, 22 Mar 2023 11:41:34 -0400 Subject: [PATCH 1/2] Add spec for span data URLs --- .../spanEvidenceKeyValueList.spec.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.spec.tsx b/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.spec.tsx index 2356b5cef30e69..eb77d48259fcce 100644 --- a/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.spec.tsx +++ b/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.spec.tsx @@ -385,10 +385,10 @@ describe('SpanEvidenceKeyValueList', () => { extractSpanURLString({ span_id: 'a', data: { - url: 'http://service.io', + url: 'http://service.io?id=2543', }, })?.toString() - ).toEqual('http://service.io/'); + ).toEqual('http://service.io/?id=2543'); }); it('Pulls out a relative URL if a base is provided', () => { @@ -405,6 +405,19 @@ describe('SpanEvidenceKeyValueList', () => { ).toEqual('http://service.io/item'); }); + it('Fetches the query string from the span data if available', () => { + expect( + extractSpanURLString({ + span_id: 'a', + description: 'GET http://service.io/item', + data: { + url: 'http://service.io/item', + 'http.query': 'id=153', + }, + })?.toString() + ).toEqual('http://service.io/item?id=153'); + }); + it('Falls back to span description if URL is faulty', () => { expect( extractSpanURLString({ From 29be9ff1ee5de6f2479681553e9bbf4b0a32fbe5 Mon Sep 17 00:00:00 2001 From: George Gritsouk <989898+gggritso@users.noreply.github.com> Date: Wed, 22 Mar 2023 11:48:52 -0400 Subject: [PATCH 2/2] Handle `http.query` in span data --- .../performance/spanEvidenceKeyValueList.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.tsx b/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.tsx index 48457dee17d852..e6d3ea1b27ab31 100644 --- a/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.tsx +++ b/static/app/components/events/interfaces/performance/spanEvidenceKeyValueList.tsx @@ -477,13 +477,23 @@ function formatChangingQueryParameters(spans: Span[], baseURL?: string): string[ return pairs; } +/** Parses the span data and pulls out the URL. Accounts for different SDKs and + different versions of SDKs formatting and parsing the URL contents + differently. Mirror of `get_url_from_span`. Ideally, this should not exist, + and instead it should use the data provided by the backend */ export const extractSpanURLString = (span: Span, baseURL?: string): URL | null => { let URLString; URLString = span?.data?.url; if (URLString) { try { - return new URL(span?.data?.url, baseURL); + let url = span?.data?.url ?? ''; + const query = span?.data?.['http.query']; + if (query) { + url += `?${query}`; + } + + return new URL(url, baseURL); } catch (e) { // Ignore error }