-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Code deduplication: - combine 3 existing client side hooks into useSearchStrategy - combine server side multiple search strategy files into shared search_strategy_provider.ts - Clarified naming (client/server params, strategy naming etc.), improved types. - None of the actual deeper internal logic changed, larger chunks of code that show up as new lines is mostly just moved code + additional types (e.g. function overloads) to support the different search strategies with the same server side code and client side hook. Co-authored-by: Walter Rafelsberger <[email protected]>
- Loading branch information
1 parent
362a525
commit 3c04a06
Showing
78 changed files
with
1,392 additions
and
1,708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const APM_SEARCH_STRATEGIES = { | ||
APM_FAILED_TRANSACTIONS_CORRELATIONS: 'apmFailedTransactionsCorrelations', | ||
APM_LATENCY_CORRELATIONS: 'apmLatencyCorrelations', | ||
} as const; | ||
export type ApmSearchStrategies = typeof APM_SEARCH_STRATEGIES[keyof typeof APM_SEARCH_STRATEGIES]; | ||
|
||
export const DEFAULT_PERCENTILE_THRESHOLD = 95; |
63 changes: 0 additions & 63 deletions
63
x-pack/plugins/apm/common/search_strategies/correlations/types.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
x-pack/plugins/apm/common/search_strategies/failed_transactions_correlations/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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 { | ||
FieldValuePair, | ||
RawResponseBase, | ||
SearchStrategyClientParams, | ||
} from '../types'; | ||
|
||
import { FAILED_TRANSACTIONS_IMPACT_THRESHOLD } from './constants'; | ||
|
||
export interface FailedTransactionsCorrelation extends FieldValuePair { | ||
doc_count: number; | ||
bg_count: number; | ||
score: number; | ||
pValue: number | null; | ||
normalizedScore: number; | ||
failurePercentage: number; | ||
successPercentage: number; | ||
} | ||
|
||
export type FailedTransactionsCorrelationsImpactThreshold = typeof FAILED_TRANSACTIONS_IMPACT_THRESHOLD[keyof typeof FAILED_TRANSACTIONS_IMPACT_THRESHOLD]; | ||
|
||
export type FailedTransactionsCorrelationsParams = SearchStrategyClientParams; | ||
|
||
export interface FailedTransactionsCorrelationsRawResponse | ||
extends RawResponseBase { | ||
log: string[]; | ||
failedTransactionsCorrelations: FailedTransactionsCorrelation[]; | ||
} |
28 changes: 0 additions & 28 deletions
28
x-pack/plugins/apm/common/search_strategies/failure_correlations/types.ts
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
x-pack/plugins/apm/common/search_strategies/latency_correlations/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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 { | ||
FieldValuePair, | ||
HistogramItem, | ||
RawResponseBase, | ||
SearchStrategyClientParams, | ||
} from '../types'; | ||
|
||
export interface LatencyCorrelation extends FieldValuePair { | ||
correlation: number; | ||
histogram: HistogramItem[]; | ||
ksTest: number; | ||
} | ||
|
||
export interface LatencyCorrelationSearchServiceProgress { | ||
started: number; | ||
loadedHistogramStepsize: number; | ||
loadedOverallHistogram: number; | ||
loadedFieldCandidates: number; | ||
loadedFieldValuePairs: number; | ||
loadedHistograms: number; | ||
} | ||
|
||
export interface LatencyCorrelationsParams extends SearchStrategyClientParams { | ||
percentileThreshold: number; | ||
analyzeCorrelations: boolean; | ||
} | ||
|
||
export interface LatencyCorrelationsRawResponse extends RawResponseBase { | ||
log: string[]; | ||
overallHistogram?: HistogramItem[]; | ||
percentileThresholdValue?: number; | ||
latencyCorrelations?: LatencyCorrelation[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export interface FieldValuePair { | ||
fieldName: string; | ||
// For dynamic fieldValues we only identify fields as `string`, | ||
// but for example `http.response.status_code` which is part of | ||
// of the list of predefined field candidates is of type long/number. | ||
fieldValue: string | number; | ||
} | ||
|
||
export interface HistogramItem { | ||
key: number; | ||
doc_count: number; | ||
} | ||
|
||
export interface ResponseHitSource { | ||
[s: string]: unknown; | ||
} | ||
|
||
export interface ResponseHit { | ||
_source: ResponseHitSource; | ||
} | ||
|
||
export interface RawResponseBase { | ||
ccsWarning: boolean; | ||
took: number; | ||
} | ||
|
||
export interface SearchStrategyClientParams { | ||
environment: string; | ||
kuery: string; | ||
serviceName?: string; | ||
transactionName?: string; | ||
transactionType?: string; | ||
start?: string; | ||
end?: string; | ||
} | ||
|
||
export interface SearchStrategyServerParams { | ||
index: string; | ||
includeFrozen?: boolean; | ||
} | ||
|
||
export type SearchStrategyParams = SearchStrategyClientParams & | ||
SearchStrategyServerParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.