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

DR-3325: Cleaning up logging and README #264

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

7emansell
Copy link
Collaborator

@7emansell 7emansell commented Dec 19, 2024

Ticket:

This PR does the following:

  • Resolves errors that were cluttering our logs (specifically the location is not defined from the home page and the lack of unique IDs on the skeleton loaders) and unused console.logs
  • Starts using the logger (which was set up ages ago) for errors in fetchAPI
    • Adds a setImmediate mock to our Jest setup so the logger works in the test environment
  • Updates the README extensively (deleting unused/redundant sections, adding a table of contents, and adding a section for our logging standards for both server and client side)

Open Questions

Our logging is still split between old and new DC (at least as far as I can tell on QA Cloudwatch and New Relic), which is a little odd, but I guess won't be a problem once Facelift is complete. Do you guys think this should be/can be addressed now?

How has this been tested? How should a reviewer test this?

This branch is currently hooked up to QA so you can see New Relic errors and logs here. In this process, I've found that New Relic collects logs and errors for an application in several places, which can be confusing, so see the updated README logging section for more detail on what you should expect to see.

Winston logs should appear in the Cloudwatch dc-frontend-qa log group.

If you can't be bothered to do all this... this is what they look like :)

Cloudwatch:
Cloudwatch test error (serverside)
New Relic error:
New relic test error (clientside)
New Relic log:
Screenshot 2024-12-30 at 12 23 32 PM

I will revert the GHA to disconnect this branch from QA once you guys check it out.

You can also run the tests to see the format of server side error logs from fetchAPI, and check the console and Cloudwatch log streams to notice how clean and empty they are.

Also, please check out the README since I got a little carried away and there's more changes than just the addition of the logging section.

Accessibility concerns or updates

Checklist:

  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.
  • I have updated the CHANGELOG.md.

