Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Differentiate between client applications #15

@dmke

Description

@dmke

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions