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

Rebase new commits from opendistro repo #5

Merged
merged 6 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions public/components/dashboard/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,19 @@ export function Dashboard(props: DashboardProps) {
if (tableItems.length === 0 || Object.keys(percentileMap).length === 0) return;
for (let i = 0; i < props.filters.length; i++) {
if (props.filters[i].custom) {
const newFilter = JSON.parse(
JSON.stringify(props.filters[i]).replace(
/{"range":{"durationInNanos":{"[gl]te?"/g,
`{"range":{"durationInNanos":{"${condition}"`
)
const newFilter = JSON.parse(JSON.stringify(props.filters[i]));
newFilter.custom.query.bool.should.forEach((should) =>
should.bool.must.forEach((must) => {
const range = must?.range?.['traceGroup.durationInNanos'];
if (range) {
const duration = range.lt || range.lte || range.gt || range.gte;
if (duration || duration === 0) {
must.range['traceGroup.durationInNanos'] = {
[condition]: duration,
};
}
}
})
);
newFilter.value = condition === 'gte' ? '>= 95th' : '< 95th';
const newFilters = [...props.filters, ...additionalFilters];
Expand Down
8 changes: 7 additions & 1 deletion public/requests/queries/traces_queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ export const getTracesQuery = (traceId = null, sort?: PropertySort) => {
latency: {
max: {
script: {
source: "Math.round(doc['traceGroup.durationInNanos'].value / 10000) / 100.0",
source: `
if (doc.containsKey('traceGroup.durationInNanos') && !doc['traceGroup.durationInNanos'].empty) {
return Math.round(doc['traceGroup.durationInNanos'].value / 10000) / 100.0
}

return 0
`,
lang: 'painless',
},
},
Expand Down
42 changes: 23 additions & 19 deletions public/requests/services_request_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ export const handleServicesRequest = async (
const serviceObject: ServiceObject = await handleServiceMapRequest(http, DSL);
if (setServiceMap) setServiceMap(serviceObject);
return Promise.all(
response.aggregations.service.buckets.map((bucket) => {
const connectedServices = [
...serviceObject[bucket.key].targetServices,
...serviceObject[bucket.key].destServices,
];
return {
name: bucket.key,
average_latency: serviceObject[bucket.key].latency,
error_rate: serviceObject[bucket.key].error_rate,
throughput: serviceObject[bucket.key].throughput,
traces: bucket.trace_count.value,
connected_services: connectedServices.join(', '),
number_of_connected_services: connectedServices.length,
};
})
response.aggregations.service.buckets
.filter((bucket) => serviceObject[bucket.key])
.map((bucket) => {
const connectedServices = [
...serviceObject[bucket.key].targetServices,
...serviceObject[bucket.key].destServices,
];
return {
name: bucket.key,
average_latency: serviceObject[bucket.key].latency,
error_rate: serviceObject[bucket.key].error_rate,
throughput: serviceObject[bucket.key].throughput,
traces: bucket.trace_count.value,
connected_services: connectedServices.join(', '),
number_of_connected_services: connectedServices.length,
};
})
);
})
.then((newItems) => {
Expand Down Expand Up @@ -111,10 +113,12 @@ export const handleServiceMapRequest = async (http, DSL, items?, setItems?, curr
bucket.resource.buckets.map((resource) => {
resource.domain.buckets.map((domain) => {
const targetService = targets[resource.key + ':' + domain.key];
if (map[bucket.key].targetServices.indexOf(targetService) === -1)
map[bucket.key].targetServices.push(targetService);
if (map[targetService].destServices.indexOf(bucket.key) === -1)
map[targetService].destServices.push(bucket.key);
if (targetService) {
if (map[bucket.key].targetServices.indexOf(targetService) === -1)
map[bucket.key].targetServices.push(targetService);
if (map[targetService].destServices.indexOf(bucket.key) === -1)
map[targetService].destServices.push(bucket.key);
}
});
});
})
Expand Down