Skip to content

Commit

Permalink
remove application launch time
Browse files Browse the repository at this point in the history
  • Loading branch information
MiriamAparicio committed Apr 21, 2023
1 parent 072ab64 commit f84d981
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function MobileTransactionOverview() {

const { start, end } = useTimeRange({ rangeFrom, rangeTo });

const { transactionType, agentName } = useApmServiceContext();
const { transactionType } = useApmServiceContext();

const history = useHistory();

Expand Down Expand Up @@ -90,7 +90,6 @@ export function MobileTransactionOverview() {
<EuiSpacer size="s" />
<EuiPanel hasBorder={true}>
<TransactionOverviewTabs
agentName={agentName}
environment={environment}
kuery={kueryWithMobileFilters}
start={start}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { SERVICE_VERSION } from '../../../../../../common/es_fields/apm';
import { useMobileStatisticsFetcher } from './use_mobile_statistics_fetcher';

function AppVersionTab({
agentName,
environment,
kuery,
start,
Expand All @@ -39,7 +38,6 @@ function AppVersionTab({

return (
<StatsList
agentName={agentName}
isLoading={isPending(mainStatisticsStatus)}
mainStatistics={mainStatistics}
detailedStatisticsLoading={isPending(detailedStatisticsStatus)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useMobileStatisticsFetcher } from './use_mobile_statistics_fetcher';
import { DEVICE_MODEL_IDENTIFIER } from '../../../../../../common/es_fields/apm';

function DevicesTab({
agentName,
environment,
kuery,
start,
Expand All @@ -39,7 +38,6 @@ function DevicesTab({

return (
<StatsList
agentName={agentName}
isLoading={isPending(mainStatisticsStatus)}
mainStatistics={mainStatistics}
detailedStatisticsLoading={isPending(detailedStatisticsStatus)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useMobileStatisticsFetcher } from './use_mobile_statistics_fetcher';
import { HOST_OS_VERSION } from '../../../../../../common/es_fields/apm';

function OSVersionTab({
agentName,
environment,
kuery,
start,
Expand All @@ -39,7 +38,6 @@ function OSVersionTab({

return (
<StatsList
agentName={agentName}
isLoading={isPending(mainStatisticsStatus)}
mainStatistics={mainStatistics}
detailedStatisticsLoading={isPending(detailedStatisticsStatus)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ type MobileDetailedStatisticsByField =

export function getColumns({
agentName,
showAppLaunchTimeColumn,
detailedStatisticsLoading,
detailedStatistics,
comparisonEnabled,
offset,
}: {
agentName?: string;
showAppLaunchTimeColumn: boolean;
detailedStatisticsLoading: boolean;
detailedStatistics: MobileDetailedStatisticsByField;
comparisonEnabled?: boolean;
Expand Down Expand Up @@ -128,28 +126,6 @@ export function getColumns({
);
},
},
// launch time
...(agentName && showAppLaunchTimeColumn
? [
{
field: 'appLaunchTime',
name: i18n.translate(
'xpack.apm.mobile.transactions.overview.table.appLaunchTime',
{
defaultMessage: 'App launch time',
}
),
align: RIGHT_ALIGNMENT,
render: (_, { appLaunchTime }) => {
return (
<EuiText size="s" textAlign="right">
{asMillisecondDuration(appLaunchTime)}
</EuiText>
);
},
} as ITableColumn<MobileMainStatisticsByFieldItem>,
]
: []),
// crash rate
{
field: 'crashRate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { i18n } from '@kbn/i18n';
import { ManagedTable } from '../../../../../shared/managed_table';
import { APIReturnType } from '../../../../../../services/rest/create_call_apm_api';
import { getColumns } from './get_columns';
import { isIosAgentName } from '../../../../../../../common/agent_name';

type MobileMainStatisticsByField =
APIReturnType<'GET /internal/apm/mobile-services/{serviceName}/main_statistics'>['mainStatistics'];
Expand All @@ -19,7 +18,6 @@ type MobileDetailedStatisticsByField =
APIReturnType<'GET /internal/apm/mobile-services/{serviceName}/detailed_statistics'>;

interface Props {
agentName?: string;
isLoading: boolean;
mainStatistics: MobileMainStatisticsByField;
detailedStatisticsLoading: boolean;
Expand All @@ -28,7 +26,6 @@ interface Props {
offset?: string;
}
export function StatsList({
agentName,
isLoading,
mainStatistics,
detailedStatisticsLoading,
Expand All @@ -38,15 +35,12 @@ export function StatsList({
}: Props) {
const columns = useMemo(() => {
return getColumns({
agentName,
showAppLaunchTimeColumn: !isIosAgentName(agentName),
detailedStatisticsLoading,
detailedStatistics,
comparisonEnabled,
offset,
});
}, [
agentName,
detailedStatisticsLoading,
detailedStatistics,
comparisonEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {
rangeQuery,
} from '@kbn/observability-plugin/server';
import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { merge } from 'lodash';
import {
APP_LAUNCH_TIME,
SERVICE_NAME,
SESSION_ID,
TRANSACTION_DURATION,
Expand Down Expand Up @@ -42,7 +40,6 @@ export interface MobileMainStatisticsResponse {
latency: number | null;
throughput: number;
crashRate: number;
appLaunchTime?: number;
}>;
}

Expand All @@ -55,137 +52,73 @@ export async function getMobileMainStatisticsByField({
end,
field,
}: Props) {
async function getMobileTransactionEventStatistics() {
const response = await apmEventClient.search(
`get_mobile_transaction_events_main_statistics_by_field`,
{
apm: {
events: [ProcessorEvent.transaction, ProcessorEvent.error],
const response = await apmEventClient.search(
`get_mobile_transaction_events_main_statistics_by_field`,
{
apm: {
events: [ProcessorEvent.transaction, ProcessorEvent.error],
},
body: {
track_total_hits: false,
size: 0,
query: {
bool: {
filter: [
...termQuery(SERVICE_NAME, serviceName),
...rangeQuery(start, end),
...environmentQuery(environment),
...kqlQuery(kuery),
],
},
},
body: {
track_total_hits: false,
size: 0,
query: {
bool: {
filter: [
...termQuery(SERVICE_NAME, serviceName),
...rangeQuery(start, end),
...environmentQuery(environment),
...kqlQuery(kuery),
],
_source: [AGENT_NAME],
aggs: {
main_statistics: {
terms: {
field,
size: 1000,
},
},
_source: [AGENT_NAME],
aggs: {
main_statistics: {
terms: {
field,
size: 1000,
},
aggs: {
latency: {
avg: {
field: TRANSACTION_DURATION,
},
},
sessions: {
cardinality: {
field: SESSION_ID,
},
},
crashes: {
filter: {
term: {
[ERROR_TYPE]: 'crash',
},
},
aggs: {
latency: {
avg: {
field: TRANSACTION_DURATION,
},
},
},
},
},
}
);

return (
response.aggregations?.main_statistics.buckets.map((bucket) => {
return {
name: bucket.key,
latency: getLatencyValue({
latencyAggregationType: LatencyAggregationType.avg,
aggregation: bucket.latency,
}),
throughput: calculateThroughputWithRange({
start,
end,
value: bucket.doc_count,
}),
crashRate: bucket.crashes.doc_count / bucket.sessions.value,
};
}) ?? []
);
}

async function getMobileTransactionMetricsStatistics() {
const response = await apmEventClient.search(
`get_mobile_transaction_metrics_main_statistics_by_field`,
{
apm: {
events: [ProcessorEvent.metric],
},
body: {
track_total_hits: false,
size: 0,
query: {
bool: {
filter: [
...termQuery(SERVICE_NAME, serviceName),
...rangeQuery(start, end),
...environmentQuery(environment),
...kqlQuery(kuery),
],
},
},
_source: [AGENT_NAME],
aggs: {
main_statistics: {
terms: {
field,
size: 1000,
sessions: {
cardinality: {
field: SESSION_ID,
},
},
aggs: {
app_launch_time: {
sum: {
field: APP_LAUNCH_TIME,
crashes: {
filter: {
term: {
[ERROR_TYPE]: 'crash',
},
},
},
},
},
},
}
);

return (
response.aggregations?.main_statistics.buckets.map((bucket) => {
return {
name: bucket.key,
appLaunchTime: bucket.app_launch_time.value ?? 0,
};
}) ?? []
);
}

const [transactioEventStatistics, transactionMetricStatistics] =
await Promise.all([
getMobileTransactionEventStatistics(),
getMobileTransactionMetricsStatistics(),
]);

const mainStatistics = merge(
transactioEventStatistics,
transactionMetricStatistics
},
}
);

const mainStatistics =
response.aggregations?.main_statistics.buckets.map((bucket) => {
return {
name: bucket.key,
latency: getLatencyValue({
latencyAggregationType: LatencyAggregationType.avg,
aggregation: bucket.latency,
}),
throughput: calculateThroughputWithRange({
start,
end,
value: bucket.doc_count,
}),
crashRate: bucket.crashes.doc_count / bucket.sessions.value,
};
}) ?? [];

return { mainStatistics };
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,6 @@ export async function generateMobileData({
galaxy10.startNewSession();
galaxy7.startNewSession();
huaweiP2.startNewSession();
galaxy10
.appMetrics({
'application.launch.time': 1000,
})
.timestamp(timestamp);
galaxy7
.appMetrics({
'application.launch.time': 1000,
})
.timestamp(timestamp);
huaweiP2
.appMetrics({
'application.launch.time': 1000,
})
.timestamp(timestamp);
pixel7.startNewSession();
pixel7Pro.startNewSession();
pixel8.startNewSession();
Expand Down
Loading

0 comments on commit f84d981

Please sign in to comment.