Skip to content

Commit

Permalink
feat: Improved instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bcessa committed Jul 11, 2023
1 parent 10f6de6 commit 199d96b
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 178 deletions.
55 changes: 20 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ on:
pull_request:
branches:
- master
- main
workflow_dispatch: {}
jobs:
# Scan direct Go dependencies for known vulnerabilities
scan:
name: scan for vulnerabilities
runs-on: ubuntu-latest
steps:
# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# Checkout code
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -30,6 +25,12 @@ jobs:
GITHUB_USER: ${{ github.actor }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}

# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# Get commit message
- name: Get commit message
run: |
Expand All @@ -55,12 +56,6 @@ jobs:
needs: scan
runs-on: ubuntu-latest
steps:
# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# Checkout code
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -71,7 +66,13 @@ jobs:
env:
GITHUB_USER: ${{ github.actor }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}


# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# Get commit message
- name: Get commit message
run: |
Expand Down Expand Up @@ -116,12 +117,6 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

# Checkout code
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -133,25 +128,19 @@ jobs:
GITHUB_USER: ${{ github.actor }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}

# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

# Get commit message
- name: Get commit message
run: |
echo 'commit_msg<<EOF' >> $GITHUB_ENV
git log --format=%B -n 1 ${{ github.sha }} >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# If "vendor" is in cache, restore.
# To run conditional steps use:
# if: steps.vendor-cache.outputs.cache-hit != 'true'
- name: Restore modules from cache
id: vendor-cache
uses: actions/cache@v3
env:
cache-name: vendor
with:
path: ./vendor
key: ${{ env.cache-name }}-${{ hashFiles('go.sum') }}

# Style consistency and static analysis using 'golangci-lint'
# https://github.com/marketplace/actions/run-golangci-lint
- name: Static analysis
Expand All @@ -174,7 +163,3 @@ jobs:
name: assets
path: |
coverage.html
# Populate vendor cache to speed up future runs
- name: Populate vendor cache
run: go mod vendor
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
branches:
- master
- main
workflow_dispatch: {}
jobs:
# Semantic code analysis to discover vulnerabilities in the codebase
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ jobs:
timeout-minutes: 10
if: startsWith(github.ref, 'refs/tags/')
steps:
# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# Checkout code
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -31,17 +25,11 @@ jobs:
GITHUB_USER: ${{ github.actor }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}

# If "vendor" is in cache, restore.
# To run conditional steps use:
# if: steps.vendor-cache.outputs.cache-hit != 'true'
- name: Restore modules from cache
id: vendor-cache
uses: actions/cache@v3
env:
cache-name: vendor
# Go
- name: Set up Go
uses: actions/setup-go@v4
with:
path: ./vendor
key: ${{ env.cache-name }}-${{ hashFiles('go.sum') }}
go-version: 1.20.x

# Use goreleaser to create the new release
# https://github.com/goreleaser/goreleaser-action
Expand Down
20 changes: 11 additions & 9 deletions client/internal/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,17 @@ func (s *Settings) OTEL(log xlog.Logger) []otel.OperatorOption {
}

// Error reporter
if sentryInfo := s.Agent.OTEL.Sentry; sentryInfo.DSN != "" {
rep, err := sentry.Reporter(sentryInfo.DSN, sentryInfo.Env, s.ReleaseCode())
if sentryOpts := s.Agent.OTEL.Sentry; sentryOpts.DSN != "" {
if sentryOpts.Release == "" {
sentryOpts.Release = s.ReleaseCode()
}
rep, err := sentry.NewReporter(sentryOpts)
if err == nil {
opts = append(opts, otel.WithErrorReporter(rep))
opts = append(opts,
otel.WithPropagator(rep.Propagator()),
otel.WithSpanProcessor(rep.SpanProcessor()),
otel.WithSpanInterceptor(rep),
)
}
}
return opts
Expand Down Expand Up @@ -308,12 +315,7 @@ type otelSettings struct {
Collector string `json:"collector" yaml:"collector" mapstructure:"collector"`
LogJSON bool `json:"log_json" yaml:"log_json" mapstructure:"log_json"`
Attributes map[string]interface{} `json:"attributes" yaml:"attributes" mapstructure:"attributes"`
Sentry *sentrySettings `json:"sentry" yaml:"sentry" mapstructure:"sentry"`
}

type sentrySettings struct {
DSN string `json:"dsn" yaml:"dsn" mapstructure:"dsn"`
Env string `json:"environment" yaml:"environment" mapstructure:"environment"`
Sentry *sentry.Options `json:"sentry" yaml:"sentry" mapstructure:"sentry"`
}

type rpcSettings struct {
Expand Down
70 changes: 35 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ require (
github.com/kennygrant/sanitize v1.2.4
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
go.bryk.io/pkg v0.0.0-20230602181453-6633b1406359
go.mongodb.org/mongo-driver v1.11.6
golang.org/x/crypto v0.9.0
go.bryk.io/pkg v0.0.0-20230711012017-8e69ce8ebd62
go.mongodb.org/mongo-driver v1.12.0
golang.org/x/crypto v0.11.0
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
google.golang.org/grpc v1.56.2
google.golang.org/protobuf v1.31.0
)

require (
Expand All @@ -26,7 +26,8 @@ require (
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/getsentry/sentry-go v0.21.0 // indirect
github.com/getsentry/sentry-go v0.22.0 // indirect
github.com/getsentry/sentry-go/otel v0.22.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand All @@ -42,24 +43,23 @@ require (
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/piprate/json-gold v0.5.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rs/zerolog v1.29.1 // indirect
github.com/shirou/gopsutil/v3 v3.23.3 // indirect
github.com/shoenig/go-m1cpu v0.1.4 // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/shirou/gopsutil/v3 v3.23.4 // indirect
github.com/shoenig/go-m1cpu v0.1.5 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
Expand All @@ -74,31 +74,31 @@ require (
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.bryk.io/miracl v0.5.1 // indirect
go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo v0.41.1 // indirect
go.opentelemetry.io/contrib/instrumentation/host v0.41.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.41.1 // indirect
go.opentelemetry.io/contrib/instrumentation/runtime v0.41.1 // indirect
go.opentelemetry.io/otel v1.15.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.15.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.38.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.38.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.15.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.15.1 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.38.1 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.1 // indirect
go.opentelemetry.io/otel/metric v0.38.1 // indirect
go.opentelemetry.io/otel/sdk v1.15.1 // indirect
go.opentelemetry.io/otel/sdk/metric v0.38.1 // indirect
go.opentelemetry.io/otel/trace v1.15.1 // indirect
go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo v0.42.0 // indirect
go.opentelemetry.io/contrib/instrumentation/host v0.42.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect
go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.39.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/sdk v1.16.0 // indirect
go.opentelemetry.io/otel/sdk/metric v0.39.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
Expand Down
Loading

0 comments on commit 199d96b

Please sign in to comment.