Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Profiling] Differential views based on same data show different values #182001

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this camelCased and TotalCount Pascal Cased?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the first version of the implementation. I'm slowly changing it.

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