From 53bd98d6c528e31a0211cb08a136c5c040e8aabf Mon Sep 17 00:00:00 2001 From: Augustin Husson Date: Tue, 5 Nov 2024 15:10:14 +0100 Subject: [PATCH 1/2] add small unit tests Signed-off-by: Augustin Husson --- go.mod | 3 +++ utils/prometheus/prometheus_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 utils/prometheus/prometheus_test.go diff --git a/go.mod b/go.mod index 1c347cd..e799d49 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/prometheus/common v0.60.1 github.com/prometheus/prometheus v0.55.0 github.com/sirupsen/logrus v1.9.3 + github.com/stretchr/testify v1.9.0 golang.org/x/oauth2 v0.23.0 ) @@ -34,6 +35,7 @@ require ( github.com/charmbracelet/x/ansi v0.2.3 // indirect github.com/cloudflare/circl v1.3.8 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dennwc/varint v1.0.0 // indirect github.com/elliotchance/orderedmap/v2 v2.2.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect @@ -91,6 +93,7 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect diff --git a/utils/prometheus/prometheus_test.go b/utils/prometheus/prometheus_test.go new file mode 100644 index 0000000..5cb2497 --- /dev/null +++ b/utils/prometheus/prometheus_test.go @@ -0,0 +1,13 @@ +package prometheus + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestExtractMetricNamesFromPromQL(t *testing.T) { + result, err := ExtractMetricNamesFromPromQL("service_status{env=~\"$env\",region=~\"$region\"}") + assert.NoError(t, err) + assert.Equal(t, []string{"service_status"}, result) +} From 04e28dcb54813e2fb2e1a5282c6dae9db27381a9 Mon Sep 17 00:00:00 2001 From: Augustin Husson Date: Tue, 5 Nov 2024 15:19:11 +0100 Subject: [PATCH 2/2] add bug_report issue template Signed-off-by: Augustin Husson --- .github/ISSUE_TEMPLATE/bug_report.yml | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..9c4d0c3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,51 @@ +--- +name: Bug report +description: Create a report to help us improve. +labels: [ "bug" ] +body: + - type: markdown + attributes: + value: | + Thank you for opening a bug report for MetricUsage. + + Please do *NOT* ask support questions in Github issues. + + If your issue is not a feature request or bug report contact us directly on slack. + - type: textarea + attributes: + label: What did you do? + description: Please provide steps for us to reproduce this issue. + validations: + required: true + - type: textarea + attributes: + label: What did you expect to see? + - type: textarea + attributes: + label: What did you see instead? Under which circumstances? + validations: + required: true + - type: markdown + attributes: + value: | + ## Environment + - type: input + attributes: + label: System information + description: insert output of `uname -srm` here, or operating system version + placeholder: e.g. Linux 5.16.15 x86_64 + - type: input + attributes: + label: MetricsUsage version + description: Insert the MetricsUsage version here. + placeholder: e.g. 0.3.0 + - type: textarea + attributes: + label: MetricsUsage configuration file + description: Insert relevant configuration here. Don't forget to remove secrets. + render: yaml + - type: textarea + attributes: + label: Logs + description: Insert MetricsUsage logs relevant to the issue here. + render: text