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

Add build_info metrics to internal metrics #987

Merged
merged 4 commits into from
Jul 3, 2024
Merged
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
1 change: 1 addition & 0 deletions docs/sources/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@ Beyla can be [configured to report internal metrics]({{< relref "./configure/opt
| `beyla_otel_trace_export_errors_total` | CounterVec | Error count on each failed OTEL trace export, by error type |
| `beyla_prometheus_http_requests_total` | CounterVec | Number of requests towards the Prometheus Scrape endpoint, faceted by HTTP port and path |
| `beyla_instrumented_processes` | GaugeVec | Instrumented processes by Beyla, with process name |
| `beyla_build_info` | GaugeVec | Version information of the Beyla binary, including the build time and commit hash |
19 changes: 18 additions & 1 deletion pkg/internal/imetrics/iprom.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package imetrics

import (
"context"
"runtime"
"time"

"github.com/prometheus/client_golang/prometheus"

"github.com/grafana/beyla/pkg/buildinfo"
"github.com/grafana/beyla/pkg/internal/connector"
)

Expand All @@ -29,6 +31,7 @@ type PrometheusReporter struct {
otelTraceExportErrs *prometheus.CounterVec
prometheusRequests *prometheus.CounterVec
instrumentedProcesses *prometheus.GaugeVec
beylaInfo prometheus.Gauge
}

func NewPrometheusReporter(cfg *PrometheusConfig, manager *connector.PrometheusManager) *PrometheusReporter {
Expand Down Expand Up @@ -66,6 +69,18 @@ func NewPrometheusReporter(cfg *PrometheusConfig, manager *connector.PrometheusM
Name: "beyla_instrumented_processes",
Help: "Instrumented processes by Beyla",
}, []string{"process_name"}),
beylaInfo: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "beyla_build_info",
Help: "A metric with a constant '1' value labeled by version, revision, branch, " +
"goversion from which Beyla was built, the goos and goarch for the build.",
ConstLabels: map[string]string{
"goarch": runtime.GOARCH,
"goos": runtime.GOOS,
"goversion": runtime.Version(),
"version": buildinfo.Version,
"revision": buildinfo.Revision,
},
}),
}
manager.Register(cfg.Port, cfg.Path,
pr.tracerFlushes,
Expand All @@ -74,13 +89,15 @@ func NewPrometheusReporter(cfg *PrometheusConfig, manager *connector.PrometheusM
pr.otelTraceExports,
pr.otelTraceExportErrs,
pr.prometheusRequests,
pr.instrumentedProcesses)
pr.instrumentedProcesses,
pr.beylaInfo)

return pr
}

func (p *PrometheusReporter) Start(ctx context.Context) {
p.connector.StartHTTP(ctx)
p.beylaInfo.Set(1)
}

func (p *PrometheusReporter) TracerFlush(len int) {
Expand Down
Loading