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
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Go CI

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Go ${{ matrix.go-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ["stable", "oldstable"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- name: Check formatting
run: |
unformatted="$(gofmt -l .)"
if [ -n "$unformatted" ]; then
printf 'Run gofmt on:\n%s\n' "$unformatted"
exit 1
fi
- name: Check module tidiness
if: matrix.go-version == 'stable'
run: go mod tidy -diff
- name: Test
run: go test -race -timeout=10s ./...
- name: Vet
run: go vet ./...
- name: Build
run: go build ./...
- name: Lint
if: matrix.go-version == 'stable'
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.15.0
36 changes: 36 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Lint PR Title

on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
security
subjectPattern: '^[a-z].+$'
subjectPatternError: 'The description must start with a lowercase letter.'
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ This is a fork of a [dead statsd client project](https://github.com/alexcesaro/s

## Download

go get github.com/multiplay/statsd
go get github.com/rocketsciencegg/statsd/v2

Import the v2 module in your Go code:

```go
import "github.com/rocketsciencegg/statsd/v2"
```

## License

Expand Down
12 changes: 5 additions & 7 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/*
Package statsd is a simple and efficient StatsD client.


Options
# Options

Use options to configure the Client: target host/port, sampling rate, tags, etc.

Expand All @@ -12,13 +11,12 @@ rate), you should use the Clone() method of the Client.
Because when cloning a Client, the same connection is reused so this is way
cheaper and more efficient than creating another Client using New().


Internals
# Internals

Client's methods buffer metrics. The buffer is flushed when either:
- the background goroutine flushes the buffer (every 100ms by default)
- the buffer is full (1440 bytes by default so that IP packets are not
fragmented)
- the background goroutine flushes the buffer (every 100ms by default)
- the buffer is full (1440 bytes by default so that IP packets are not
fragmented)

The background goroutine can be disabled using the FlushPeriod(0) option.

Expand Down
2 changes: 1 addition & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime"
"time"

"github.com/multiplay/statsd"
"github.com/rocketsciencegg/statsd/v2"
)

var (
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/rocketsciencegg/statsd/v2

go 1.16
5 changes: 2 additions & 3 deletions statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"io"
"io/ioutil"
"net"
"sync"
"testing"
Expand Down Expand Up @@ -203,7 +202,7 @@ func TestOddTagsArgs(t *testing.T) {
}
}()

_, _ = New(TagsFormat(InfluxDB), Tags("tag1"))
_, _ = New(TagsFormat(InfluxDB), Tags("tag1")) //nolint:staticcheck // Intentionally pass an odd tag count to test the panic.
t.Fatal("A panic should occur")
}

Expand Down Expand Up @@ -519,7 +518,7 @@ func newServer(t testing.TB, network, addr string, f func([]byte)) *server {
s.closed <- true
return
}
p, err := ioutil.ReadAll(conn)
p, err := io.ReadAll(conn)
if err != nil {
t.Fatal(err)
}
Expand Down
Loading