[APM] Add range query to service map trace walk (#86631)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Dario Gieselaar 2021-01-04 11:37:10 +01:00 committed by GitHub
parent 8d2e51d8fa
commit 1934d34ee7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { rangeFilter } from '../../../common/utils/range_filter';
import { ProcessorEvent } from '../../../common/processor_event';
import { TRACE_ID } from '../../../common/elasticsearch_fieldnames';
import {
@ -10,14 +11,19 @@ import {
ExternalConnectionNode,
ServiceConnectionNode,
} from '../../../common/service_map';
import { Setup } from '../helpers/setup_request';
import { Setup, SetupTimeRange } from '../helpers/setup_request';
export async function fetchServicePathsFromTraceIds(
setup: Setup,
setup: Setup & SetupTimeRange,
traceIds: string[]
) {
const { apmEventClient } = setup;
// make sure there's a range so ES can skip shards
const dayInMs = 24 * 60 * 60 * 1000;
const start = setup.start - dayInMs;
const end = setup.end + dayInMs;
const serviceMapParams = {
apm: {
events: [ProcessorEvent.span, ProcessorEvent.transaction],
@ -32,6 +38,7 @@ export async function fetchServicePathsFromTraceIds(
[TRACE_ID]: traceIds,
},
},
{ range: rangeFilter(start, end) },
],
},
},

View file

@ -10,7 +10,7 @@ import {
SERVICE_NAME,
} from '../../../common/elasticsearch_fieldnames';
import { Connection, ConnectionNode } from '../../../common/service_map';
import { Setup } from '../helpers/setup_request';
import { Setup, SetupTimeRange } from '../helpers/setup_request';
import { fetchServicePathsFromTraceIds } from './fetch_service_paths_from_trace_ids';
export function getConnections({
@ -79,7 +79,7 @@ export async function getServiceMapFromTraceIds({
serviceName,
environment,
}: {
setup: Setup;
setup: Setup & SetupTimeRange;
traceIds: string[];
serviceName?: string;
environment?: string;