justtrackio / gosoline

Gosoline is our framework which fuels all of our Golang applications
MIT License
93 stars 50 forks source link

log: Sampling request logger #1135

Open bt-justtrack opened 3 months ago

bt-justtrack commented 3 months ago

We want / need a logger which can sample request log traces. The following requirements apply:

bt-justtrack commented 2 months ago

This logger should work on a per service basis. Eg: Service A processes successfully and samples the logs, hands over to Service B Service B processing fails, emits logs. Doing the sampling decision cross service is not the goal. We want to pass a sampling decision inside of context based on a sampler that is run eg for httpserver on request receive. This sampling decision can later be overridden based on eg a failure. For eg the http server this can be implemented through a middleware injecting the sampling info into the context. The logger can register a hook with the sampling span on first encounter of it and collect the log messages for that span. Once the sampling middleware returns it can close the span and call the hook, which causes the logger to emit or drop the log statements.

This means we want to have as first argument the context.Context for all log statements.