Skip to content

Commit

Permalink
Add url path to client http spans, parallelize where statement genera…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
MikeShi42 committed Jan 8, 2024
1 parent 63ad5a8 commit e4204c7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
55 changes: 40 additions & 15 deletions packages/api/src/clickhouse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1538,19 +1538,21 @@ export const getSpanPerformanceChart = async ({
}) => {
const tableName = getLogStreamTableName(tableVersion, teamId);

const parentSpanWhereCondition = await buildSearchQueryWhereCondition({
endTime,
propertyTypeMappingsModel,
query: parentSpanWhere,
startTime,
});

const childrenSpanWhereCondition = await buildSearchQueryWhereCondition({
endTime,
propertyTypeMappingsModel,
query: childrenSpanWhere,
startTime,
});
const [parentSpanWhereCondition, childrenSpanWhereCondition] =
await Promise.all([
buildSearchQueryWhereCondition({
endTime,
propertyTypeMappingsModel,
query: parentSpanWhere,
startTime,
}),
buildSearchQueryWhereCondition({
endTime,
propertyTypeMappingsModel,
query: childrenSpanWhere,
startTime,
}),
]);

// This needs to return in a format that matches multi-series charts
const query = SqlString.format(
Expand All @@ -1561,7 +1563,30 @@ FROM ??
WHERE (?)
)
SELECT
[span_name] as "group",
[
span_name,
if(
span_name = 'HTTP DELETE'
OR span_name = 'DELETE'
OR span_name = 'HTTP GET'
OR span_name = 'GET'
OR span_name = 'HTTP HEAD'
OR span_name = 'HEAD'
OR span_name = 'HTTP OPTIONS'
OR span_name = 'OPTIONS'
OR span_name = 'HTTP PATCH'
OR span_name = 'PATCH'
OR span_name = 'HTTP POST'
OR span_name = 'POST'
OR span_name = 'HTTP PUT'
OR span_name = 'PUT',
COALESCE(
NULLIF(_string_attributes['server.address'], ''),
NULLIF(_string_attributes['http.host'], '')
),
''
)
] as "group",
sum(_duration) as "series_0.data",
count(*) as "series_1.data",
avg(_duration) as "series_2.data",
Expand All @@ -1574,7 +1599,7 @@ FROM ??
WHERE
(?)
AND trace_id IN (SELECT trace_id FROM trace_ids)
GROUP BY span_name
GROUP BY "group"
ORDER BY "series_0.data" DESC
LIMIT ?`,
[
Expand Down
8 changes: 6 additions & 2 deletions packages/app/src/HDXListBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function ListBar({
const value = row['series_0.data'];
const percentOfMax = (value / maxValue) * 100;
const percentOfTotal = (value / totalValue) * 100;
const group = `${row.group}`;
const group = `${row.group.join(' ').trim()}`;

const hoverCardContent =
columns.length > 0 ? (
Expand Down Expand Up @@ -207,8 +207,12 @@ export const HDXSpanPerformanceBarChart = memo(
}) ?? [];

const getRowSearchLink = (row: Row) => {
const urlQ =
row.group.length > 1 && row.group[1]
? ` (http.host:"${row.group[1]}" OR server.address:"${row.group[1]}")`
: '';
const qparams = new URLSearchParams({
q: `${childrenSpanWhere} span_name:"${row.group[0]}"`.trim(),
q: `${childrenSpanWhere} span_name:"${row.group[0]}"${urlQ}`.trim(),
from: `${dateRange[0].getTime()}`,
to: `${dateRange[1].getTime()}`,
});
Expand Down

0 comments on commit e4204c7

Please sign in to comment.