Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into task/EMT-504-tech…
Browse files Browse the repository at this point in the history
…-debt-cleanup
  • Loading branch information
paul-tavares committed Jun 24, 2020
2 parents e84dabb + e3598cb commit 5137852
Show file tree
Hide file tree
Showing 58 changed files with 803 additions and 2,531 deletions.
38 changes: 1 addition & 37 deletions x-pack/plugins/apm/common/ml_job_constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import {
getMlJobId,
getMlPrefix,
getMlJobServiceName,
getSeverity,
severity,
} from './ml_job_constants';
import { getSeverity, severity } from './ml_job_constants';

describe('ml_job_constants', () => {
it('getMlPrefix', () => {
expect(getMlPrefix('myServiceName')).toBe('myservicename-');
expect(getMlPrefix('myServiceName', 'myTransactionType')).toBe(
'myservicename-mytransactiontype-'
);
});

it('getMlJobId', () => {
expect(getMlJobId('myServiceName')).toBe(
'myservicename-high_mean_response_time'
);
expect(getMlJobId('myServiceName', 'myTransactionType')).toBe(
'myservicename-mytransactiontype-high_mean_response_time'
);
expect(getMlJobId('my service name')).toBe(
'my_service_name-high_mean_response_time'
);
expect(getMlJobId('my service name', 'my transaction type')).toBe(
'my_service_name-my_transaction_type-high_mean_response_time'
);
});

describe('getMlJobServiceName', () => {
it('extracts the service name from a job id', () => {
expect(
getMlJobServiceName('opbeans-node-request-high_mean_response_time')
).toEqual('opbeans-node');
});
});

describe('getSeverity', () => {
describe('when score is undefined', () => {
it('returns undefined', () => {
Expand Down
19 changes: 0 additions & 19 deletions x-pack/plugins/apm/common/ml_job_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,6 @@ export enum severity {
warning = 'warning',
}

export const APM_ML_JOB_GROUP_NAME = 'apm';

export function getMlPrefix(serviceName: string, transactionType?: string) {
const maybeTransactionType = transactionType ? `${transactionType}-` : '';
return encodeForMlApi(`${serviceName}-${maybeTransactionType}`);
}

export function getMlJobId(serviceName: string, transactionType?: string) {
return `${getMlPrefix(serviceName, transactionType)}high_mean_response_time`;
}

export function getMlJobServiceName(jobId: string) {
return jobId.split('-').slice(0, -2).join('-');
}

export function encodeForMlApi(value: string) {
return value.replace(/\s+/g, '_').toLowerCase();
}

export function getSeverity(score?: number) {
if (typeof score !== 'number') {
return undefined;
Expand Down
10 changes: 0 additions & 10 deletions x-pack/plugins/apm/common/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ export interface Connection {
destination: ConnectionNode;
}

export interface ServiceAnomaly {
anomaly_score: number;
anomaly_severity: string;
actual_value: number;
typical_value: number;
ml_job_id: string;
}

export type ServiceNode = ConnectionNode & Partial<ServiceAnomaly>;

export interface ServiceNodeMetrics {
avgMemoryUsage: number | null;
avgCpuUsage: number | null;
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5137852

Please sign in to comment.