Skip to content

Commit

Permalink
[Profiling] Differential views based on same data show different values
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Apr 29, 2024
1 parent 9035166 commit 61a5613
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function DifferentialTopNFunctionsView() {
baseValue={
state.data
? {
totalCount: state.data.TotalCount,
totalCount: state.data.selfCPU,
scaleFactor: isNormalizedByTime ? baselineTime : baseline,
totalAnnualCO2Kgs: state.data.totalAnnualCO2Kgs,
totalAnnualCostUSD: state.data.totalAnnualCostUSD,
Expand All @@ -183,7 +183,7 @@ export function DifferentialTopNFunctionsView() {
comparisonValue={
comparisonState.data
? {
totalCount: comparisonState.data.TotalCount,
totalCount: comparisonState.data.selfCPU,
scaleFactor: isNormalizedByTime ? comparisonTime : comparison,
totalAnnualCO2Kgs: comparisonState.data.totalAnnualCO2Kgs,
totalAnnualCostUSD: comparisonState.data.totalAnnualCostUSD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,23 @@ export function registerTopNFunctionsSearchRoute({
const useStacktracesAPI = await core.uiSettings.client.get<boolean>(
profilingFetchTopNFunctionsFromStacktraces
);
const totalSeconds = endSecs - startSecs;

const topNFunctions = useStacktracesAPI
? await profilingDataAccess.services.fetchFunctions({
core,
esClient,
startIndex,
endIndex,
totalSeconds: endSecs - startSecs,
totalSeconds,
query,
})
: await profilingDataAccess.services.fetchESFunctions({
core,
esClient,
query,
aggregationField: 'service.name',
totalSeconds,
});

return response.ok({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ export interface ProfilingESClient {
awsCostDiscountRate?: number;
azureCostDiscountRate?: number;
costPervCPUPerHour?: number;
durationSeconds: number;
}): Promise<ESTopNFunctions>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface FetchFunctionsParams {
query: QueryDslQueryContainer;
aggregationField?: AggregationField;
limit?: number;
totalSeconds: number;
}

const targetSampleSize = 20000; // minimum number of samples to get statistically sound results
Expand All @@ -46,6 +47,7 @@ export function createFetchESFunctions({ createProfilingEsClient }: RegisterServ
query,
aggregationField,
limit,
totalSeconds,
}: FetchFunctionsParams) => {
const [
co2PerKWH,
Expand Down Expand Up @@ -82,6 +84,7 @@ export function createFetchESFunctions({ createProfilingEsClient }: RegisterServ
awsCostDiscountRate: percentToFactor(awsCostDiscountRate),
costPervCPUPerHour,
azureCostDiscountRate: percentToFactor(azureCostDiscountRate),
durationSeconds: totalSeconds,
});

return transformToKibanaTopNFunction(esTopNFunctions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export function createProfilingEsClient({
azureCostDiscountRate,
sampleSize,
limit,
durationSeconds,
}) {
const controller = new AbortController();

Expand All @@ -187,6 +188,7 @@ export function createProfilingEsClient({
aws_cost_factor: awsCostDiscountRate,
cost_per_core_hour: costPervCPUPerHour,
azure_cost_factor: azureCostDiscountRate,
requested_duration: durationSeconds,
},
},
{
Expand Down

0 comments on commit 61a5613

Please sign in to comment.