-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Reporting/New Platform] Use the logger service from core #55442
[Reporting/New Platform] Use the logger service from core #55442
Conversation
} | ||
|
||
public debug(msg: string, tags: string[] = []) { | ||
this._logger([...this._tags, ...tags, 'debug'], trimStr(msg)); | ||
this.getLogger(tags).debug(msg); |
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 am finding that no debug messages are getting logged with the changes from this branch.
@joshdover you asked me to track this for you. I'll give it another run and file a bug if needed.
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.
Filed #55456
Pinging @elastic/kibana-reporting-services (Team:Reporting Services) |
08adc15
to
604dd2c
Compare
import { fieldFormatMapFactory } from './lib/field_format_map'; | ||
import { createGenerateCsv } from './lib/generate_csv'; |
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.
Apologies, but this PR contains some automated changes of an IDE tool that organize the imports
93b46ec
to
94ebeeb
Compare
Ack: will review tomorrow |
await expectRejectedPromise(executeJob('job123', jobParams, cancellationToken)); | ||
await expect( | ||
executeJob('job123', jobParams, cancellationToken) | ||
).rejects.toMatchInlineSnapshot(`[TypeError: Cannot read property 'indexOf' of undefined]`); |
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.
this seems a little strange. It's worth a look to see if this is the actual expected error
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.
LGTM
Some NITs and comments:
const mockLogger = new LevelLogger({ | ||
get: () => ({ | ||
debug: jest.fn(), | ||
warn: jest.fn(), | ||
error: jest.fn(), | ||
}), | ||
}); |
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 can probably use core
mocked logger implementation
import { loggingServiceMock } from '[..]/src/core/server/mocks';
const mockLogger = new LevelLogger({
get: () => loggingServiceMock.createLogger(),
});
const logger = new LevelLogger(this.initializerContext.logger.get('reporting')); | ||
const browserDriverFactory = await createBrowserDriverFactory(__LEGACY, logger); |
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.
NOTE: the legacy initializerContext.logger.get
returns a logger factory with empty context.
You have to be aware what once migrated to NP and using the actual NP plugin's initializerContext
, this will be prefixed with the plugins
context, meaning that this.initializerContext.logger.get('reporting') will returns the plugins.reporting
-prefixed factory instead of just reporting
as of now.
function isResponse(response: Boom<null> | ResponseObject): response is ResponseObject { | ||
return !(response as Boom<unknown>).isBoom; | ||
} |
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: use isBoom
instead (import { isBoom } from 'boom';
+ return !isBoom(response);
)
if (statusCode !== 200) { | ||
if (statusCode === 500) { | ||
logger.error(`Report ${docId} has failed: ${JSON.stringify(response.source)}`); | ||
} else { |
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: would remove one nesting level with if (statusCode === 500) elif (statusCode !== 200)
const reportingFeatureId = getReportingFeatureId(request); | ||
const reportingFeatureId = getReportingFeatureId(request) as string; |
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: the signature seems to already define the return type, why was the force-cast necessary?
export type GetReportingFeatureIdFn = (request: Legacy.Request) => string;
constructor(logger: LoggerFactory, tags?: string[]) { | ||
this._logger = logger; | ||
this._tags = tags; | ||
this._tags = tags || []; |
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: avoid ||
with constructor(logger: LoggerFactory, tags: string[] = []) {
|
||
const trimStr = (toTrim: string) => { | ||
return typeof toTrim === 'string' ? toTrim.trim() : toTrim; | ||
}; | ||
|
||
export class LevelLogger { | ||
private _logger: any; | ||
private _logger: LoggerFactory; |
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: would name is _loggerFactory
or _factory
to be explicit about the type
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
|
||
export const executeJobFactory: ExecuteJobFactory<ESQueueWorkerExecuteFn< | ||
JobDocPayloadDiscoverCsv | ||
>> = function executeJobFactoryFn(server: ServerFacade) { | ||
>> = function executeJobFactoryFn(server: ServerFacade, parentLogger: Logger) { |
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.
Man the >>
threw me for a second. Smelled of merge conflict :/
Summary
Part of #53898
[ ] Blocked on [New Platform / LoggerFactory] Debug messages are not appearing #55456This PR integrates the core New Platform server-side logger with the legacy Reporting plugin.
NOTE: This breaks a technique that users have used to print verbose logs for Reporting.
This config:
Will no longer show debug messages for Reporting. The workaround is to just use:
If that becomes a breaking change when this code is released, then it should be documented. We'll have to keep an eye on this because maybe there will be a better solution before this code is released.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers
[ ] This includes a feature addition or change that requires a release note and was labeled appropriately