Skip to content

Commit

Permalink
Update the statsd client. (stripe#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavdugar-stripe authored Jan 23, 2023
1 parent 6ef5d2a commit 5f7009c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
16 changes: 16 additions & 0 deletions cmd/veneur/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"os"

"github.com/DataDog/datadog-go/statsd"
"github.com/getsentry/sentry-go"
"github.com/sirupsen/logrus"
"github.com/stripe/veneur/v14"
Expand Down Expand Up @@ -81,6 +82,20 @@ func main() {
os.Exit(0)
}

stats, err := statsd.New(
config.StatsAddress,
statsd.WithAggregationInterval(config.Interval),
statsd.WithChannelMode(),
statsd.WithChannelModeBufferSize(4096),
statsd.WithClientSideAggregation(),
statsd.WithMaxMessagesPerPayload(4096),
statsd.WithNamespace("veneur."),
statsd.WithoutTelemetry(),
)
if err != nil {
logger.WithError(err).Fatal("failed to create statsd client")
}

server, err := veneur.NewFromConfig(veneur.ServerConfig{
Config: *config,
Logger: logger,
Expand Down Expand Up @@ -167,6 +182,7 @@ func main() {
w.Write([]byte("hello world!\n"))
},
},
Statsd: stats,
})
if err != nil {
logger.WithError(err).Fatal("Could not initialize server")
Expand Down
11 changes: 3 additions & 8 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type ServerConfig struct {
SourceTypes SourceTypes
SpanSinkTypes SpanSinkTypes
HttpCustomHandlers HttpCustomHandlers
Statsd *statsd.Client
}

// A Server is the actual veneur instance that will be run.
Expand Down Expand Up @@ -507,20 +508,14 @@ func NewFromConfig(config ServerConfig) (*Server, error) {
}
ret.HistogramAggregates.Count = len(conf.Aggregates)

stats, err := statsd.New(conf.StatsAddress, statsd.WithoutTelemetry(), statsd.WithMaxMessagesPerPayload(4096))
if err != nil {
return ret, err
}
stats.Namespace = "veneur."

scopes, err := scopesFromConfig(conf)
if err != nil {
return ret, err
}
ret.Statsd = scopedstatsd.NewClient(stats, conf.VeneurMetricsAdditionalTags, scopes)
ret.Statsd = scopedstatsd.NewClient(config.Statsd, conf.VeneurMetricsAdditionalTags, scopes)

ret.TraceClient, err = trace.NewChannelClient(ret.SpanChan,
trace.ReportStatistics(stats, 1*time.Second, []string{"ssf_format:internal"}),
trace.ReportStatistics(config.Statsd, 1*time.Second, []string{"ssf_format:internal"}),
normalizeSpans(conf),
)
if err != nil {
Expand Down

0 comments on commit 5f7009c

Please sign in to comment.