Skip to content
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
29 changes: 4 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,7 @@ on:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
check-latest: true
cache: true
- uses: golangci/golangci-lint-action@v3
with:
version: latest
unit:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
check-latest: true
cache: true
- run: make test bench
main:
uses: bsm/misc/.github/workflows/test-go.yml@main
with:
working-directory: .
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/bsm/openmetrics

go 1.16
go 1.24
2 changes: 1 addition & 1 deletion omhttp/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func withCompression(h http.Handler) http.Handler {
w.Header().Set(headerContentEncoding, "gzip")

z := newGzipResponseWriter(w)
defer z.Close()
defer func() { _ = z.Close() }()

h.ServeHTTP(z, r)
} else {
Expand Down
21 changes: 15 additions & 6 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ func isValidMetricName(s string) bool {
}

for i, r := range s {
if !(isAlpha(r) || r == ':' || (i > 0 && r == '_') || (i > 0 && isDigit(r))) {
return false
if isAlpha(r) || r == ':' {
continue
}
if i > 0 && (isDigit(r) || r == '_') {
continue
}
return false
}

return true
Expand All @@ -32,9 +36,13 @@ func isValidLabelName(s string) bool {
return false
}
for i, r := range s {
if !(isAlpha(r) || (i > 0 && r == '_') || (i > 0 && isDigit(r))) {
return false
if isAlpha(r) {
continue
}
if i > 0 && (isDigit(r) || r == '_') {
continue
}
return false
}
return true
}
Expand All @@ -45,9 +53,10 @@ func isValidLabelValue(s string) bool {

func isValidMetricUnit(s string) bool {
for _, r := range s {
if !(isAlpha(r) || r == '_' || r == ':' || isDigit(r)) {
return false
if isAlpha(r) || isDigit(r) || r == ':' || r == '_' {
continue
}
return false
}
return true
}
Expand Down
Loading