Skip to content

Commit 33dca70

Browse files
authored
feat: add datadog tracer (#387)
## Description Add tracing to track performance. Fixes #364 ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules - [x] I have checked my code and corrected any misspellings
2 parents 8448fae + fae2bb7 commit 33dca70

File tree

14 files changed

+325
-66
lines changed

14 files changed

+325
-66
lines changed

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func init() {
5757
rootCmd.PersistentFlags().Bool("datadog.statsd.enabled", false, `e.g. "true" or "false"`)
5858
rootCmd.PersistentFlags().String("datadog.statsd.url", "", `e.g. "localhost:8125"`)
5959
rootCmd.PersistentFlags().Float64(config.DataDogStatsdSampleRate, 1.0, `The sample rate to use for statsd metrics`)
60+
rootCmd.PersistentFlags().Bool("datadog.enable_tracing", false, `Enable Datadog APM tracing`)
6061

6162
rootCmd.PersistentFlags().Bool("prometheus.enabled", false, `e.g. "true" or "false"`)
6263
rootCmd.PersistentFlags().Int("prometheus.port", 2112, `The port to run the prometheus server on`)

cmd/run.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package cmd
33
import (
44
"context"
55
"fmt"
6+
"github.com/Layr-Labs/sidecar/internal/tracer"
7+
ddTracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
68
"log"
79
"time"
810

@@ -69,6 +71,14 @@ var runCmd = &cobra.Command{
6971
zap.String("chain", cfg.Chain.String()),
7072
)
7173

74+
if cfg.DataDogConfig.EnableTracing {
75+
l.Sugar().Info("DataDog tracing is enabled")
76+
} else {
77+
l.Sugar().Info("DataDog tracing is disabled, using mock tracer")
78+
}
79+
tracer.StartTracer(cfg.DataDogConfig.EnableTracing, cfg.Chain)
80+
defer ddTracer.Stop()
81+
7282
eb := eventBus.NewEventBus(l)
7383

7484
metricsClients, err := metrics.InitMetricsSinksFromConfig(cfg, l)

go.mod

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/google/uuid v1.6.0
1717
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
1818
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3
19-
github.com/jackc/pgx/v5 v5.5.5
19+
github.com/jackc/pgx/v5 v5.6.0
2020
github.com/jarcoal/httpmock v1.3.1
2121
github.com/lib/pq v1.10.9
2222
github.com/pkg/errors v0.9.1
@@ -28,19 +28,28 @@ require (
2828
github.com/spf13/pflag v1.0.6
2929
github.com/spf13/viper v1.20.0
3030
github.com/stretchr/testify v1.10.0
31-
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
31+
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d
3232
github.com/wealdtech/go-merkletree/v2 v2.6.1
3333
github.com/wk8/go-ordered-map/v2 v2.1.8
3434
go.uber.org/zap v1.27.0
3535
golang.org/x/mod v0.24.0
3636
google.golang.org/grpc v1.71.0
3737
google.golang.org/protobuf v1.36.6
38+
gopkg.in/DataDog/dd-trace-go.v1 v1.65.0
3839
gopkg.in/yaml.v3 v3.0.1
3940
gorm.io/driver/postgres v1.5.11
4041
gorm.io/gorm v1.25.12
4142
)
4243

4344
require (
45+
github.com/DataDog/appsec-internal-go v1.9.0 // indirect
46+
github.com/DataDog/datadog-agent/pkg/obfuscate v0.64.0-rc.1 // indirect
47+
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.64.0-rc.1 // indirect
48+
github.com/DataDog/go-libddwaf/v3 v3.5.3 // indirect
49+
github.com/DataDog/go-sqllexer v0.1.0 // indirect
50+
github.com/DataDog/go-tuf v1.1.0-0.5.2 // indirect
51+
github.com/DataDog/sketches-go v1.4.7 // indirect
52+
github.com/DataDog/zstd v1.5.6 // indirect
4453
github.com/Layr-Labs/protobuf-libs v0.0.0-20250305032038-8d1047b56aab // indirect
4554
github.com/Microsoft/go-winio v0.6.2 // indirect
4655
github.com/StackExchange/wmi v1.2.1 // indirect
@@ -58,14 +67,16 @@ require (
5867
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
5968
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
6069
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
70+
github.com/dustin/go-humanize v1.0.1 // indirect
71+
github.com/ebitengine/purego v0.8.2 // indirect
6172
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
6273
github.com/ethereum/go-verkle v0.2.2 // indirect
6374
github.com/fsnotify/fsnotify v1.8.0 // indirect
6475
github.com/go-ole/go-ole v1.3.0 // indirect
6576
github.com/go-resty/resty/v2 v2.7.0 // indirect
6677
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
6778
github.com/golang/protobuf v1.5.4 // indirect
68-
github.com/gorilla/websocket v1.4.2 // indirect
79+
github.com/gorilla/websocket v1.5.0 // indirect
6980
github.com/holiman/uint256 v1.3.2 // indirect
7081
github.com/iden3/go-iden3-crypto v0.0.16 // indirect
7182
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -79,33 +90,40 @@ require (
7990
github.com/mattn/go-colorable v0.1.13 // indirect
8091
github.com/mattn/go-isatty v0.0.20 // indirect
8192
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
82-
github.com/mitchellh/mapstructure v1.5.0 // indirect
93+
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
8394
github.com/mmcloughlin/addchain v0.4.0 // indirect
8495
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
96+
github.com/outcaste-io/ristretto v0.2.3 // indirect
8597
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
98+
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
8699
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
87100
github.com/prometheus/client_model v0.6.1 // indirect
88101
github.com/prometheus/common v0.62.0 // indirect
89102
github.com/prometheus/procfs v0.15.1 // indirect
90103
github.com/rivo/uniseg v0.4.7 // indirect
91104
github.com/rs/zerolog v1.33.0 // indirect
92105
github.com/sagikazarmark/locafero v0.7.0 // indirect
106+
github.com/secure-systems-lab/go-securesystemslib v0.9.0 // indirect
93107
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
94108
github.com/sourcegraph/conc v0.3.0 // indirect
95109
github.com/spf13/afero v1.12.0 // indirect
96110
github.com/spf13/cast v1.7.1 // indirect
97111
github.com/subosito/gotenv v1.6.0 // indirect
98112
github.com/supranational/blst v0.3.14 // indirect
99-
github.com/tklauser/go-sysconf v0.3.12 // indirect
100-
github.com/tklauser/numcpus v0.6.1 // indirect
101-
go.uber.org/multierr v1.10.0 // indirect
102-
golang.org/x/crypto v0.35.0 // indirect
103-
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
104-
golang.org/x/net v0.35.0 // indirect
105-
golang.org/x/sync v0.11.0 // indirect
106-
golang.org/x/sys v0.30.0 // indirect
107-
golang.org/x/term v0.29.0 // indirect
108-
golang.org/x/text v0.22.0 // indirect
113+
github.com/tinylib/msgp v1.2.5 // indirect
114+
github.com/tklauser/go-sysconf v0.3.14 // indirect
115+
github.com/tklauser/numcpus v0.8.0 // indirect
116+
go.uber.org/atomic v1.11.0 // indirect
117+
go.uber.org/multierr v1.11.0 // indirect
118+
golang.org/x/crypto v0.36.0 // indirect
119+
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
120+
golang.org/x/net v0.37.0 // indirect
121+
golang.org/x/sync v0.12.0 // indirect
122+
golang.org/x/sys v0.31.0 // indirect
123+
golang.org/x/term v0.30.0 // indirect
124+
golang.org/x/text v0.23.0 // indirect
125+
golang.org/x/time v0.9.0 // indirect
126+
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
109127
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
110128
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
111129
rsc.io/tmplfunc v0.0.3 // indirect

0 commit comments

Comments
 (0)