-
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
[http] Add log for route path access #152621
Changes from 4 commits
bf7a3c3
2962355
ed281fe
4ccb36c
fb86412
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -516,6 +516,7 @@ export class HttpServer { | |
} | ||
|
||
private configureRoute(route: RouterRoute) { | ||
const optionsLogger = this.logger.get('http', 'server', this.name, 'options'); | ||
this.log.debug(`registering route handler for [${route.path}]`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if extending this log entry with the values suggested in https://github.com/elastic/kibana/pull/152621/files/bf7a3c36cb4394b06a3b3fa09a0553c3f958bfed#r1126120651 would suffice. Both entries look too similar and are logged at the same time. If the only reason is so that we can use a new logger, I wonder if we can use it here (as long as it's nested, it should still log with the same config) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about that but went a new logger route to be able to silence the extra info or to later remove the logger completely without losing the original log |
||
// Hapi does not allow payload validation to be specified for 'head' or 'get' requests | ||
const validate = isSafeMethod(route.method) ? undefined : { payload: true }; | ||
|
@@ -526,6 +527,8 @@ export class HttpServer { | |
xsrfRequired: route.options.xsrfRequired ?? !isSafeMethod(route.method), | ||
access: route.options.access ?? (route.path.startsWith('/internal') ? 'internal' : 'public'), | ||
}; | ||
// Log HTTP API target consumer. | ||
optionsLogger.debug(`access [${kibanaRouteOptions.access}] for path [${route.path}]`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mind that @jloleysens's comment also suggested adding the method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies, adding that now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done: commit fb86412 |
||
|
||
this.server!.route({ | ||
handler: route.handler, | ||
|
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 chose to add a new logger to make it easier to filter for these specific log lines
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.
If we want to avoid repeating the
http
andserver
part, I think we can define the logger asthis.log.get(this.name, 'options);
.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.
We'd lose the full context around where the log comes from if we remove
http
andserver
, which makes it very hard to analyze the debug-level logs.Personally, I'd prefer being able to filter logs by a full logger name that keeps some sort of record of where it's coming from.
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.
Mind that I'm using
this.log
(instead ofthis.logger
). AFAIK,this.log
is already scoped tohttp.server
, callingthis.log.get
calls a nested logger. If we ever change the parent, it all changes together (as opposed to using the root loggerthis.logger
). I hope it makes sense.++ I agree.
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 did a quick test with
this.log.get(this.name, 'options') with the same
http-console` appender. We end up duplicating the server name: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! cool! I didn't notice the existing entry is logged as
http.server.Kibana
. In that case,this.log.get('options')
is enough :)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.
done: commit
fb86412
(#152621)