Skip to content

Commit

Permalink
Get rid of getCoreServices, param docs, rename type, remove rangeQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jun 28, 2021
1 parent b616063 commit 034c680
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function Correlations() {
const properties: IStickyProperty[] = [];
if (serviceName !== undefined && nextEnvironment !== undefined) {
properties.push({
label: i18n.translate('xpack.apm.transactionDetails.serviceLabel', {
label: i18n.translate('xpack.apm.correlations.serviceLabel', {
defaultMessage: 'Service',
}),
fieldName: SERVICE_NAME,
Expand All @@ -106,7 +106,7 @@ export function Correlations() {
}
if (urlParams.transactionName) {
properties.push({
label: i18n.translate('xpack.apm.transactionDetails.transactionLabel', {
label: i18n.translate('xpack.apm.correlations.transactionLabel', {
defaultMessage: 'Transaction',
}),
fieldName: TRANSACTION_NAME,
Expand All @@ -116,7 +116,7 @@ export function Correlations() {
}
if (urlParams.environment) {
properties.push({
label: i18n.translate('xpack.apm.transactionDetails.environmentLabel', {
label: i18n.translate('xpack.apm.correlations.environmentLabel', {
defaultMessage: 'Environment',
}),
fieldName: SERVICE_ENVIRONMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import {
TRANSACTION_NAME,
} from '../../../../common/elasticsearch_fieldnames';
import type { SearchServiceParams } from '../../../../common/search_strategies/correlations/types';
import {
environmentQuery as getEnvironmentQuery,
rangeQuery as getRangeQuery,
} from '../../../utils/queries';
import { environmentQuery as getEnvironmentQuery } from '../../../utils/queries';
import { ProcessorEvent } from '../../../../common/processor_event';

const getPercentileThresholdValueQuery = (
Expand All @@ -42,6 +39,22 @@ export const getTermsQuery = (
return fieldName && fieldValue ? [{ term: { [fieldName]: fieldValue } }] : [];
};

const getRangeQuery = (
start?: string,
end?: string
): estypes.QueryDslQueryContainer[] => {
return [
{
range: {
'@timestamp': {
...(start !== undefined ? { gte: start } : {}),
...(end !== undefined ? { lte: end } : {}),
},
},
},
];
};

interface QueryParams {
params: SearchServiceParams;
fieldName?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,13 @@ export const isHistogramRoughlyEqual = (

/** Round numeric to the nearest 5
* E.g. if roundBy = 5, results will be 11 -> 10, 14 -> 10, 16 -> 20
* @param n
* @param roundBy
*/
export const roundToNearest = (n: number, roundBy = 5) => {
return Math.ceil((n + 1) / roundBy) * roundBy;
};

/**
* Create a rough stringified version of the histogram
* @param histogram
* @param significantFraction
* @param numBinsToSample
*/
export const hashHistogram = (
histogram: HistogramItem[],
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,12 @@ export class APMPlugin
});

// search strategies for async partial search results
core.getStartServices().then(() => {
if (plugins.data?.search?.registerSearchStrategy !== undefined) {
plugins.data.search.registerSearchStrategy(
'apmCorrelationsSearchStrategy',
apmCorrelationsSearchStrategyProvider()
);
});

}
return {
config$: mergedConfig$,
getApmIndices: boundGetApmIndices,
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/ml/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import type { AlertingPlugin } from '../../alerting/server';
import type { ActionsPlugin } from '../../actions/server';
import type { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
import type {
PluginSetup as PluginSetupData,
PluginStart as PluginStartData,
PluginSetup as DataPluginSetup,
PluginStart as DataPluginStart,
} from '../../../../src/plugins/data/server';

export interface LicenseCheckResult {
Expand All @@ -46,7 +46,7 @@ export interface SavedObjectsRouteDeps {

export interface PluginsSetup {
cloud: CloudSetup;
data: PluginSetupData;
data: DataPluginSetup;
features: FeaturesPluginSetup;
home: HomeServerPluginSetup;
licensing: LicensingPluginSetup;
Expand All @@ -58,7 +58,7 @@ export interface PluginsSetup {
}

export interface PluginsStart {
data: PluginStartData;
data: DataPluginStart;
spaces?: SpacesPluginStart;
}

Expand Down
8 changes: 3 additions & 5 deletions x-pack/plugins/observability/server/utils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export function alertStatusQuery(status: AlertStatus) {
}

export function rangeQuery(
start?: number | string,
end?: number | string,
start?: number,
end?: number,
field = '@timestamp'
): estypes.QueryDslQueryContainer[] {
return [
Expand All @@ -29,9 +29,7 @@ export function rangeQuery(
[field]: {
gte: start,
lte: end,
...(typeof start === 'number' || typeof end === 'number'
? { format: 'epoch_millis' }
: {}),
format: 'epoch_millis',
},
},
},
Expand Down

0 comments on commit 034c680

Please sign in to comment.