Skip to content

Add detailed logging for responses in each handler #110

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions probe_metrics_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/webdevops/azure-metrics-exporter/config"
"github.com/webdevops/azure-metrics-exporter/metrics"

"go.uber.org/zap"
)

func probeMetricsListHandler(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -90,4 +92,11 @@ func probeMetricsListHandler(w http.ResponseWriter, r *http.Request) {

h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
h.ServeHTTP(w, r)

latency := time.Since(startTime)
contextLogger.With(
zap.String("method", r.Method),
zap.Int("status", http.StatusOK),
zap.String("latency", latency.String()),
).Info("Request handled for /probe/metrics/list")
}
9 changes: 9 additions & 0 deletions probe_metrics_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/webdevops/azure-metrics-exporter/config"
"github.com/webdevops/azure-metrics-exporter/metrics"

"go.uber.org/zap"
)

func probeMetricsResourceHandler(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -101,4 +103,11 @@ func probeMetricsResourceHandler(w http.ResponseWriter, r *http.Request) {

h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
h.ServeHTTP(w, r)

latency := time.Since(startTime)
contextLogger.With(
zap.String("method", r.Method),
zap.Int("status", http.StatusOK),
zap.String("latency", latency.String()),
).Info("Request handled for /probe/metrics/resource")
}
9 changes: 9 additions & 0 deletions probe_metrics_resourcegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/webdevops/azure-metrics-exporter/config"
"github.com/webdevops/azure-metrics-exporter/metrics"

"go.uber.org/zap"
)

func probeMetricsResourceGraphHandler(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -100,4 +102,11 @@ func probeMetricsResourceGraphHandler(w http.ResponseWriter, r *http.Request) {

h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
h.ServeHTTP(w, r)

latency := time.Since(startTime)
contextLogger.With(
zap.String("method", r.Method),
zap.Int("status", http.StatusOK),
zap.String("latency", latency.String()),
).Info("Request handled for /probe/metrics/resourcegraph")
}
9 changes: 9 additions & 0 deletions probe_metrics_scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/webdevops/azure-metrics-exporter/config"
"github.com/webdevops/azure-metrics-exporter/metrics"

"go.uber.org/zap"
)

func probeMetricsScrapeHandler(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -102,4 +104,11 @@ func probeMetricsScrapeHandler(w http.ResponseWriter, r *http.Request) {

h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
h.ServeHTTP(w, r)

latency := time.Since(startTime)
contextLogger.With(
zap.String("method", r.Method),
zap.Int("status", http.StatusOK),
zap.String("latency", latency.String()),
).Info("Request handled for /probe/metrics/scrape")
}
9 changes: 9 additions & 0 deletions probe_metrics_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/webdevops/azure-metrics-exporter/config"
"github.com/webdevops/azure-metrics-exporter/metrics"

"go.uber.org/zap"
)

func probeMetricsSubscriptionHandler(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -82,4 +84,11 @@ func probeMetricsSubscriptionHandler(w http.ResponseWriter, r *http.Request) {

h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{})
h.ServeHTTP(w, r)

latency := time.Since(startTime)
contextLogger.With(
zap.String("method", r.Method),
zap.Int("status", http.StatusOK),
zap.String("latency", latency.String()),
).Info("Request handled for /probe/metrics/subscription")
}