-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[APM] Upgrade ES client #86594
[APM] Upgrade ES client #86594
Conversation
Pinging @elastic/apm-ui (Team:apm) |
02ccf9f
to
34ede87
Compare
@elasticmachine merge upstream |
x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts
Show resolved
Hide resolved
… upgrade-es-client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to all be working. Thanks for doing this.
|
||
promise.then( | ||
() => subscription.unsubscribe(), | ||
() => subscription.unsubscribe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we do this twice? It looks intentional but a comment explaining would help me understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second argument to .then()
is a failure callback. The difference between .then(onSuccess, onFailure)
and .then(onSuccess).catch(onFailure)
is that the former calls onFailure only when the original promise is rejected, the second is also called when the onSuccess
handler throws. I will add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this what finally
is for (available since Node 10).
promise.finally(() => subscription.unsubscribe())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's what I used initially but it failed on CI (with the API tests). Admittedly I was too lazy to figure out why that happened 😀 I'll have another look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh duh I knew that I was just reading it as two chained then
s for some reason. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, .finally() doesn't work on CI: https://kibana-ci.elastic.co/job/elastic+kibana+pipeline-pull-request/99947/execution/node/595/log/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bummer. Okay, thanks for trying.
import { contextServiceMock } from 'src/core/server/mocks'; | ||
import supertest from 'supertest'; | ||
import { createApmEventClient } from '.'; | ||
import { createHttpServer } from '../../../../../../../../src/core/server/test_utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a relative path if you're importing from src/core
.
import { createApmEventClient } from '.'; | ||
import { createHttpServer } from '../../../../../../../../src/core/server/test_utils'; | ||
|
||
describe('create_apm_event_client', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd name this createApmEventClient
after the function, not after the module file name.
@@ -49,18 +58,32 @@ export function createInternalESClient({ | |||
>( | |||
params: TSearchRequest | |||
): Promise<ESSearchResponse<TDocument, TSearchRequest>> => { | |||
return callEs('search', params); | |||
return callEs({ | |||
operationName: 'search', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these values defined as constants anywhere? It's clear as-is, but just wondering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's used for logging only as well, the actual ES client call is separate from it.
request.route.path | ||
}`; | ||
|
||
const { title, body } = getMessage(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: for clarity
const { title, body } = getMessage(); | |
const { title, body } = getDebugMessage(); |
export const getSearchDebugBody = (params: Record<string, any>) => | ||
`GET ${params.index}/_search\n${formatObj(params.body)}`; | ||
|
||
export const getDefaultDebugBody = ( | ||
params: Record<string, any>, | ||
operationName: string | ||
) => | ||
`${chalk.bold('ES operation:')} ${operationName}\n${chalk.bold( | ||
'ES query:' | ||
)}\n${formatObj(params)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: perhaps a co-locating the debug message in a single function will make it easier to understand when one is used over the other:
export const getSearchDebugBody = (params: Record<string, any>) => | |
`GET ${params.index}/_search\n${formatObj(params.body)}`; | |
export const getDefaultDebugBody = ( | |
params: Record<string, any>, | |
operationName: string | |
) => | |
`${chalk.bold('ES operation:')} ${operationName}\n${chalk.bold( | |
'ES query:' | |
)}\n${formatObj(params)}`; | |
export const getDebugBody = ( | |
params: Record<string, any>, | |
operationName: string | |
) => { | |
if (operationName === 'search') { | |
return `GET ${params.index}/_search\n${formatObj(params.body)}`; | |
} | |
// message for all but 'search' operatins | |
return `${chalk.bold('ES operation:')} ${operationName}\n${chalk.bold( | |
'ES query:' | |
)}\n${formatObj(params)}`; | |
} |
@elasticmachine merge upstream |
… upgrade-es-client
💛 Build succeeded, but was flaky
Test FailuresX-Pack Saved Object Tagging Functional Tests.x-pack/test/saved_object_tagging/functional/tests/maps_integration·ts.saved objects tagging - functional tests maps integration creating "before each" hook for "allows to select tags for a new map"Standard Out
Stack Trace
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…y-tests * 'master' of github.com:elastic/kibana: (276 commits) [Telemetry] Settings Collector: redact sensitive reported values (elastic#88675) [CI] Combines Jest test jobs (elastic#85850) [Upgrade Assistant] Migrate server to new es-js client (elastic#89207) Migrate maps_legacy, maps_oss, region_map, and tile_map plugions to TS projects (elastic#89351) [Vega Docs] Add experimental flag on the vega maps title (elastic#89402) Increase the time needed to locate the save viz toast (elastic#89301) [Enterprise Search] Add links to doc links service (elastic#89260) Fixed regex bug in Safari (elastic#89399) [Lens] Fix indexpattern checks for missing references (elastic#88840) [Lens] Clean up usage collector (elastic#89109) update apm index pattern (elastic#89395) [APM] Upgrade ES client (elastic#86594) Enable v2 so migrations, disable in FTR tests (elastic#89297) [Search Sessions] Make search session indicator UI opt-in, refactor per-app capabilities (elastic#88699) Cleanup OSS code from visualizations wizard (elastic#89092) [APM] Optimize API test order (elastic#88654) Rename conversion function, extract to module scope and add tests. (elastic#89018) [core.logging] Add ops logs to the KP logging system (elastic#88070) chore(NA): improve ts build refs performance on kbn bootstrap (elastic#89333) skip flaky suite (elastic#89379) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx # x-pack/test/accessibility/config.ts
…ana into task-manager/shift-on-trend * 'task-manager/shift-on-trend' of github.com:gmmorris/kibana: (74 commits) [Metrics UI] Fix Host Overview boxes in Host Detail page (elastic#89299) [Telemetry] Settings Collector: redact sensitive reported values (elastic#88675) [CI] Combines Jest test jobs (elastic#85850) [Upgrade Assistant] Migrate server to new es-js client (elastic#89207) Migrate maps_legacy, maps_oss, region_map, and tile_map plugions to TS projects (elastic#89351) [Vega Docs] Add experimental flag on the vega maps title (elastic#89402) Increase the time needed to locate the save viz toast (elastic#89301) [Enterprise Search] Add links to doc links service (elastic#89260) Fixed regex bug in Safari (elastic#89399) [Lens] Fix indexpattern checks for missing references (elastic#88840) [Lens] Clean up usage collector (elastic#89109) update apm index pattern (elastic#89395) [APM] Upgrade ES client (elastic#86594) Enable v2 so migrations, disable in FTR tests (elastic#89297) [Search Sessions] Make search session indicator UI opt-in, refactor per-app capabilities (elastic#88699) Cleanup OSS code from visualizations wizard (elastic#89092) [APM] Optimize API test order (elastic#88654) Rename conversion function, extract to module scope and add tests. (elastic#89018) [core.logging] Add ops logs to the KP logging system (elastic#88070) chore(NA): improve ts build refs performance on kbn bootstrap (elastic#89333) ...
Closes #83913.
Update: I'm going to remove the auto-instrumentation of ES calls and handle instrumentation separately.
Update #2: I've also added some information about the underlying ES error if there is one:I'm still displaying it as a 500 because that is what it is to the user. There is more information, but I want to be cautious about displaying too much information here.Removed the Elasticsearch error message, as we are hiding the error from the logger/APM agent and core had some security concerns.