cloudwan / gohan

Gohan is an API Gateway Server written by Go that makes it easy for developers to create and maintain REST-style API
http://www.slideshare.net/natiueno/gohan-61170476
Other
109 stars 44 forks source link

Print trace ID in request logs & transaction logs #671

Closed p-kozlowski closed 6 years ago

p-kozlowski commented 6 years ago

The main point of this PR was to include the request trace_id (an UUID) in the request logs (eg. Started GET... or Completed 200 OK) and transaction logs (eg. Created transaction..., Executing SQL query ...). However, to make it feasible, some large-scale refactorings (not rewrites!) were necessary.

I suggest reviewing commit-by-commit.

  1. "Create context.Context and trace_id in middleware layers" is the essence: it moves creating trace ID and context from goext to middleware
  2. "Database interface refactoring" removes dependencies from db package to avoid dependency cycles and introduces functional options paradigm for easier transaction parametrization
  3. "Log trace_id in middleware and transaction" introduces a new type tracingLogger and uses it it goext and transactions
  4. "Simplify Transaction interface" is a follow up of commit 2. - it further simplifies the transaction interface - about half of all methods has been removed
  5. "Exec should clear the cache" fixes bugs in cached_transaction - the cache was not cleared on Exec and new contexts were created instead of using a context passed by parameter
p-kozlowski commented 6 years ago

will squash & merge after getting one more approve