Skip to content

Commit

Permalink
Addressed comments.
Browse files Browse the repository at this point in the history
Signed-off-by: bwplotka <[email protected]>
  • Loading branch information
bwplotka committed Oct 7, 2024
1 parent ee65708 commit a24bc3e
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 14 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Go
on: [push]

jobs:
build:
runs-on: ubuntu-latest
name: Unit tests on Go ${{ matrix.go }} ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Run unit tests.
env:
GOBIN: /tmp/.bin
run: make test
39 changes: 39 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# This action is synced from https://github.com/prometheus/prometheus
name: golangci-lint
on:
push:
paths:
- "go.sum"
- "go.mod"
- "**.go"
- "scripts/errcheck_excludes.txt"
- ".github/workflows/golangci-lint.yml"
- ".golangci.yml"
pull_request:

permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: 1.23.x
- name: Install snmp_exporter/generator dependencies
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
if: github.repository == 'prometheus/snmp_exporter'
- name: Lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
args: --verbose ./tools/mtypes
version: v1.60.2
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ cluster-destroy: check-deps ## Tear down the benchmarking GKE cluster.
.PHONY: lint
lint: ## Lint resources.
bash ./scripts/shellcheck.sh

GOMODS := $(shell find . -name "go.mod" | grep -v .bingo)
.PHONY: test
test:
@for gomod in $(GOMODS); do \
cd `dirname $$gomod` && go test -v ./...; \
done
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can start as many scenarios as you want on the single cluster (make sure to

The scenario is a path to the "collector" manifest, so anything that will scrape `./manifests/load/avalanche.exampletarget.yaml`. Feel free to adjust anything in `./manifests/scenarios/` or add your own.

This setup uses separate Prometheus for gathering metrics about core resources and collectors (available locally and in GCM). Make sure your pod has `app=collector` label and relevant port name has `-ins` suffix, sto be scraped by this core Prometheus. There is also a dashboard you can apply to GCM in `./dashboards/`.
This setup uses separate Prometheus for gathering metrics about core resources and collectors (available locally and in GCM). Make sure your pod has `app=collector` label and relevant port name has `-ins` suffix, to be scraped by this core Prometheus. There is also a dashboard you can apply to GCM in `./dashboards/`.

* `make stop CLUSTER_NAME=my-prombenchy BENCH_NAME=<name of benchmark, also k8s namespace> SCENARIO=./manifests/scenarios/gmp` kill the node-pool and experiment.

Expand Down
3 changes: 3 additions & 0 deletions manifests/scenarios/gmp-otel/1_collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ data:
# - delete_key(attributes, "project_id")
receivers:
# NOTE(bwplotka): Mimicking scrape config of GMP operator, to ensure
# we have the same labels on the output with the same relabel processing.
# Related issue: https://github.com/bwplotka/prombenchy/issues/13
prometheus/bench:
config:
scrape_configs:
Expand Down
33 changes: 20 additions & 13 deletions tools/mtypes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,40 +67,47 @@ func main() {
writeStatistics(os.Stdout, total, statistics)

if *avalancheFlagsForTotal > 0 {
// adjustedGoal is tracking the # of adjusted series we want to generate with avalanche.
adjustedGoal := float64(*avalancheFlagsForTotal)
fmt.Println()
fmt.Println("Avalanche flags for the similar distribution to get to the adjusted series goal of:", adjustedGoal)

adjustedGoal = adjustedGoal / 10.0 // Assuming --series-count=10
// adjustedSum is tracking the total sum of series so far (at the end hopefully adjustedSum ~= adjustedGoal)
adjustedSum := 0
for _, mtype := range allTypes {
s := statistics[mtype]

// adjustedSeriesRatio is tracking the ratio of this type in the input file.
// We try to get similar ratio, but with different absolute counts, given the total sum of series we are aiming for.
adjustedSeriesRatio := float64(s.adjustedSeries) / float64(total.adjustedSeries)

adjustedSeries := int(adjustedGoal * adjustedSeriesRatio)
// adjustedSeriesForType is tracking (per metric type), how many unique series of that
// metric type avalanche needs to create according to the ratio we got from our input.
adjustedSeriesForType := int(adjustedGoal * adjustedSeriesRatio)

switch mtype {
case dto.MetricType_GAUGE:
fmt.Printf("--gauge-metric-count=%v\n", adjustedSeries)
adjustedSum += adjustedSeries
fmt.Printf("--gauge-metric-count=%v\n", adjustedSeriesForType)
adjustedSum += adjustedSeriesForType
case dto.MetricType_COUNTER:
fmt.Printf("--counter-metric-count=%v\n", adjustedSeries)
adjustedSum += adjustedSeries
fmt.Printf("--counter-metric-count=%v\n", adjustedSeriesForType)
adjustedSum += adjustedSeriesForType
case dto.MetricType_HISTOGRAM:
avgBkts := s.buckets / s.series
adjustedSeries /= 2 + avgBkts
fmt.Printf("--histogram-metric-count=%v\n", adjustedSeries)
adjustedSeriesForType /= 2 + avgBkts
fmt.Printf("--histogram-metric-count=%v\n", adjustedSeriesForType)
fmt.Printf("--histogram-metric-bucket-count=%v\n", avgBkts-1) // -1 is due to caveat of additional +Inf not added by avalanche.
adjustedSum += adjustedSeries * (2 + avgBkts)
adjustedSum += adjustedSeriesForType * (2 + avgBkts)
case metricType_NATIVE_HISTOGRAM:
fmt.Printf("--native-histogram-metric-count=%v\n", adjustedSeries)
adjustedSum += adjustedSeries
fmt.Printf("--native-histogram-metric-count=%v\n", adjustedSeriesForType)
adjustedSum += adjustedSeriesForType
case dto.MetricType_SUMMARY:
avgObjs := s.objectives / s.series
adjustedSeries /= 2 + avgObjs
fmt.Printf("--summary-metric-count=%v\n", adjustedSeries)
adjustedSeriesForType /= 2 + avgObjs
fmt.Printf("--summary-metric-count=%v\n", adjustedSeriesForType)
fmt.Printf("--summary-metric-objective-count=%v\n", avgObjs)
adjustedSum += adjustedSeries * (2 + avgObjs)
adjustedSum += adjustedSeriesForType * (2 + avgObjs)
default:
if s.series > 0 {
log.Fatalf("not supported %v metric in avalanche", mtype)
Expand Down

0 comments on commit a24bc3e

Please sign in to comment.