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

Add middleware to support tracing-like functionalities #1816

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

yunkon-kim
Copy link
Member

  • Add TracingHook to logger for logging ctx
  • Add traceLogger
  • Add tracing middleware
  • Support a logger to be used in tracing middleware
    • Log to file, Loglevel=trace
  • Update API docs
  • Split the existing middlewares into individual files
    • It could be helpful to clearly show callers in logs
  • Increase default LOGFILE_MAXSIZE 1000 MB

Tested by Beetle API
: Same 'traceId' (1726063245406771411), different 'spanId's (1726063245406790111, 1726063245407560511)
: Log to file at 'trace' level (separate from global log level)

Procedure
: Call GET /beetle/test/tracing
: Call GET /tumblebug/readyz with x-request-id (traceId)

Beetle log

{"level":"trace","traceId":"1726063245406771411","spanId":"1726063245406790111","URI":"/beetle/test/tracing","time":"2024-09-11T23:00:45+09:00","message":"[tracing] receive request"}
{"level":"info","traceId":"1726063245406771411","spanId":"1726063245406790111","time":"2024-09-11T23:00:45+09:00","caller":"pkg/api/rest/common/utility.go:137","message":"RestGetReadyz called"}
{"level":"trace","traceId":"1726063245406771411","spanId":"1726063245406790111","URI":"/beetle/test/tracing","time":"2024-09-11T23:00:45+09:00","message":"[tracing] send response"}
{"level":"info","id":"1726063245406771411","remote_ip":"::1","method":"GET","URI":"/beetle/test/tracing","status":200,"latency_human":"1.4672ms","bytes_in":"","bytes_out":36,"time":"2024-09-11T23:00:45+09:00","caller":"pkg/api/rest/middlewares/zerologger.go:56","message":"request"}

Tumblebug log

{"level":"trace","traceId":"1726063245406771411","spanId":"1726063245407560511","URI":"/tumblebug/readyz","time":"2024-09-11T14:00:45Z","message":"[tracing] receive request"}
{"level":"trace","traceId":"1726063245406771411","spanId":"1726063245407560511","URI":"/tumblebug/readyz","time":"2024-09-11T14:00:45Z","message":"[tracing] send response"}
{"level":"info","id":"1726063245406771411","client_ip":"172.21.0.1","method":"GET","URI":"/tumblebug/readyz","status":200,"latency_human":"80.5µs","bytes_in":"","bytes_out":36,"time":"2024-09-11T14:00:45Z","caller":"src/api/rest/server/middlewares/zerologger.go:57","message":"request"}

* Add TracingHook to logger for logging ctx
* Add traceLogger
* Add tracing middleware
* Support a logger to be used in tracing middleware
  - Log to file, Loglevel=trace
* Update API docs
* Split the existing middlewares into individual files
   - It could be helpful to clearly show callers in logs
* Increase default LOGFILE_MAXSIZE 1000 MB
@yunkon-kim
Copy link
Member Author

/approve

@github-actions github-actions bot added the approved This PR is approved and will be merged soon. label Sep 11, 2024
@cb-github-robot cb-github-robot merged commit a7fafc2 into cloud-barista:main Sep 11, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This PR is approved and will be merged soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants