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

Differentiate between client applications #15

Open
dmke opened this issue May 3, 2022 · 0 comments
Open

Differentiate between client applications #15

dmke opened this issue May 3, 2022 · 0 comments
Milestone

Comments

@dmke
Copy link
Member

dmke commented May 3, 2022

When texd is used by multiple client applications, it would be nice to see some application-specific metrics.

To accomplish this, I suggest analysing an optional X-Application header within the HTTP handler, and manipulate a corresponding metric counter:

// package metrics
var ProcessedByApplication = promauto.NewCounterVec(prometheus.CounterOpts{
  Name: "texd_client_applications",
  Help: "Number of jobs created, by client application"
}, []string{"name"})


// package service
func (svc *service) HandleRender(res http.ResponseWriter, req *http.Request) {
  if app := req.Header.Get("X-Application"); app != "" {
    metrics.ProcessedByApplication.WithLabelValues(app).Inc()
  }
  // ...
}

(This might need some safety guards, like limiting the header value length, and protection against non-ASCII characters.)

Alternatively, we could add extend the existing metrics.ProcessedX counters, but then why stop there and not also extend metrics.XSize?

Additionally, the Ruby client shall automatically set the header value to something like Rails.application.class.name.split("::").first.downcase (but make it configurable, as this can only be a heuristic).

@dmke dmke added this to the v1.0 milestone Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant