Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-chairs-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperdx/common-utils": minor
---

Add support for visualizing histogram counts
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ docker-compose.prod.yml
.volumes

# NX
.nx/
.nx/

# webstorm
.idea
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,103 @@ exports[`renderChartConfig containing CTE clauses should render a ChSql CTE conf

exports[`renderChartConfig containing CTE clauses should render a chart config CTE configuration correctly 1`] = `"WITH Parts AS (SELECT _part, _part_offset FROM default.some_table WHERE ((FieldA = 'test')) ORDER BY rand() DESC LIMIT 1000) SELECT * FROM Parts WHERE ((FieldA = 'test') AND (indexHint((_part, _part_offset) IN (SELECT tuple(_part, _part_offset) FROM Parts)))) ORDER BY rand() DESC LIMIT 1000"`;

exports[`renderChartConfig histogram metric queries should generate a query with grouping and time bucketing 1`] = `
exports[`renderChartConfig histogram metric queries count should generate a count query with grouping and time bucketing 1`] = `
"WITH grouped_data AS (
SELECT
toStartOfInterval(toDateTime(TimeUnix), INTERVAL 2 minute) AS \`__hdx_time_bucket\`,
[ResourceAttributes['host']] as group,
toInt64(sum(Count)) as cumulative_count,
AggregationTemporality
FROM default.otel_metrics_histogram
WHERE (TimeUnix >= toStartOfInterval(fromUnixTimestamp64Milli(1739318400000), INTERVAL 2 minute) - INTERVAL 2 minute AND TimeUnix <= toStartOfInterval(fromUnixTimestamp64Milli(1765670400000), INTERVAL 2 minute) + INTERVAL 2 minute) AND ((MetricName = 'http.server.duration'))
GROUP BY group, \`__hdx_time_bucket\`, AggregationTemporality
),metrics AS (
SELECT
\`__hdx_time_bucket\`,
group,
CASE
WHEN AggregationTemporality = 1 THEN cumulative_count
WHEN AggregationTemporality = 2 THEN
GREATEST(0,
cumulative_count - COALESCE(
lag(cumulative_count) OVER (
PARTITION BY group, AggregationTemporality
ORDER BY \`__hdx_time_bucket\`
),
0
)
)
ELSE 0
END as \\"Value\\"
FROM grouped_data
) SELECT \`__hdx_time_bucket\`, group, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
`;

exports[`renderChartConfig histogram metric queries count should generate a count query without grouping but time bucketing 1`] = `
"WITH grouped_data AS (
SELECT
toStartOfInterval(toDateTime(TimeUnix), INTERVAL 2 minute) AS \`__hdx_time_bucket\`,

toInt64(sum(Count)) as cumulative_count,
AggregationTemporality
FROM default.otel_metrics_histogram
WHERE (TimeUnix >= toStartOfInterval(fromUnixTimestamp64Milli(1739318400000), INTERVAL 2 minute) - INTERVAL 2 minute AND TimeUnix <= toStartOfInterval(fromUnixTimestamp64Milli(1765670400000), INTERVAL 2 minute) + INTERVAL 2 minute) AND ((MetricName = 'http.server.duration'))
GROUP BY \`__hdx_time_bucket\`, AggregationTemporality
),metrics AS (
SELECT
\`__hdx_time_bucket\`,

CASE
WHEN AggregationTemporality = 1 THEN cumulative_count
WHEN AggregationTemporality = 2 THEN
GREATEST(0,
cumulative_count - COALESCE(
lag(cumulative_count) OVER (
PARTITION BY AggregationTemporality
ORDER BY \`__hdx_time_bucket\`
),
0
)
)
ELSE 0
END as \\"Value\\"
FROM grouped_data
) SELECT \`__hdx_time_bucket\`, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
`;

exports[`renderChartConfig histogram metric queries count should generate a count query without grouping or time bucketing 1`] = `
"WITH grouped_data AS (
SELECT
TimeUnix AS \`__hdx_time_bucket\`,

toInt64(sum(Count)) as cumulative_count,
AggregationTemporality
FROM default.otel_metrics_histogram
WHERE (TimeUnix >= fromUnixTimestamp64Milli(1739318400000) AND TimeUnix <= fromUnixTimestamp64Milli(1765670400000)) AND ((MetricName = 'http.server.duration'))
GROUP BY \`__hdx_time_bucket\`, AggregationTemporality
),metrics AS (
SELECT
\`__hdx_time_bucket\`,

CASE
WHEN AggregationTemporality = 1 THEN cumulative_count
WHEN AggregationTemporality = 2 THEN
GREATEST(0,
cumulative_count - COALESCE(
lag(cumulative_count) OVER (
PARTITION BY AggregationTemporality
ORDER BY \`__hdx_time_bucket\`
),
0
)
)
ELSE 0
END as \\"Value\\"
FROM grouped_data
) SELECT \`__hdx_time_bucket\`, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
`;

exports[`renderChartConfig histogram metric queries quantile should generate a query with grouping and time bucketing 1`] = `
"WITH source AS (
SELECT
MetricName,
Expand Down Expand Up @@ -102,7 +198,7 @@ exports[`renderChartConfig histogram metric queries should generate a query with
) SELECT \`__hdx_time_bucket\`, group, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
`;

exports[`renderChartConfig histogram metric queries should generate a query without grouping but time bucketing 1`] = `
exports[`renderChartConfig histogram metric queries quantile should generate a query without grouping but time bucketing 1`] = `
"WITH source AS (
SELECT
MetricName,
Expand Down Expand Up @@ -186,12 +282,12 @@ exports[`renderChartConfig histogram metric queries should generate a query with
) SELECT \`__hdx_time_bucket\`, \\"Value\\" FROM metrics WHERE (\`__hdx_time_bucket\` >= fromUnixTimestamp64Milli(1739318400000) AND \`__hdx_time_bucket\` <= fromUnixTimestamp64Milli(1765670400000)) LIMIT 10 SETTINGS short_circuit_function_evaluation = 'force_enable'"
`;

exports[`renderChartConfig histogram metric queries should generate a query without grouping or time bucketing 1`] = `
exports[`renderChartConfig histogram metric queries quantile should generate a query without grouping or time bucketing 1`] = `
"WITH source AS (
SELECT
MetricName,
ExplicitBounds,
TimeUnix AS \`__hdx_time_bucket\`
TimeUnix AS \`__hdx_time_bucket\`,

sumForEach(deltas) as rates
FROM (
Expand Down
Loading