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

feat: create new service for logging metadata from filter #1450

Merged
merged 5 commits into from Jun 15, 2023

Conversation

jmcdo29
Copy link
Owner

@jmcdo29 jmcdo29 commented Nov 5, 2022

The new OgmaFilterService an be injected into a service and take in an exception and an arguments host object from Nest and print out metadata according to how the request failed. This will only happen, however, if the request has not been logged by an interceptor, meaning there will not be double logging of requests which would make logs noiser.

This is done by checking for the existence of the requestId added by the interceptor earlier in the call, and the major gain here is that now errors caused by guards or middleware can be caught can logged just as other requests are properly automatically logged as well, making Ogma now fully capable of logging any request type into Nest! This feature is opt-in, just as the interceptor is, but the power it brings is major due to now not leaving any requests unlogged.

The only downside at the moment is not being able to determing the time length of the request as most underlying transports don't grab the metadata of the start time, but there will be mentions of how users can implement such a feature to allow for that if they so choose.

@nx-cloud
Copy link

nx-cloud bot commented Nov 5, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 98eea09. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 7 targets

Sent with 💌 from NxCloud.

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2022

⚠️ No Changeset found

Latest commit: 116bd02

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@jmcdo29 jmcdo29 force-pushed the feat/filter-logger-service branch 2 times, most recently from 2885616 to b8d0ae3 Compare November 8, 2022 20:13
@jmcdo29
Copy link
Owner Author

jmcdo29 commented Nov 9, 2022

Waiting on nestjs/nest#10545 to handle the websocket part before merging

@jmcdo29 jmcdo29 marked this pull request as draft November 9, 2022 02:13
@AdaptingAFM
Copy link

Any hopes on this releasing any what soon?

@jmcdo29
Copy link
Owner Author

jmcdo29 commented Jun 12, 2023

Any hopes on this releasing any what soon?

I'd love to. Still waiting on the PR on the Nest side to go through so I can include websockets as well PR has been merged, looks like it'll be released as part of Nest 10.0.0. I'll make this a part of Ogma 5.0.0 along with the breaking changes with the performance updates

@jmcdo29 jmcdo29 changed the base branch from main to feat/nestjs-module-5.0.0 June 15, 2023 15:17
The new `OgmaFilterLogger` an be injected into a service and take in an
exception and an arguments host object from Nest and print out metadata
according to how the request failed. This will **only** happen, however, if the
request has not been logged by an interceptor, meaning there will not be double
logging of requests which would make logs noiser.

This is done by checking for the existence of the `requestId` added by the
interceptor earlier in the call, and the major gain here is that now errors
caused by guards or middleware can be caught can logged just as other requests
are properly automatically logged as well, making Ogma now fully capable of
logging **any** request type into Nest! This feature is opt-in, just as the
interceptor is, but the power it brings is major due to now not leaving any
requests unlogged.

The only downside at the moment is not being able to determing the time length
of the request as most underlying transports don't grab the metadata of the
start time, but there will be mentions of how users can implement such a
feature to allow for that if they so choose.
@jmcdo29 jmcdo29 force-pushed the feat/filter-logger-service branch from 98eea09 to 96644c9 Compare June 15, 2023 16:08
@jmcdo29 jmcdo29 marked this pull request as ready for review June 15, 2023 16:26
@jmcdo29 jmcdo29 merged commit e0d5199 into feat/nestjs-module-5.0.0 Jun 15, 2023
2 checks passed
@jmcdo29 jmcdo29 deleted the feat/filter-logger-service branch June 15, 2023 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants