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

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

Merged
merged 5 commits into from
Jan 4, 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
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