Skip to content

Commit

Permalink
Rebase new commits from opendistro repo (#5)
Browse files Browse the repository at this point in the history
* Renamed 'traceGroup' to 'traceGroupFields' to support backwards compatibility.

Signed-off-by: Jeff Wright <74204404+wrijeff@users.noreply.github.com>

* Revert "Renamed 'traceGroup' to 'traceGroupFields' to support backwards compatibility."

This reverts commit 0c09b5fa3c44ef0957884b0ec3cd1cf6e216ef5d.

* Merge pull request #33 from wrijeff/main

Renamed 'traceGroup' to 'traceGroupFields' to support backwards compa…

* Merge pull request #34 from wrijeff/main

Fixed getTracesQuery, was returning 0 unexpectedly.

* Add null check for service map, fix percentile filter (#35)

* Add null check for service map query

* Loop through filters when switching percentile filters

* Add check before changing percentile filter

* Revert to traceGroup from traceGroupFields (#37)

* Revert "Add null check for service map, fix percentile filter (#35)"

This reverts commit 126c3dbd7e25edd33f6b26aa842ae0fc4167e73a.

* Revert "Merge pull request #34 from wrijeff/main"

This reverts commit 66a9dcc9bddd7c8dbb6955e1472448e4ed9bd222, reversing
changes made to 1cfd7b00227be5bd9cc2d2213297e66f0a213dc8.

* Revert "Merge pull request #33 from wrijeff/main"

This reverts commit 1cfd7b00227be5bd9cc2d2213297e66f0a213dc8, reversing
changes made to e9141628e96c2a80cd3123daf320275b51aad243.

* pick: Merge pull request #34 from wrijeff/main

Fixed getTracesQuery, was returning 0 unexpectedly.

* Add null check for service map, fix percentile filter (#35)

* Add null check for service map query

* Loop through filters when switching percentile filters

* Add check before changing percentile filter

* Change to traceGroup

Co-authored-by: Jeff Wright <74204404+wrijeff@users.noreply.github.com>

Co-authored-by: Jeff Wright <74204404+wrijeff@users.noreply.github.com>
  • Loading branch information
joshuali925 and wrijeff authored Apr 23, 2021
1 parent 9c78938 commit 55e2e1f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
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

0 comments on commit 55e2e1f

Please sign in to comment.