Skip to content

Commit

Permalink
[APM] Add range query to service map trace walk (#86631) (#87122)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
dgieselaar and kibanamachine committed Jan 4, 2021
1 parent b4400b7 commit 57f6387
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
* 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 {
ConnectionNode,
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],
Expand All @@ -32,6 +38,7 @@ export async function fetchServicePathsFromTraceIds(
[TRACE_ID]: traceIds,
},
},
{ range: rangeFilter(start, end) },
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -79,7 +79,7 @@ export async function getServiceMapFromTraceIds({
serviceName,
environment,
}: {
setup: Setup;
setup: Setup & SetupTimeRange;
traceIds: string[];
serviceName?: string;
environment?: string;
Expand Down

0 comments on commit 57f6387

Please sign in to comment.