Skip to content
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
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
RMDIR := rm -rf

## Globals
GIT_CURRENT_BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
GIT_CURRENT_BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
GIT_COMMIT := $(shell git rev-parse --short HEAD)

REPO_ROOT = $(shell git rev-parse --show-toplevel)
ifndef TAG
Expand Down Expand Up @@ -158,7 +159,7 @@ retina: ## builds retina binary

retina-binary: ## build the Retina binary
go generate ./... && \
go build -v -o $(RETINA_BUILD_DIR)/retina$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version=$(TAG) -X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID=$(APP_INSIGHTS_ID)" $(RETINA_DIR)/main.go
go build -v -o $(RETINA_BUILD_DIR)/retina$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version=$(TAG) -X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID=$(APP_INSIGHTS_ID) -X github.com/microsoft/retina/internal/buildinfo.GitCommit=$(GIT_COMMIT)" $(RETINA_DIR)/main.go

retina-capture-workload: ## build the Retina capture workload
cd $(CAPTURE_WORKLOAD_DIR) && go build -v -o $(RETINA_BUILD_DIR)/captureworkload$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X main.version=$(TAG)"
Expand Down Expand Up @@ -395,12 +396,14 @@ build-windows-binaries: ## Build Windows binaries
CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build -v \
-o $(BUILD_DIR)/captureworkload.exe \
-ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version=$(TAG) \
-X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID=$(APP_INSIGHTS_ID)" \
-X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID=$(APP_INSIGHTS_ID) \
-X github.com/microsoft/retina/internal/buildinfo.GitCommit=$(GIT_COMMIT)" \
$(CAPTURE_WORKLOAD_DIR)/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=$(GOARCH) go build -v \
-o $(BUILD_DIR)/controller.exe \
-ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version=$(TAG) \
-X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID=$(APP_INSIGHTS_ID)" \
-X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID=$(APP_INSIGHTS_ID) \
-X github.com/microsoft/retina/internal/buildinfo.GitCommit=$(GIT_COMMIT)" \
$(RETINA_DIR)/main.go
@echo "Windows binaries built successfully in $(BUILD_DIR)"

Expand Down
1 change: 1 addition & 0 deletions internal/buildinfo/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ var (
// If it is set, the application will send telemetry to the corresponding Application Insights resource.
ApplicationInsightsID string
Version string
GitCommit string
RetinaAgentImageName = "ghcr.io/microsoft/retina/retina-agent"
)
21 changes: 21 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
package metrics

import (
"runtime"

"github.com/microsoft/retina/internal/buildinfo"
"github.com/microsoft/retina/pkg/exporter"
"github.com/microsoft/retina/pkg/log"
"github.com/microsoft/retina/pkg/utils"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
dto "github.com/prometheus/client_model/go"
)

Expand Down Expand Up @@ -201,6 +205,23 @@ func InitializeMetrics() {
utils.Metric,
)

// Build info metric - exposes version/commit/platform as labels with a constant value of 1
buildInfo := promauto.With(exporter.DefaultRegistry).NewGaugeVec(
prometheus.GaugeOpts{
Namespace: exporter.RetinaNamespace,
Name: buildInfoGaugeName,
Help: buildInfoGaugeDescription,
},
[]string{"version", "git_commit", "goversion", "os", "arch"},
)
buildInfo.WithLabelValues(
buildinfo.Version,
buildinfo.GitCommit,
runtime.Version(),
runtime.GOOS,
runtime.GOARCH,
).Set(1)

isInitialized = true
metricsLogger.Info("Metrics initialized")
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const (
infinibandStatsGaugeDescription = "InfiniBand statistics gauge"
infinibandStatusParamsGaugeDescription = "InfiniBand Status Parameters gauge"

buildInfoGaugeName = "build_info"
buildInfoGaugeDescription = "Build information for retina agent"

// Control plane metrics
pluginManagerFailedToReconcileCounterDescription = "Number of times the plugin manager failed to reconcile the plugins"
lostEventsCounterDescription = "Number of events lost in control plane"
Expand Down
Loading