Comments (5)
Yup, makes sense. I think you could implement this with some kind of handler pattern, like
type HealthStatusChangeHandler func(ctx context.Context, prevStatus, currStatus health.HealthStatus)
Then something like:
- Track a
changeHandlers []HealthStatusChangeHandler
on the healthHandlerImpl- Run these any time
checksDiffer
- Convert
logIfHealthChanged()
into a handler added to list by default
- Run these any time
- Add a
WithHealthStatusChangeHandler
to the server builder that appends to the list - Add a
ThreadDumpOnError
handler somewhere that can be opted in viawitchcraft.NewServer().WithHealthStatusChangeHandler(somewhere.ThreadDumpOnError())
- this is how you opt-in to the basic version of what you describe above
Down the road the framework exists if you want to implement arbitrarily-complex handlers in downstream code where the maintenance is not my problem 😄
from witchcraft-go-server.
We would probably want some rate limiting to protect against flaky results, but otherwise this sounds reasonable.
At what layer would you add the code? Would this be triggered by w-g-s when the /health endpoint is hit or would it be in one of the source utilities like the reporter?
from witchcraft-go-server.
Also, would it be opt-in or opt-out? Would it be configurable per-check?
from witchcraft-go-server.
I'm imagining this being in the same place as we do the "Health status code changed" logic (so here). I am leaning towards starting with opt-in. I am unsure how configurable this should be. On the one hand, I don't really like the idea of enabling consumers to only enable this for some checks, especially given that some processes' health check keys vary across their lifetimes (maybe that's indicative of an abuse of health checks). On the other hand, I like the idea of being able to trigger diagnostic logs only for certain cases.
Something I do not want a diagnostic log for:
checks:
key1:
state: ERROR
message: uhoh
params:
error: "request failed: connection refused"
Something I do want a diagnostic log for:
checks:
key1:
state: ERROR
message: health of some job we expect to complete in a certain amount of time
params:
error: "job failed to complete: context canceled"
Perhaps this is too much configurability (you suddenly allow developers to check for the presence of specific keys and values in the untyped params map of a health check result), but it does enable us to avoid emitting useless diagnostic logs.
from witchcraft-go-server.
changes merged and released in 1.26.1
from witchcraft-go-server.
Related Issues (20)
- Runtime config refreshable produces zero value if cannot parse yaml
- pprof/goroutine returns 404 HOT 2
- Add a default health check for a sliding window of events HOT 1
- TestNewInflightLimitMiddleware test flakes
- Separate out trace sampling for application routes and management routes
- Allow selecting which go metrics you care about to emit HOT 4
- Default server/client metrics too verbose, no option to trim down HOT 10
- log canceled request as 499 instead of 500 HOT 8
- Ability to shutdown server with error HOT 3
- Reduce default trace rate to 1%
- 404s do not produce request logs
- Improved panic logging
- Liveness endpoint should return non-empty JSON object
- Metric loggers should emit 0 value before regular value for certain metric types HOT 1
- connection metrics
- Encrypted values in configuration should be decoded while maintaining YAML structure
- RouteHandlerMiddleware unwieldy for endpoint-specific handling
- Missing pprof routes
- Library equivalent to Java's ManagedScheduledTask
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from witchcraft-go-server.