@7emansell 7emansell added the WIP Work in progress (don't merge) label Dec 19, 2024
Copy link

vercel bot commented Dec 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
digital-collections ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 30, 2024 5:09pm

@7emansell 7emansell removed the WIP Work in progress (don't merge) label Dec 20, 2024
README.md Outdated
| Branch | Environment | AWS Account | Cluster | Link To Application |
| :--------- | :---------- | :------------- | :-------------------------------------------- | :------------------------------------------------------------------------------------- |
| main | development | | | [localhost:3000](http://localhost:3000) |
| qa | qa | nypl-dams-dev | nyplorg-dc-rp-qa AND dc-frontend-qa | [https://qa-digitalcollections.nypl.org/](https://qa-new-digitalcollections.nypl.org/) |
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this confusing to list two clusters/ is this technically correct? I think the fact that I'm STILL unsure about this setup means we need to have a very clear written description so I'd like to make that happen

Copy link
Member

Choose a reason for hiding this comment

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

That's fair and I can include that later, but no, this is not technically correct. The cluster is only dc-frontend-qa (similar for prod). The reverse proxy cluster is its own thing.

@EdwinGuzman
Copy link
Member

Our logging is still split between old and new DC (at least as far as I can tell on QA Cloudwatch and New Relic), which is a little odd, but I guess won't be a problem once Facelift is complete. Do you guys think this should be/can be addressed now?

This isn't great but if we can live with this for now, let's keep it this way. It might be more effort to consolidate both apps, on Cloudwatch and NR, than to just wait until DCF completely replaces legacy.

@EdwinGuzman
Copy link
Member

If you can't be bothered... this is what they look like

Ha, thanks, but I did look. Did you cause the fetchAPI call to error multiple times? It's great to see this formatted properly in the logs but I'm curious why it's logging so often.

@7emansell
Copy link
Collaborator Author

7emansell commented Dec 20, 2024

Ha, thanks, but I did look. Did you cause the fetchAPI call to error multiple times? It's great to see this formatted properly in the logs but I'm curious why it's logging so often.

I think you're talking about Cloudwatch logs from today/yesterday? I did try it a bunch because I initially expected the logs to go to the QA RP log group. It should not still be logging unless fetchAPI actually errors. This is getting difficult to look at because Alessandra just deployed to QA from the normal branch, so there's some time periods that don't reflect the logging updates here @EdwinGuzman

@@ -106,7 +106,7 @@ export default function DivisionPage({ data }: any) {
laneName={data.name}
/>
) : (
<LaneLoading withTitle={false} />
<LaneLoading id={"unloaded"} withTitle={false} />
Copy link
Member

Choose a reason for hiding this comment

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

nit: you don't need braces around string prop values

@@ -19,6 +19,11 @@ interface DivisionsProps {

export default function DivisionsPage({ summary, divisions }: DivisionsProps) {
const [isLoaded, setIsLoaded] = useState(false);
if ((window as any).newrelic) {
(window as any).newrelic.log("test log from divisions page", {
Copy link
Member

Choose a reason for hiding this comment

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

Do you know where I can see this in NR? I see logs here https://one.newrelic.com/logger?account=121334&duration=86400000&filters=%28domain%20IN%20%28%27BROWSER%27%2C%20%27BROWSER%27%29%20AND%20type%20IN%20%28%27APPLICATION%27%2C%20%27MICRO_FRONTEND%27%29%29&state=97ecb909-d652-d0ee-7371-53a1dcc37c0e

but it's only the "test error from fetch API". I was confused, I saw the following in NR but not in the repo and then noticed from the commits that you added and then removed it. From what I understand, you logged "test error from fetch API" through the logger which uses winston and that did log to cloudwatch. I was not expecting that to log to NR unless if I missed a commit.

Screenshot 2024-12-20 at 3 13 34 PM

Copy link
Collaborator Author

@7emansell 7emansell Dec 20, 2024

Choose a reason for hiding this comment

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

Oh interesting ! I wasn't expecting it to log to NR either, since I was looking at the browser logs. But NR is actually picking up everything I guess via this other APM service– so all those "test error from fetch API" were just logging whenever fetchAPI was called at all, so that makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Testing with the divisions page now...

Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

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

Some comments in the readme. I appreciate taking the time to tidy it and def not carried away.

README.md Outdated
| Branch | Environment | AWS Account | Cluster | Link To Application |
| :--------- | :---------- | :------------- | :-------------------------------------------- | :------------------------------------------------------------------------------------- |
| main | development | | | [localhost:3000](http://localhost:3000) |
| qa | qa | nypl-dams-dev | nyplorg-dc-rp-qa AND dc-frontend-qa | [https://qa-digitalcollections.nypl.org/](https://qa-new-digitalcollections.nypl.org/) |
Copy link
Member

Choose a reason for hiding this comment

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

That's fair and I can include that later, but no, this is not technically correct. The cluster is only dc-frontend-qa (similar for prod). The reverse proxy cluster is its own thing.


### Release Naming Strategy
### Release naming strategy
Copy link
Member

Choose a reason for hiding this comment

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

I don't have a strong opinion but why the sentence case? UX patterns is to use sentence case for titles and I'm cool with this being a convention we follow on our docs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just prefer it and the casing was inconsistent, so i wanted to pick one

README.md Outdated

We structure our logs according to these [NYPL standards](https://github.com/NYPL/engineering-general/blob/main/standards/logging.md). See `logger.js` for the formatting and storage of logs.

Do NOT use `console.log` if you want to add a permanent log, and make sure to clean up your debugging `console.log`s, because they will clutter Cloudwatch and New Relic.
Copy link
Member

Choose a reason for hiding this comment

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

I like the language used, "NOT", "DO". Don't change it, but I wonder if there's a way to use what's in engineering-general or perhaps we should extend engineering-general when it says

The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY/OPTIONAL, in these documents are to be interpreted as described in RFC 2119.

@7emansell
Copy link
Collaborator Author

About to be off for the week so just pushed Alessandra's last PR up to QA again, will return to this 12/30!

@7emansell
Copy link
Collaborator Author

@EdwinGuzman No significant code changes from your last review, just experimented with what New Relic actually captures depending on how you send it (noticeError or log) and then updated README accordingly

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.

2 participants