Skip to content
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

Add new elasticsearch client #69905

Merged
merged 55 commits into from
Jul 8, 2020
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
10f0846
add "@elastic/elasticsearch" to dependencies
pgayvallet Jun 25, 2020
e923ce5
first POC of new client
pgayvallet Jun 25, 2020
175e0cb
add logging
pgayvallet Jun 25, 2020
f56a506
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jun 29, 2020
24ac36b
add generation script for client facade API and implementation
pgayvallet Jun 29, 2020
024f3df
add back keepAlive
pgayvallet Jun 30, 2020
cfa547a
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jun 30, 2020
eecd780
add exports from client
pgayvallet Jun 30, 2020
8c6c9fc
add new client mocks
pgayvallet Jun 30, 2020
c7a2cf1
add some doc
pgayvallet Jun 30, 2020
193fecc
fix API usages
pgayvallet Jun 30, 2020
b8935d7
rename legacy client to legacy in service
pgayvallet Jun 30, 2020
f268e63
rename currently unused config/client observable
pgayvallet Jun 30, 2020
73f68b8
wire new client to service & update mocks
pgayvallet Jun 30, 2020
2c5a489
fix mock type
pgayvallet Jun 30, 2020
c7ae6aa
export client types
pgayvallet Jun 30, 2020
93d05ee
add transport.request
pgayvallet Jun 30, 2020
4156411
more doc
pgayvallet Jun 30, 2020
5a3fd9c
migrate version_check to new client
pgayvallet Jun 30, 2020
71a27bb
fix default port logic
pgayvallet Jun 30, 2020
e48f3ad
rename legacy client mocks
pgayvallet Jun 30, 2020
bdacda3
move legacy client mocks to legacy folder
pgayvallet Jun 30, 2020
152b6dc
start adding tests
pgayvallet Jun 30, 2020
b265759
add configure_client tests
pgayvallet Jul 1, 2020
9e356e8
add get_client_facade tests
pgayvallet Jul 1, 2020
353253f
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 1, 2020
7e49f65
bump client to 7.8
pgayvallet Jul 1, 2020
bda204e
add cluster_client tests
pgayvallet Jul 1, 2020
28b8cfc
expose new client on internal contract only
pgayvallet Jul 1, 2020
8cd1ed2
revert using the new client for es version check
pgayvallet Jul 1, 2020
205c100
add service level test for new client
pgayvallet Jul 1, 2020
7819166
update generated API
pgayvallet Jul 1, 2020
d1cdb0a
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 1, 2020
80bfc97
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 1, 2020
bf18e61
Revert "rename legacy client mocks"
pgayvallet Jul 1, 2020
6c4ff93
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 1, 2020
8a397d0
address some review comments
pgayvallet Jul 1, 2020
533212b
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 2, 2020
0a09aee
revert ts-expect-error from unowned files
pgayvallet Jul 2, 2020
1a68ea1
move response mocks to mocks.ts
pgayvallet Jul 3, 2020
f956fb4
Remove generated facade, use ES Client directly
pgayvallet Jul 3, 2020
56db6c4
log queries even in case of error
pgayvallet Jul 3, 2020
d6f1c9d
nits
pgayvallet Jul 3, 2020
83b7246
use direct properties instead of accessors
pgayvallet Jul 3, 2020
a764b10
handle async closing of client
pgayvallet Jul 3, 2020
9d272ba
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 3, 2020
3f1d9bd
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 6, 2020
88ae350
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 6, 2020
cb242e7
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 7, 2020
413a97d
review nits
pgayvallet Jul 7, 2020
c0d7f3a
ElasticSearchClient -> ElasticsearchClient
pgayvallet Jul 7, 2020
022e4a2
add test for encoded querystring
pgayvallet Jul 7, 2020
0dc69b4
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 8, 2020
5acfe96
adapt test file
pgayvallet Jul 8, 2020
f059964
Merge remote-tracking branch 'upstream/master' into kbn-35508-add-new…
pgayvallet Jul 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
log queries even in case of error
  • Loading branch information
pgayvallet committed Jul 3, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 56db6c43c7105078491240171438a1c707c4d732
39 changes: 39 additions & 0 deletions src/core/server/elasticsearch/client/configure_client.test.ts
Original file line number Diff line number Diff line change
@@ -179,6 +179,45 @@ describe('configureClient', () => {
`);
});

it('logs queries even in case of errors if `logQueries` is true', () => {
const client = configureClient(
createFakeConfig({
logQueries: true,
}),
{ logger, scoped: false }
);

const response = createApiResponse({
statusCode: 500,
body: {
error: {
type: 'internal server error',
},
},
params: {
method: 'GET',
path: '/foo',
querystring: { hello: 'dolly' },
},
});
client.emit('response', new errors.ResponseError(response), response);

expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(`
Array [
Array [
"500
GET /foo
hello=dolly",
Object {
"tags": Array [
"query",
],
},
],
]
`);
});

it('does not log queries if `logQueries` is false', () => {
const client = configureClient(
createFakeConfig({
3 changes: 2 additions & 1 deletion src/core/server/elasticsearch/client/configure_client.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@ const addLogging = (client: Client, logger: Logger, logQueries: boolean) => {
client.on('response', (err, event) => {
if (err) {
logger.error(`${err.name}: ${err.message}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we okay not to log warnings anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took #69905 (comment) as a 'yes', as warning are per-request and can now be handled by the consumers. but we can decide to log them on our own. I don't really have an opinion on that one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m wondering if the client should log warnings more aggressively, maybe via process.emitWarning.
This is because I think users will never proactively go and read the warnings key. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.emitWarning seems way too aggressive imho. Being able to get them using the event emitter API is fine.

} else if (logQueries) {
}
if (event && logQueries) {
const params = event.meta.request.params;

// definition is wrong, `params.querystring` can be either a string or an object