Giter Site home page Giter Site logo

Comments (5)

bmoylan avatar bmoylan commented on May 31, 2024 1

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
  • Add a WithHealthStatusChangeHandler to the server builder that appends to the list
  • Add a ThreadDumpOnError handler somewhere that can be opted in via witchcraft.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.

bmoylan avatar bmoylan commented on May 31, 2024

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.

bmoylan avatar bmoylan commented on May 31, 2024

Also, would it be opt-in or opt-out? Would it be configurable per-check?

from witchcraft-go-server.

jamesross3 avatar jamesross3 commented on May 31, 2024

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.

jamesross3 avatar jamesross3 commented on May 31, 2024

changes merged and released in 1.26.1

from witchcraft-go-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.