Skip to content

Conversation

@stanleegoodspeed
Copy link
Collaborator

@stanleegoodspeed stanleegoodspeed commented Nov 1, 2023

Description

This PR adds JSON log formatters to frontend, backend, ads, and discounts. This allows DD attributes to be extracted easily inside the app.

For testing purposes, I enabled the Ads error feature flag so the stack trace will be visible in the logs

Additionally, I verified that the ads and discount logs are not being truncated. The standard logger that comes with werkzeug (python util library used by Flask) is built using the log format 127.0.0.1 - - [01/Mar/2022 12:35:19] "GET / HTTP/1.1" 200 -

Ref: https://circleci.com/blog/application-logging-with-flask/

Motivation

https://datadoghq.atlassian.net/browse/WEB-4090

How to test

If possible, it's easier to start from a new baseline and destroy all old docker images / volumes with docker system prune -a --volumes

  1. Pull down branch locally
  2. Run make local-start
  3. Visit http://localhost and click around to create traffic
  4. View DD app for confirmation of new log changes

Log examples

Backend attributes extracted

Screenshot 2023-11-01 at 11 17 24 AM

Ads service with multi-line log + stack trace

Screenshot 2023-10-31 at 4 13 11 PM

Frontend multi-line log

Screenshot 2023-11-01 at 2 36 09 PM

@arosenkranz
Copy link
Collaborator

I kept getting issues in the backend service that it was missing the lograge game. I tried to rebuild with no cache but still got that issue. Any ideas?

@stanleegoodspeed
Copy link
Collaborator Author

I kept getting issues in the backend service that it was missing the lograge game. I tried to rebuild with no cache but still got that issue. Any ideas?

@arosenkranz can you trying blowing out your volumes via docker system prune --volumes and then rebuilding?

Copy link
Collaborator

@arosenkranz arosenkranz left a comment

Choose a reason for hiding this comment

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

This all looks good! I can start a new branch that removes the bundle cache mount for the backend service, as I have some other changes to make to the docker-compose file to bring better parity between this repo and what we use in labs.

I think the solution for removing the next-commerce:<command> in the frontend logs is to move away from the monorepo setup and integrate those packages into the frontend service, which I think would increase the scope of work in a way that we should just start a new branch for it.

@stanleegoodspeed stanleegoodspeed merged commit 73152ca into main Jan 10, 2024
@stanleegoodspeed stanleegoodspeed deleted the ccole/logs-standardization branch January 10, 2024 15:33
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.

3 participants