Skip to content

Commit

Permalink
Remove stack traces as these are useless on 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Dec 9, 2021
1 parent 6512d60 commit 9a578be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const createApiResponse = <T>({
statusCode?: number;
headers?: Record<string, string>;
warnings?: string[] | null;
params?: TransportRequestParams;
params?: TransportRequestParams & { headers?: Record<string, string> };
requestOptions?: TransportRequestOptions;
}): RequestEvent<T> => {
return {
Expand Down Expand Up @@ -512,7 +512,6 @@ describe('instrumentQueryAndDeprecationLogger', () => {
'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
);
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch('Origin:user');
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(/Stack trace:\n.*at/);
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
/Query:\n.*400\n.*GET \/_path\?hello\=dolly \[illegal_argument_exception\]: request \[\/_path\] contains unrecognized parameter: \[name\]/
);
Expand All @@ -528,8 +527,6 @@ describe('instrumentQueryAndDeprecationLogger', () => {
method: 'GET',
path: '/_path',
querystring: { hello: 'dolly' },
},
requestOptions: {
// Set the request header to indicate to Elasticsearch that this is a request over which users have no control
headers: { 'x-elastic-product-origin': 'kibana' },
},
Expand All @@ -548,7 +545,6 @@ describe('instrumentQueryAndDeprecationLogger', () => {
'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
);
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch('Origin:kibana');
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(/Stack trace:\n.*at/);
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
/Query:\n.*400\n.*GET \/_path\?hello\=dolly \[illegal_argument_exception\]: request \[\/_path\] contains unrecognized parameter: \[name\]/
);
Expand Down Expand Up @@ -581,7 +577,6 @@ describe('instrumentQueryAndDeprecationLogger', () => {
'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
);
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch('Origin:user');
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(/Stack trace:\n.*at/);
expect(loggingSystemMock.collect(logger).debug[1][0]).toMatch(
/Query:\n.*200\n.*GET \/_path\?hello\=dolly/
);
Expand All @@ -597,8 +592,6 @@ describe('instrumentQueryAndDeprecationLogger', () => {
method: 'GET',
path: '/_path',
querystring: { hello: 'dolly' },
},
requestOptions: {
// Set the request header to indicate to Elasticsearch that this is a request over which users have no control
headers: { 'x-elastic-product-origin': 'kibana' },
},
Expand All @@ -618,7 +611,6 @@ describe('instrumentQueryAndDeprecationLogger', () => {
'Elasticsearch deprecation: 299 Elasticsearch-8.1.0 "GET /_path is deprecated"'
);
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch('Origin:kibana');
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(/Stack trace:\n.*at/);
expect(loggingSystemMock.collect(logger).info[0][0]).toMatch(
/Query:\n.*200\n.*GET \/_path\?hello\=dolly/
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ export const instrumentEsQueryAndDeprecationLogger = ({
? 'kibana'
: 'user';

// Strip the first 5 stack trace lines as these are irrelavent to finding the call site
const stackTrace = new Error().stack?.split('\n').slice(5).join('\n');

const deprecationMsg = `Elasticsearch deprecation: ${event.warnings}\nOrigin:${requestOrigin}\nStack trace:\n${stackTrace}\nQuery:\n${queryMsg}`;
const deprecationMsg = `Elasticsearch deprecation: ${event.warnings}\nOrigin:${requestOrigin}\nQuery:\n${queryMsg}`;
if (requestOrigin === 'kibana') {
deprecationLogger.info(deprecationMsg);
} else {
Expand Down

0 comments on commit 9a578be

Please sign in to comment.