
This commit adds code in GO language to expose Physical Function interface device info and statistics (metrics) of a node using REST API service. NIC Statistics provided by Netlink. Following APIs are implemented: /metrics -- all statistics in OpenMetrics format /metrics/device/{DeviceName} -- particular device statistics in OpenMetrics format /metrics/pci-addr/{PciAddr} -- particular pci-address statistics in OpenMetrics format /json/metrics -- all metrics in json format /json/metrics/device/{DeviceName} -- particular device statistics in json format /json/metrics/pci-addr/{PciAddr} -- particular pci-address statistics in json format Test Plan: PASS: GO linting PASS: Unit test PASS: Api test. PASS: Docker image build process defined here [1] PASS: Created container image of this app, pushed to local registry and deployed on AIO-SX lab using sample deployment file. Then tested the APIs and validated the results. Story: 2010918 Task: 48794 [1]https://docs.starlingx.io/developer_resources/build_docker_image.html Change-Id: I5229b338b9e9afff3b02fe2389cfcd0c4e0590f6 Signed-off-by: AbhishekJ <abhishek.jaiswal@windriver.com>
46 lines
1.1 KiB
Makefile
46 lines
1.1 KiB
Makefile
#
|
|
# Copyright (c) 2023 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# All Rights Reserved.
|
|
#
|
|
|
|
# variables
|
|
GO ?= go
|
|
GOCOVER ?= $(GO) tool cover
|
|
LABEL ?= metrics-exporter-api
|
|
|
|
# Targets
|
|
help: ## Show this help.
|
|
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
|
|
|
|
apphelp: ## Show this help.
|
|
$(GO) run . -h
|
|
|
|
install_dep: ## install go dependency
|
|
$(GO) mod tidy
|
|
|
|
run: ## run app on host machine
|
|
$(GO) run .
|
|
|
|
test: ## run go unit test
|
|
$(GO) test ./...
|
|
|
|
testcov: ## run go coverage test
|
|
$(GO) test -coverprofile=coverage.out ./...
|
|
$(GO) tool cover -func=coverage.out
|
|
$(GO) tool cover -html=coverage.out -o coverage.html
|
|
|
|
vet: ## run go vet
|
|
$(GO) vet
|
|
|
|
lint: ## run go lint
|
|
golangci-lint run
|
|
|
|
build_linux: ## Build application
|
|
CGO_ENABLED=0 GOOS=linux go build -o metrics-api-server
|
|
|
|
build_image: ## Build docker image
|
|
docker build -f ../../debian/Dockerfile -t starlingx/metrics-exporter-api ../
|