Skip to content

Commit 8464326

Browse files
committed
Review feedback
1 parent dab72cd commit 8464326

9 files changed

Lines changed: 133 additions & 88 deletions

File tree

x-pack/plugins/apm/public/components/app/service_overview/service_overview_dependencies_table/index.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ export function ServiceOverviewDependenciesTable({ serviceName }: Props) {
9393
return (
9494
<SparkPlotWithValueLabel
9595
color="euiColorVis1"
96-
series={latency.timeseries ?? undefined}
96+
series={latency.timeseries}
9797
valueLabel={asDuration(latency.value)}
9898
/>
9999
);
100100
},
101101
sortable: true,
102102
},
103103
{
104-
field: 'throughput_value',
104+
field: 'throughputValue',
105105
name: i18n.translate(
106106
'xpack.apm.serviceOverview.dependenciesTableColumnThroughput',
107107
{
@@ -114,36 +114,36 @@ export function ServiceOverviewDependenciesTable({ serviceName }: Props) {
114114
<SparkPlotWithValueLabel
115115
compact
116116
color="euiColorVis0"
117-
series={throughput.timeseries ?? undefined}
117+
series={throughput.timeseries}
118118
valueLabel={asTransactionRate(throughput.value)}
119119
/>
120120
);
121121
},
122122
sortable: true,
123123
},
124124
{
125-
field: 'error_rate_value',
125+
field: 'errorRateValue',
126126
name: i18n.translate(
127127
'xpack.apm.serviceOverview.dependenciesTableColumnErrorRate',
128128
{
129129
defaultMessage: 'Error rate',
130130
}
131131
),
132132
width: px(unit * 10),
133-
render: (_, { error_rate: errorRate }) => {
133+
render: (_, { errorRate }) => {
134134
return (
135135
<SparkPlotWithValueLabel
136136
compact
137137
color="euiColorVis7"
138-
series={errorRate.timeseries ?? undefined}
138+
series={errorRate.timeseries}
139139
valueLabel={asPercent(errorRate.value, 1)}
140140
/>
141141
);
142142
},
143143
sortable: true,
144144
},
145145
{
146-
field: 'impact_value',
146+
field: 'impactValue',
147147
name: i18n.translate(
148148
'xpack.apm.serviceOverview.dependenciesTableColumnImpact',
149149
{
@@ -186,10 +186,10 @@ export function ServiceOverviewDependenciesTable({ serviceName }: Props) {
186186
// need top-level sortable fields for the managed table
187187
const items = data.map((item) => ({
188188
...item,
189-
error_rate_value: item.error_rate.value,
190-
latency_value: item.latency.value,
191-
throughput_value: item.throughput.value,
192-
impact_value: item.impact,
189+
errorRateValue: item.errorRate.value,
190+
latencyValue: item.latency.value,
191+
throughputValue: item.throughput.value,
192+
impactValue: item.impact,
193193
}));
194194

195195
return (
@@ -235,7 +235,7 @@ export function ServiceOverviewDependenciesTable({ serviceName }: Props) {
235235
sorting={{
236236
sort: {
237237
direction: 'desc',
238-
field: 'impact_value',
238+
field: 'impactValue',
239239
},
240240
}}
241241
/>

x-pack/plugins/apm/public/components/shared/charts/spark_plot/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
2121

2222
interface Props {
2323
color: string;
24-
series?: Array<{ x: number; y: number | null }>;
24+
series?: Array<{ x: number; y: number | null }> | null;
2525
width: string;
2626
}
2727

x-pack/plugins/apm/public/components/shared/charts/spark_plot/spark_plot_with_value_label/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function SparkPlotWithValueLabel({
2929
compact,
3030
}: {
3131
color: Color;
32-
series?: Array<{ x: number; y: number | null }>;
32+
series?: Array<{ x: number; y: number | null }> | null;
3333
valueLabel: React.ReactNode;
3434
compact?: boolean;
3535
}) {

x-pack/plugins/apm/public/components/shared/truncate_with_tooltip/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import React from 'react';
99
import styled from 'styled-components';
1010
import { truncate } from '../../../style/variables';
1111

12+
const tooltipAnchorClassname = '_apm_truncate_tooltip_anchor_';
13+
1214
const TooltipWrapper = styled.div`
1315
width: 100%;
14-
.euiToolTipAnchor {
16+
.${tooltipAnchorClassname} {
1517
width: 100% !important;
1618
display: block !important;
1719
}
@@ -31,7 +33,11 @@ export function TruncateWithTooltip(props: Props) {
3133

3234
return (
3335
<TooltipWrapper>
34-
<EuiToolTip delay="long" content={text}>
36+
<EuiToolTip
37+
delay="long"
38+
content={text}
39+
anchorClassName={tooltipAnchorClassname}
40+
>
3541
<ContentWrapper>{content || text}</ContentWrapper>
3642
</EuiToolTip>
3743
</TooltipWrapper>

x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { LegacyAPICaller, Logger } from 'kibana/server';
8+
import { rangeFilter } from '../../../../common/utils/range_filter';
89
import { ESSearchResponse } from '../../../../../../typings/elasticsearch';
910
import { Annotation as ESAnnotation } from '../../../../../observability/common/annotations';
1011
import { ScopedAnnotationsClient } from '../../../../../observability/server';
@@ -34,12 +35,7 @@ export async function getStoredAnnotations({
3435
bool: {
3536
filter: [
3637
{
37-
range: {
38-
'@timestamp': {
39-
gte: setup.start,
40-
lt: setup.end,
41-
},
42-
},
38+
range: rangeFilter(setup.start, setup.end),
4339
},
4440
{ term: { 'annotation.type': 'deployment' } },
4541
{ term: { tags: 'apm' } },

x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_destination_map.ts

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,20 @@ import {
2020
import { rangeFilter } from '../../../../common/utils/range_filter';
2121
import { ProcessorEvent } from '../../../../common/processor_event';
2222
import { getEnvironmentUiFilterES } from '../../helpers/convert_ui_filters/get_environment_ui_filter_es';
23-
import { APMEventClient } from '../../helpers/create_es_client/create_apm_event_client';
2423
import { joinByKey } from '../../../../common/utils/join_by_key';
24+
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
2525

2626
export const getDestinationMap = async ({
27-
apmEventClient,
27+
setup,
2828
serviceName,
29-
start,
30-
end,
3129
environment,
3230
}: {
33-
apmEventClient: APMEventClient;
31+
setup: Setup & SetupTimeRange;
3432
serviceName: string;
35-
start: number;
36-
end: number;
3733
environment: string;
3834
}) => {
35+
const { start, end, apmEventClient } = setup;
36+
3937
const response = await apmEventClient.search({
4038
apm: {
4139
events: [ProcessorEvent.span],
@@ -62,6 +60,8 @@ export const getDestinationMap = async ({
6260
terms: { field: SPAN_DESTINATION_SERVICE_RESOURCE },
6361
},
6462
},
63+
// make sure we get samples for both successful
64+
// and failed calls
6565
{ [EVENT_OUTCOME]: { terms: { field: EVENT_OUTCOME } } },
6666
],
6767
},
@@ -110,6 +110,7 @@ export const getDestinationMap = async ({
110110
),
111111
},
112112
},
113+
{ range: rangeFilter(start, end) },
113114
],
114115
},
115116
},
@@ -133,13 +134,42 @@ export const getDestinationMap = async ({
133134
},
134135
}));
135136

137+
const joinedBySpanId = joinByKey(
138+
[...outgoingConnections, ...joinByKey(incomingConnections, 'service')],
139+
'id'
140+
);
141+
136142
const connections = joinByKey(
137-
joinByKey(
138-
[...outgoingConnections, ...joinByKey(incomingConnections, 'service')],
139-
'id'
140-
),
143+
joinedBySpanId,
141144
SPAN_DESTINATION_SERVICE_RESOURCE
142-
);
145+
).map((connection) => {
146+
const info = {
147+
span: {
148+
type: connection[SPAN_TYPE],
149+
subtype: connection[SPAN_SUBTYPE],
150+
destination: {
151+
service: {
152+
resource: connection[SPAN_DESTINATION_SERVICE_RESOURCE],
153+
},
154+
},
155+
},
156+
};
157+
158+
return {
159+
...info,
160+
...('service' in connection && connection.service
161+
? {
162+
service: {
163+
name: connection.service.name,
164+
environment: connection.service.environment,
165+
},
166+
agent: {
167+
name: connection.service.agentName,
168+
},
169+
}
170+
: {}),
171+
};
172+
});
143173

144174
// map span.destination.service.resource to an instrumented service (service.name, service.environment)
145175
// or an external service (span.type, span.subtype)

x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_metrics.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,23 @@ import {
1515
import { rangeFilter } from '../../../../common/utils/range_filter';
1616
import { ProcessorEvent } from '../../../../common/processor_event';
1717
import { getEnvironmentUiFilterES } from '../../helpers/convert_ui_filters/get_environment_ui_filter_es';
18-
import { APMEventClient } from '../../helpers/create_es_client/create_apm_event_client';
1918
import { getBucketSize } from '../../helpers/get_bucket_size';
2019
import { EventOutcome } from '../../../../common/event_outcome';
20+
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
2121

2222
export const getMetrics = async ({
23-
start,
24-
end,
25-
apmEventClient,
23+
setup,
2624
serviceName,
2725
environment,
2826
numBuckets,
2927
}: {
30-
start: number;
31-
end: number;
28+
setup: Setup & SetupTimeRange;
3229
serviceName: string;
33-
apmEventClient: APMEventClient;
3430
environment: string;
3531
numBuckets: number;
3632
}) => {
33+
const { start, end, apmEventClient } = setup;
34+
3735
const response = await apmEventClient.search({
3836
apm: {
3937
events: [ProcessorEvent.metric],

x-pack/plugins/apm/server/lib/services/get_service_dependencies/index.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import { ValuesType } from 'utility-types';
7+
import { isFiniteNumber } from '../../../../common/utils/is_finite_number';
78
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
89
import { joinByKey } from '../../../../common/utils/join_by_key';
9-
import {
10-
SPAN_DESTINATION_SERVICE_RESOURCE,
11-
SPAN_SUBTYPE,
12-
SPAN_TYPE,
13-
} from '../../../../common/elasticsearch_fieldnames';
1410
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
1511
import { getMetrics } from './get_metrics';
1612
import { getDestinationMap } from './get_destination_map';
@@ -25,7 +21,7 @@ export interface ServiceDependencyItem {
2521
value: number | null;
2622
timeseries: Array<{ x: number; y: number | null }>;
2723
};
28-
error_rate: {
24+
errorRate: {
2925
value: number | null;
3026
timeseries: Array<{ x: number; y: number | null }>;
3127
};
@@ -48,22 +44,18 @@ export async function getServiceDependencies({
4844
environment: string;
4945
numBuckets: number;
5046
}): Promise<ServiceDependencyItem[]> {
51-
const { start, end, apmEventClient } = setup;
47+
const { start, end } = setup;
5248

5349
const [allMetrics, destinationMap] = await Promise.all([
5450
getMetrics({
55-
start,
56-
end,
57-
apmEventClient,
51+
setup,
5852
serviceName,
5953
environment,
6054
numBuckets,
6155
}),
6256
getDestinationMap({
63-
apmEventClient,
57+
setup,
6458
serviceName,
65-
start,
66-
end,
6759
environment,
6860
}),
6961
]);
@@ -73,12 +65,18 @@ export async function getServiceDependencies({
7365

7466
const destination = destinationMap[spanDestination];
7567

76-
return {
77-
destination: destination
78-
? destination
79-
: {
80-
[SPAN_DESTINATION_SERVICE_RESOURCE]: metricItem.key,
68+
const defaultInfo = {
69+
span: {
70+
destination: {
71+
service: {
72+
resource: metricItem.key,
8173
},
74+
},
75+
},
76+
};
77+
78+
return {
79+
destination: destination ? destination : defaultInfo,
8280
metrics: [metricItem],
8381
};
8482
}, []);
@@ -150,7 +148,7 @@ export async function getServiceDependencies({
150148
y: point.count > 0 ? point.count / deltaAsMinutes : null,
151149
})),
152150
},
153-
error_rate: {
151+
errorRate: {
154152
value:
155153
mergedMetrics.value.count > 0
156154
? (mergedMetrics.value.error_count ?? 0) /
@@ -165,28 +163,30 @@ export async function getServiceDependencies({
165163

166164
if ('service' in destination) {
167165
return {
168-
name: destination.service!.name,
169-
serviceName: destination.service!.name,
170-
environment: destination.service!.environment,
171-
agentName: destination.service!.agentName,
166+
name: destination.service.name,
167+
serviceName: destination.service.name,
168+
environment: destination.service.environment,
169+
agentName: destination.agent.name,
172170
...destMetrics,
173171
};
174172
}
175173

176174
return {
177-
name: destination[SPAN_DESTINATION_SERVICE_RESOURCE],
178-
spanType:
179-
'span.type' in destination ? destination[SPAN_TYPE] : undefined,
180-
spanSubtype:
181-
'span.subtype' in destination ? destination[SPAN_SUBTYPE] : undefined,
175+
name: destination.span.destination.service.resource!,
176+
...('span' in destination && 'type' in destination.span
177+
? {
178+
spanType: destination.span.type,
179+
spanSubtype: destination.span.subtype,
180+
}
181+
: {}),
182182
...destMetrics,
183183
};
184184
}
185185
);
186186

187187
const latencySums = metricsByResolvedAddress
188188
.map((metrics) => metrics.latency.value)
189-
.filter((n) => n !== null) as number[];
189+
.filter(isFiniteNumber);
190190

191191
const minLatencySum = Math.min(...latencySums);
192192
const maxLatencySum = Math.max(...latencySums);

0 commit comments

Comments
 (0)