Skip to content

Commit

Permalink
Revert "[APM] Mock synthetic source for metric documents (#139643)" (#…
Browse files Browse the repository at this point in the history
…143027) (#143033)

This reverts commit 1def7cb.

(cherry picked from commit 8c38609)

Co-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>
  • Loading branch information
kibanamachine and sorenlouv authored Oct 11, 2022
1 parent 43379fc commit 9b5bbd5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 191 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
unpackProcessorEvents,
processorEventsToIndex,
} from './unpack_processor_events';
import { fakeSyntheticSource } from './fake_synthetic_source';

export type APMEventESSearchRequest = Omit<ESSearchRequest, 'index'> & {
apm: {
Expand Down Expand Up @@ -159,48 +158,9 @@ export class APMEventClient {

return this.callAsyncWithDebug({
cb: (opts) =>
(
this.esClient.search(searchParams, opts) as unknown as Promise<{
body: TypedSearchResponse<TParams>;
}>
).then((response) => {
// ensure metric data is compatible with synthetic source
// enabled
const metricEventsOnly = params.apm.events.every(
(event) => event === ProcessorEvent.metric
);

if (!response.body?.hits?.hits) {
return response;
}

const hits = response.body.hits.hits.map((hit) => {
if (
metricEventsOnly ||
// take filter_path etc into account
(hit._source &&
'processor' in hit._source &&
hit._source.processor?.event === ProcessorEvent.metric)
) {
return {
...hit,
_source: fakeSyntheticSource(hit._source),
};
}
return hit;
});

return {
...response,
body: {
...response.body,
hits: {
...response.body.hits,
hits,
},
},
};
}),
this.esClient.search(searchParams, opts) as unknown as Promise<{
body: TypedSearchResponse<TParams>;
}>,
operationName,
params: searchParams,
requestType: 'search',
Expand Down

0 comments on commit 9b5bbd5

Please sign in to comment.