Skip to content

Commit

Permalink
[APM] Backport #106837, #106995, #107367 (#107518)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar authored Aug 3, 2021
1 parent d8c963e commit 343a3e1
Show file tree
Hide file tree
Showing 83 changed files with 12,038 additions and 12,742 deletions.
67 changes: 67 additions & 0 deletions x-pack/plugins/apm/common/connections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { AgentName } from '../typings/es_schemas/ui/fields/agent';
import { Coordinate } from '../typings/timeseries';

export enum NodeType {
service = 'service',
backend = 'backend',
}

interface NodeBase {
id: string;
}

export interface ServiceNode extends NodeBase {
type: NodeType.service;
serviceName: string;
agentName: AgentName;
environment: string;
}

export interface BackendNode extends NodeBase {
type: NodeType.backend;
backendName: string;
spanType: string;
spanSubtype: string;
}

export type Node = ServiceNode | BackendNode;

export interface ConnectionStatsItem {
location: Node;
stats: {
latency: {
value: number | null;
timeseries: Coordinate[];
};
throughput: {
value: number | null;
timeseries: Coordinate[];
};
errorRate: {
value: number | null;
timeseries: Coordinate[];
};
};
}

export interface ConnectionStatsItemWithImpact extends ConnectionStatsItem {
stats: ConnectionStatsItem['stats'] & {
impact: number;
};
}

export interface ConnectionStatsItemWithComparisonData {
location: Node;
currentStats: ConnectionStatsItemWithImpact['stats'];
previousStats: ConnectionStatsItemWithImpact['stats'] | null;
}

export function getNodeName(node: Node) {
return node.type === NodeType.service ? node.serviceName : node.backendName;
}
22 changes: 19 additions & 3 deletions x-pack/plugins/apm/common/utils/get_offset_in_ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@
import moment from 'moment';
import { parseInterval } from '../../../../../src/plugins/data/common';

export function getOffsetInMs(start: number, offset?: string) {
export function getOffsetInMs({
start,
end,
offset,
}: {
start: number;
end: number;
offset?: string;
}) {
if (!offset) {
return 0;
return {
startWithOffset: start,
endWithOffset: end,
offsetInMs: 0,
};
}

const interval = parseInterval(offset);
Expand All @@ -20,5 +32,9 @@ export function getOffsetInMs(start: number, offset?: string) {

const calculatedOffset = start - moment(start).subtract(interval).valueOf();

return calculatedOffset;
return {
startWithOffset: start - calculatedOffset,
endWithOffset: end - calculatedOffset,
offsetInMs: calculatedOffset,
};
}
Binary file not shown.
Loading

0 comments on commit 343a3e1

Please sign in to comment.