Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Filter grpc healthchecks from otel traces (#40)
Browse files Browse the repository at this point in the history
This PR should make it so grpc healthchecks are filtered and not traced. We're using a fairly significant amount of Honeycomb capacity on these traces. ~~This should also provide a pattern for excluding these grpc healthchecks from other services using otelgrpc tracing.~~

Turns out `UnaryClientInterceptor` is deprecated and we are to use `NewClientHandler` instead. This is not a simple change and I'm hoping to avoid making it for cacher.
  • Loading branch information
mmlb authored Dec 1, 2023
2 parents 471c8d4 + 1a29b78 commit 0346462
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 148 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ jobs:
CGO_ENABLED: 0
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: '1.18'
go-version: '1.21'
- name: goimports
run: go get golang.org/x/tools/cmd/goimports && goimports -d . | (! grep .)
# Workaround for missing checksums caused by https://github.com/golang/go/issues/44129
- name: gomod fix
run: go env -w GOFLAGS=-mod=mod
- name: go mod tidy
run: go mod tidy
- name: lint
run: make lint
- name: tests
Expand All @@ -34,11 +36,11 @@ jobs:
needs: [validation]
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: '1.18'
go-version: '1.21'
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ linters-settings:
- name: waitgroup-by-value

staticcheck:
go: "1.18"
go: "1.21"

unused:
go: "1.18"
go: "1.21"

output:
sort-results: true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18-alpine as builder
FROM golang:1.21-alpine as builder
RUN apk add --update make
ADD ./ /src
WORKDIR /src
Expand Down
4 changes: 3 additions & 1 deletion client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/packethost/pkg/env"
"github.com/pkg/errors"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/filters"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
Expand All @@ -20,7 +21,8 @@ import (
func connect(facility string) (*grpc.ClientConn, error) {
// setup OpenTelemetry autoinstrumentation automatically on the gRPC client
dialOpts := []grpc.DialOption{
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()),
//nolint:staticcheck // UnaryClientInterceptor is deprecated but requires refactor
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor(otelgrpc.WithInterceptorFilter(filters.Not(filters.HealthCheck())))),
}

useTLS := env.Bool("CACHER_USE_TLS", true)
Expand Down
88 changes: 44 additions & 44 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
module github.com/packethost/cacher

go 1.18
go 1.21

require (
github.com/equinix-labs/otel-init-go v0.0.7
github.com/gammazero/workerpool v0.0.0-20200311205957-7b00833861c6
github.com/google/uuid v1.3.0
github.com/packethost/packngo v0.1.1-0.20180510203711-dff6ec250ba6
github.com/packethost/pkg v0.0.0-20211110202003-387414657e83
github.com/equinix-labs/otel-init-go v0.0.9
github.com/gammazero/workerpool v1.1.3
github.com/google/uuid v1.4.0
github.com/packethost/packngo v0.30.0
github.com/packethost/pkg v0.0.0-20230710142318-f8a288cd3046
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_golang v1.17.0
github.com/satori/go.uuid v1.2.0
github.com/spf13/cobra v1.0.1-0.20200713175500-884edc58ad08
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.4
github.com/tinkerbell/boots v0.0.0-20201111172111-e81a291c4d02
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.22.0
go.opentelemetry.io/otel v1.11.2
go.opentelemetry.io/otel/trace v1.11.2
google.golang.org/grpc v1.52.0
google.golang.org/protobuf v1.28.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
go.opentelemetry.io/otel v1.21.0
go.opentelemetry.io/otel/trace v1.21.0
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
gopkg.in/h2non/gock.v1 v1.0.14
inet.af/netaddr v0.0.0-20200430175045-5aaf2097c7fc
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/gammazero/deque v0.0.0-20200227231300-1e9af0e52b46 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/gammazero/deque v0.2.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.31.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rollbar/rollbar-go v1.4.2 // indirect
github.com/rollbar/rollbar-go/errors v0.0.0-20210929193720-32947096267e // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rollbar/rollbar-go v1.4.5 // indirect
github.com/rollbar/rollbar-go/errors v0.0.0-20220927065624-ed38c7c74ef6 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tinkerbell/tink v0.0.0-20201109122352-0e8e57332303 // indirect
go.opentelemetry.io/contrib v0.22.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 // indirect
go.opentelemetry.io/otel/internal/metric v0.22.0 // indirect
go.opentelemetry.io/otel/metric v0.22.0 // indirect
go.opentelemetry.io/otel/sdk v1.11.2 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 0346462

Please sign in to comment.