Skip to content

Commit

Permalink
[ML] Remove 'async' from variable names.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Sep 6, 2021
1 parent e96aed9 commit 1656d8d
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function isLatencyCorrelations(
);
}

export interface AsyncSearchProviderProgress {
export interface LatencyCorrelationSearchServiceProgress {
started: number;
loadedHistogramStepsize: number;
loadedOverallHistogram: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ import type {
FailedTransactionsCorrelationsRawResponse,
} from '../../../../common/search_strategies/failed_transactions_correlations/types';
import type { ApmIndicesConfig } from '../../settings/apm_indices/get_apm_indices';
import { asyncSearchServiceLogProvider } from '../async_search_service_log';
import { searchServiceLogProvider } from '../search_service_log';
import {
fetchFailedTransactionsCorrelationPValues,
fetchTransactionDurationFieldCandidates,
} from '../queries';
import type { AsyncSearchServiceProvider } from '../search_strategy_provider';
import type { SearchServiceProvider } from '../search_strategy_provider';

import { asyncFailedTransactionsCorrelationsSearchServiceStateProvider } from './async_search_service_state';
import { failedTransactionsCorrelationsSearchServiceStateProvider } from './failed_transactions_correlations_search_service_state';

import { ERROR_CORRELATION_THRESHOLD } from '../constants';

export type FailedTransactionsCorrelationsAsyncSearchServiceProvider = AsyncSearchServiceProvider<
export type FailedTransactionsCorrelationsSearchServiceProvider = SearchServiceProvider<
FailedTransactionsCorrelationsParams,
FailedTransactionsCorrelationsRawResponse
>;
Expand All @@ -43,15 +43,15 @@ export type FailedTransactionsCorrelationsSearchStrategy = ISearchStrategy<
IKibanaSearchResponse<FailedTransactionsCorrelationsRawResponse>
>;

export const failedTransactionsCorrelationsAsyncSearchServiceProvider: FailedTransactionsCorrelationsAsyncSearchServiceProvider = (
export const failedTransactionsCorrelationsSearchServiceProvider: FailedTransactionsCorrelationsSearchServiceProvider = (
esClient: ElasticsearchClient,
getApmIndices: () => Promise<ApmIndicesConfig>,
searchServiceParams: FailedTransactionsCorrelationsParams,
includeFrozen: boolean
) => {
const { addLogMessage, getLogMessages } = asyncSearchServiceLogProvider();
const { addLogMessage, getLogMessages } = searchServiceLogProvider();

const state = asyncFailedTransactionsCorrelationsSearchServiceStateProvider();
const state = failedTransactionsCorrelationsSearchServiceStateProvider();

async function fetchErrorCorrelations() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Progress {
loadedFieldCandidates: number;
loadedFailedTransactionsCorrelations: number;
}
export const asyncFailedTransactionsCorrelationsSearchServiceStateProvider = () => {
export const failedTransactionsCorrelationsSearchServiceStateProvider = () => {
let ccsWarning = false;
function setCcsWarning(d: boolean) {
ccsWarning = d;
Expand Down Expand Up @@ -90,6 +90,6 @@ export const asyncFailedTransactionsCorrelationsSearchServiceStateProvider = ()
};
};

export type AsyncSearchServiceState = ReturnType<
typeof asyncFailedTransactionsCorrelationsSearchServiceStateProvider
export type FailedTransactionsCorrelationsSearchServiceState = ReturnType<
typeof failedTransactionsCorrelationsSearchServiceStateProvider
>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

export {
failedTransactionsCorrelationsAsyncSearchServiceProvider,
FailedTransactionsCorrelationsAsyncSearchServiceProvider,
failedTransactionsCorrelationsSearchServiceProvider,
FailedTransactionsCorrelationsSearchServiceProvider,
FailedTransactionsCorrelationsSearchStrategy,
} from './async_search_service';
} from './failed_transactions_correlations_search_service';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

export {
latencyCorrelationsAsyncSearchServiceProvider,
LatencyCorrelationsAsyncSearchServiceProvider,
latencyCorrelationsSearchServiceProvider,
LatencyCorrelationsSearchServiceProvider,
LatencyCorrelationsSearchStrategy,
} from './async_search_service';
} from './latency_correlations_search_service';
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import {
fetchTransactionDurationRanges,
} from '../queries';
import { computeExpectationsAndRanges } from '../utils';
import { asyncSearchServiceLogProvider } from '../async_search_service_log';
import type { AsyncSearchServiceProvider } from '../search_strategy_provider';
import { searchServiceLogProvider } from '../search_service_log';
import type { SearchServiceProvider } from '../search_strategy_provider';

import { asyncSearchServiceStateProvider } from './async_search_service_state';
import { latencyCorrelationsSearchServiceStateProvider } from './latency_correlations_search_service_state';

export type LatencyCorrelationsAsyncSearchServiceProvider = AsyncSearchServiceProvider<
export type LatencyCorrelationsSearchServiceProvider = SearchServiceProvider<
LatencyCorrelationsParams,
LatencyCorrelationsRawResponse
>;
Expand All @@ -47,15 +47,15 @@ export type LatencyCorrelationsSearchStrategy = ISearchStrategy<
IKibanaSearchResponse<LatencyCorrelationsRawResponse>
>;

export const latencyCorrelationsAsyncSearchServiceProvider: LatencyCorrelationsAsyncSearchServiceProvider = (
export const latencyCorrelationsSearchServiceProvider: LatencyCorrelationsSearchServiceProvider = (
esClient: ElasticsearchClient,
getApmIndices: () => Promise<ApmIndicesConfig>,
searchServiceParams: LatencyCorrelationsParams,
includeFrozen: boolean
) => {
const { addLogMessage, getLogMessages } = asyncSearchServiceLogProvider();
const { addLogMessage, getLogMessages } = searchServiceLogProvider();

const state = asyncSearchServiceStateProvider();
const state = latencyCorrelationsSearchServiceStateProvider();

async function fetchCorrelations() {
let params:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* 2.0.
*/

import { asyncSearchServiceStateProvider } from './async_search_service_state';
import { latencyCorrelationsSearchServiceStateProvider } from './latency_correlations_search_service_state';

describe('async search service', () => {
describe('asyncSearchServiceStateProvider', () => {
describe('search service', () => {
describe('latencyCorrelationsSearchServiceStateProvider', () => {
it('initializes with default state', () => {
const state = asyncSearchServiceStateProvider();
const state = latencyCorrelationsSearchServiceStateProvider();
const defaultState = state.getState();
const defaultProgress = state.getOverallProgress();

Expand All @@ -30,7 +30,7 @@ describe('async search service', () => {
});

it('returns updated state', () => {
const state = asyncSearchServiceStateProvider();
const state = latencyCorrelationsSearchServiceStateProvider();

state.setCcsWarning(true);
state.setError(new Error('the-error-message'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import type { HistogramItem } from '../../../../common/search_strategies/types';
import type {
AsyncSearchProviderProgress,
LatencyCorrelationSearchServiceProgress,
LatencyCorrelation,
} from '../../../../common/search_strategies/latency_correlations/types';

export const asyncSearchServiceStateProvider = () => {
export const latencyCorrelationsSearchServiceStateProvider = () => {
let ccsWarning = false;
function setCcsWarning(d: boolean) {
ccsWarning = d;
Expand Down Expand Up @@ -45,7 +45,7 @@ export const asyncSearchServiceStateProvider = () => {
percentileThresholdValue = d;
}

let progress: AsyncSearchProviderProgress = {
let progress: LatencyCorrelationSearchServiceProgress = {
started: Date.now(),
loadedHistogramStepsize: 0,
loadedOverallHistogram: 0,
Expand All @@ -63,7 +63,7 @@ export const asyncSearchServiceStateProvider = () => {
);
}
function setProgress(
d: Partial<Omit<AsyncSearchProviderProgress, 'started'>>
d: Partial<Omit<LatencyCorrelationSearchServiceProgress, 'started'>>
) {
progress = {
...progress,
Expand Down Expand Up @@ -109,6 +109,6 @@ export const asyncSearchServiceStateProvider = () => {
};
};

export type AsyncSearchServiceState = ReturnType<
typeof asyncSearchServiceStateProvider
export type LatencyCorrelationsSearchServiceState = ReturnType<
typeof latencyCorrelationsSearchServiceStateProvider
>;
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import type { estypes } from '@elastic/elasticsearch';
import type { ElasticsearchClient } from 'src/core/server';
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';

import { asyncSearchServiceLogProvider } from '../async_search_service_log';
import { asyncSearchServiceStateProvider } from '../latency_correlations/async_search_service_state';
import { searchServiceLogProvider } from '../search_service_log';
import { latencyCorrelationsSearchServiceStateProvider } from '../latency_correlations/latency_correlations_search_service_state';

import {
fetchTransactionDurationFieldValuePairs,
Expand Down Expand Up @@ -62,8 +62,8 @@ describe('query_field_value_pairs', () => {
search: esClientSearchMock,
} as unknown) as ElasticsearchClient;

const { addLogMessage, getLogMessages } = asyncSearchServiceLogProvider();
const state = asyncSearchServiceStateProvider();
const { addLogMessage, getLogMessages } = searchServiceLogProvider();
const state = latencyCorrelationsSearchServiceStateProvider();

const resp = await fetchTransactionDurationFieldValuePairs(
esClientMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type {
SearchStrategyParams,
} from '../../../../common/search_strategies/types';

import type { AsyncSearchServiceLog } from '../async_search_service_log';
import type { AsyncSearchServiceState } from '../latency_correlations/async_search_service_state';
import type { SearchServiceLog } from '../search_service_log';
import type { LatencyCorrelationsSearchServiceState } from '../latency_correlations/latency_correlations_search_service_state';
import { TERMS_SIZE } from '../constants';

import { getQueryWithParams } from './get_query_with_params';
Expand Down Expand Up @@ -44,7 +44,7 @@ const fetchTransactionDurationFieldTerms = async (
esClient: ElasticsearchClient,
params: SearchStrategyParams,
fieldName: string,
addLogMessage: AsyncSearchServiceLog['addLogMessage']
addLogMessage: SearchServiceLog['addLogMessage']
): Promise<FieldValuePair[]> => {
try {
const resp = await esClient.search(getTermsAggRequest(params, fieldName));
Expand Down Expand Up @@ -93,8 +93,8 @@ export const fetchTransactionDurationFieldValuePairs = async (
esClient: ElasticsearchClient,
params: SearchStrategyParams,
fieldCandidates: string[],
state: AsyncSearchServiceState,
addLogMessage: AsyncSearchServiceLog['addLogMessage']
state: LatencyCorrelationsSearchServiceState,
addLogMessage: SearchServiceLog['addLogMessage']
): Promise<FieldValuePair[]> => {
let fieldValuePairsProgress = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import type { estypes } from '@elastic/elasticsearch';
import type { ElasticsearchClient } from 'src/core/server';
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';

import { asyncSearchServiceLogProvider } from '../async_search_service_log';
import { asyncSearchServiceStateProvider } from '../latency_correlations/async_search_service_state';
import { searchServiceLogProvider } from '../search_service_log';
import { latencyCorrelationsSearchServiceStateProvider } from '../latency_correlations/latency_correlations_search_service_state';

import { fetchTransactionDurationHistograms } from './query_histograms_generator';

Expand Down Expand Up @@ -50,8 +50,8 @@ describe('query_histograms_generator', () => {
search: esClientSearchMock,
} as unknown) as ElasticsearchClient;

const state = asyncSearchServiceStateProvider();
const { addLogMessage, getLogMessages } = asyncSearchServiceLogProvider();
const state = latencyCorrelationsSearchServiceStateProvider();
const { addLogMessage, getLogMessages } = searchServiceLogProvider();

let loadedHistograms = 0;
const items = [];
Expand Down Expand Up @@ -104,8 +104,8 @@ describe('query_histograms_generator', () => {
search: esClientSearchMock,
} as unknown) as ElasticsearchClient;

const state = asyncSearchServiceStateProvider();
const { addLogMessage, getLogMessages } = asyncSearchServiceLogProvider();
const state = latencyCorrelationsSearchServiceStateProvider();
const { addLogMessage, getLogMessages } = searchServiceLogProvider();

let loadedHistograms = 0;
const items = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type {
SearchStrategyParams,
} from '../../../../common/search_strategies/types';

import type { AsyncSearchServiceLog } from '../async_search_service_log';
import type { AsyncSearchServiceState } from '../latency_correlations/async_search_service_state';
import type { SearchServiceLog } from '../search_service_log';
import type { LatencyCorrelationsSearchServiceState } from '../latency_correlations/latency_correlations_search_service_state';
import { CORRELATION_THRESHOLD, KS_TEST_THRESHOLD } from '../constants';

import { getPrioritizedFieldValuePairs } from './get_prioritized_field_value_pairs';
Expand All @@ -24,9 +24,9 @@ import { fetchTransactionDurationRanges } from './query_ranges';

export async function* fetchTransactionDurationHistograms(
esClient: ElasticsearchClient,
addLogMessage: AsyncSearchServiceLog['addLogMessage'],
addLogMessage: SearchServiceLog['addLogMessage'],
params: SearchStrategyParams,
state: AsyncSearchServiceState,
state: LatencyCorrelationsSearchServiceState,
expectations: number[],
ranges: estypes.AggregationsAggregationRange[],
fractions: number[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { APM_SEARCH_STRATEGIES } from '../../../common/search_strategies/constan

import type { ApmIndicesConfig } from '../settings/apm_indices/get_apm_indices';

import { failedTransactionsCorrelationsAsyncSearchServiceProvider } from './failed_transactions_correlations';
import { latencyCorrelationsAsyncSearchServiceProvider } from './latency_correlations';
import { failedTransactionsCorrelationsSearchServiceProvider } from './failed_transactions_correlations';
import { latencyCorrelationsSearchServiceProvider } from './latency_correlations';
import { searchStrategyProvider } from './search_strategy_provider';

export const registerSearchStrategies = (
Expand All @@ -23,7 +23,7 @@ export const registerSearchStrategies = (
registerSearchStrategy(
APM_SEARCH_STRATEGIES.APM_LATENCY_CORRELATIONS,
searchStrategyProvider(
latencyCorrelationsAsyncSearchServiceProvider,
latencyCorrelationsSearchServiceProvider,
getApmIndices,
includeFrozen
)
Expand All @@ -32,7 +32,7 @@ export const registerSearchStrategies = (
registerSearchStrategy(
APM_SEARCH_STRATEGIES.APM_FAILED_TRANSACTIONS_CORRELATIONS,
searchStrategyProvider(
failedTransactionsCorrelationsAsyncSearchServiceProvider,
failedTransactionsCorrelationsSearchServiceProvider,
getApmIndices,
includeFrozen
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import {
asyncSearchServiceLogProvider,
searchServiceLogProvider,
currentTimeAsString,
} from './async_search_service_log';
} from './search_service_log';

describe('async search service', () => {
describe('search service', () => {
describe('currentTimeAsString', () => {
it('returns the current time as a string', () => {
const mockDate = new Date(1392202800000);
Expand All @@ -25,9 +25,9 @@ describe('async search service', () => {
});
});

describe('asyncSearchServiceLogProvider', () => {
describe('searchServiceLogProvider', () => {
it('adds and retrieves messages from the log', async () => {
const { addLogMessage, getLogMessages } = asyncSearchServiceLogProvider();
const { addLogMessage, getLogMessages } = searchServiceLogProvider();

const mockDate = new Date(1392202800000);
// @ts-ignore ignore the mockImplementation callback error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface LogMessage {

export const currentTimeAsString = () => new Date().toISOString();

export const asyncSearchServiceLogProvider = () => {
export const searchServiceLogProvider = () => {
const log: LogMessage[] = [];

function addLogMessage(message: string, error?: string) {
Expand All @@ -31,6 +31,4 @@ export const asyncSearchServiceLogProvider = () => {
return { addLogMessage, getLogMessages };
};

export type AsyncSearchServiceLog = ReturnType<
typeof asyncSearchServiceLogProvider
>;
export type SearchServiceLog = ReturnType<typeof searchServiceLogProvider>;
Loading

0 comments on commit 1656d8d

Please sign in to comment.