Skip to content

Commit

Permalink
histogram response time data (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Feb 11, 2023
1 parent 41a458e commit 6882853
Show file tree
Hide file tree
Showing 7 changed files with 581 additions and 494 deletions.
9 changes: 9 additions & 0 deletions migrations/1674942200154_histogram-plot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports.up = (pgm) => {
pgm.addColumn({ schema: "jtl", name: "charts" }, {
histogram_plot_data: {
type: "jsonb",
"default": null,
notNull: false,
},
})
}
2 changes: 2 additions & 0 deletions src/server/controllers/item/get-item-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe("getItemController", () => {
(db.one as any).mockResolvedValueOnce({
plot_data: {},
extra_plot_data: {},
histogram_plot_data: {},
note: "my note",
environment: "environment",
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand All @@ -49,6 +50,7 @@ describe("getItemController", () => {
baseId: null,
environment: "environment",
extraPlotData: {},
histogramPlotData: {},
hostname: null,
isBase: false,
monitoring: {
Expand Down
2 changes: 2 additions & 0 deletions src/server/controllers/item/get-item-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const getItemController = async (req: IGetUserAuthInfoRequest, res: Respo
const {
plot_data: plot,
extra_plot_data: extraPlotData,
histogram_plot_data: histogramPlotData,
note,
environment,
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -40,6 +41,7 @@ export const getItemController = async (req: IGetUserAuthInfoRequest, res: Respo
overview, sutOverview, statistics, status, apdexSettings,
plot, extraPlotData, note, environment, hostname, reportStatus, thresholds, analysisEnabled,
baseId: base_id, isBase: base_id === itemId, zeroErrorToleranceEnabled, topMetricsSettings,
histogramPlotData,
name,
monitoring: {
cpu: {
Expand Down
29 changes: 23 additions & 6 deletions src/server/controllers/item/shared/item-data-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@ import { db } from "../../../../db/db"
import { logger } from "../../../../logger"
import {
prepareDataForSavingToDb,
prepareChartDataForSaving,
prepareChartDataForSaving, prepareHistogramDataForSaving,
} from "../../../data-stats/prepare-data"
import { chartQueryOptionInterval } from "../../../data-stats/helper/duration"
import {
saveThresholdsResult, saveItemStats, savePlotData, updateItem,
aggOverviewQuery, aggLabelQuery, chartOverviewQuery,
charLabelQuery, sutOverviewQuery, distributedThreadsQuery, responseCodeDistribution, responseMessageFailures,
deleteSamples, calculateApdexValues, updateItemApdexSettings, chartOverviewStatusCodesQuery,
saveThresholdsResult,
saveItemStats,
savePlotData,
updateItem,
aggOverviewQuery,
aggLabelQuery,
chartOverviewQuery,
charLabelQuery,
sutOverviewQuery,
distributedThreadsQuery,
responseCodeDistribution,
responseMessageFailures,
deleteSamples,
calculateApdexValues,
updateItemApdexSettings,
chartOverviewStatusCodesQuery,
responseTimePerLabelHistogram,
} from "../../../queries/items"
import { ReportStatus } from "../../../queries/items.model"
import { getScenarioSettings, currentScenarioMetrics } from "../../../queries/scenario"
Expand All @@ -29,9 +42,11 @@ export const itemDataProcessing = async ({ projectName, scenarioName, itemId })
const aggOverview = await db.one(aggOverviewQuery(itemId))
const aggLabel = await db.many(aggLabelQuery(itemId))
const statusCodeDistribution = await db.manyOrNone(responseCodeDistribution(itemId))
const responseTimePerLabelDistribution = await db.manyOrNone(responseTimePerLabelHistogram(itemId))
const responseFailures = await db.manyOrNone(responseMessageFailures(itemId))
const scenarioSettings = await db.one(getScenarioSettings(projectName, scenarioName))

console.log({ responseTimePerLabelDistribution })

if (aggOverview.number_of_sut_hostnames > 1) {
sutMetrics = await db.many(sutOverviewQuery(itemId))
Expand All @@ -55,6 +70,7 @@ export const itemDataProcessing = async ({ projectName, scenarioName, itemId })
labelStats, sutOverview,
} = prepareDataForSavingToDb(aggOverview, aggLabel, sutMetrics,
statusCodeDistribution, responseFailures, apdex)
const responseTimeHistogram = prepareHistogramDataForSaving(responseTimePerLabelDistribution)
const defaultInterval = chartQueryOptionInterval(duration)
let chartData
const extraChartData = []
Expand Down Expand Up @@ -112,7 +128,8 @@ export const itemDataProcessing = async ({ projectName, scenarioName, itemId })

await db.tx(async t => {
await t.none(saveItemStats(itemId, JSON.stringify(labelStats), overview, JSON.stringify(sutOverview)))
await t.none(savePlotData(itemId, JSON.stringify(chartData), JSON.stringify(extraChartData)))
await t.none(savePlotData(itemId, JSON.stringify(chartData), JSON.stringify(extraChartData),
JSON.stringify(responseTimeHistogram)))
await t.none(updateItem(itemId, ReportStatus.Ready, overview.startDate))
})

Expand Down
Loading

0 comments on commit 6882853

Please sign in to comment.