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

unique uuid for each request in log #2261

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MahtabBukhari
Copy link
Contributor

Describe your changes

Issue ticket number; #2255

Link

Close: #2255

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have tested on Chrome and Firefox
  • I have tested on a mobile device
  • I have provided a screenshot or recording of changes in my PR if there were updates to the frontend

@MahtabBukhari
Copy link
Contributor Author

@kevkevinpal Could you please review the PR?

@kevkevinpal
Copy link
Contributor

Hey @MahtabBukhari I think you may have misunderstood the change a bit, but I can give an example

In /test/internal-server-error I added 3 logs in this diff

git diff -- routes/test_routes.go
diff --git a/routes/test_routes.go b/routes/test_routes.go
index 92a82b87..1f23bff7 100644
--- a/routes/test_routes.go
+++ b/routes/test_routes.go
@@ -4,13 +4,17 @@ import (
        "net/http"

        "github.com/go-chi/chi"
+       "github.com/stakwork/sphinx-tribes/utils"
 )

 func TestRoutes() chi.Router {
        r := chi.NewRouter()

        r.Get("/internal-server-error", func(w http.ResponseWriter, r *http.Request) {
-               panic("Forced internal server error")
+               utils.Log.Info("test 1")
+               utils.Log.Info("test 2")
+               utils.Log.Info("test 3")
+               //panic("Forced internal server error")
        })

        return r

And I am expecting to get this output

2024/12/22 17:24:39 /mnt/shared_drive/DEVDIR/sphinx-tribes/db/db.go:412 SLOW SQL >= 200ms
[634.042ms] [rows:298] SELECT * FROM "people" WHERE (unlisted = 'f' OR unlisted is null) AND (deleted = 'f' OR deleted is null)
Could Not Connect To Redis dial tcp 172.31.73.186:6379: i/o timeout
INFO: 2024/12/22 17:24:45 logger.go:47: [no request uuid] Listening on port 5002
INFO: 2024/12/22 17:24:50 logger.go:47: [44898903-92aa-4d98-bf79-b4a2ec0a358f] test 1
INFO: 2024/12/22 17:24:50 logger.go:47: [44898903-92aa-4d98-bf79-b4a2ec0a358f] test 2
INFO: 2024/12/22 17:24:50 logger.go:47: [44898903-92aa-4d98-bf79-b4a2ec0a358f] test 3

But in this PR I am getting this currently

2024/12/22 17:24:39 /mnt/shared_drive/DEVDIR/sphinx-tribes/db/db.go:412 SLOW SQL >= 200ms
[634.042ms] [rows:298] SELECT * FROM "people" WHERE (unlisted = 'f' OR unlisted is null) AND (deleted = 'f' OR deleted is null)
Could Not Connect To Redis dial tcp 172.31.73.186:6379: i/o timeout
INFO: 2024/12/22 17:24:45 logger.go:47: [a0881688-1d0f-4cdd-a8b5-053ca00d90da] Listening on port 5002
INFO: 2024/12/22 17:24:50 logger.go:47: [44898903-92aa-4d98-bf79-b4a2ec0a358f] test 1
INFO: 2024/12/22 17:24:50 logger.go:47: [70694864-c803-4efa-8d20-cf7048cc17c6] test 2
INFO: 2024/12/22 17:24:50 logger.go:47: [da59e7f1-08e2-4d8f-8242-d257ee5e9ce1] test 3

@MahtabBukhari MahtabBukhari force-pushed the unique_uuid_for_each_request_in_log branch from 73915ed to 0743215 Compare December 23, 2024 02:16
@MahtabBukhari
Copy link
Contributor Author

@kevkevinpal Could you please review the PR?

image

@kevkevinpal
Copy link
Contributor

@kevkevinpal Could you please review the PR?

image

is there anyway you can do this in the chi middleware so we don't need to manually set it in the route definition?

@MahtabBukhari
Copy link
Contributor Author

@kevkevinpal Could you please review the PR?

image

is there anyway you can do this in the chi middleware so we don't need to manually set it in the route definition?

Sure let me check

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.

unique uuid for each request in log
2 participants