Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16ef97a

Browse files
authored
feat(cli): add DataDog Go tracer (#9411)
1 parent9ceba20 commit16ef97a

File tree

11 files changed

+156
-4
lines changed

11 files changed

+156
-4
lines changed

‎cli/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,7 @@ func ConfigureTraceProvider(
21052105
sdkTracerProvider,_closeTracing,err:=tracing.TracerProvider(ctx,"coderd", tracing.TracerOpts{
21062106
Default:cfg.Trace.Enable.Value(),
21072107
Coder:shouldCoderTrace,
2108+
DataDog:cfg.Trace.DataDog.Value(),
21082109
Honeycomb:cfg.Trace.HoneycombAPIKey.String(),
21092110
})
21102111
iferr!=nil {

‎cli/testdata/server-config.yaml.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ introspection:
201201
# which may incur significant costs.
202202
# (default: <unset>, type: bool)
203203
captureLogs: false
204+
# Enables sending Go runtime traces to the local DataDog agent.
205+
# (default: false, type: bool)
206+
dataDog: false
204207
logging:
205208
# Output debug-level logs.
206209
# (default: <unset>, type: bool)

‎coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/tracing/exporter.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import (
1313
"go.opentelemetry.io/otel/sdk/resource"
1414
sdktrace"go.opentelemetry.io/otel/sdk/trace"
1515
semconv"go.opentelemetry.io/otel/semconv/v1.14.0"
16+
ddotel"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry"
17+
ddtracer"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
18+
ddprofiler"gopkg.in/DataDog/dd-trace-go.v1/profiler"
19+
1620
"golang.org/x/xerrors"
1721
"google.golang.org/grpc/credentials"
1822
)
@@ -25,6 +29,8 @@ type TracerOpts struct {
2529
// Coder exports traces to Coder's public tracing ingest service and is used
2630
// to improve the product. It is disabled when opting out of telemetry.
2731
Coderbool
32+
// DataDog exports traces and profiles to the local DataDog daemon.
33+
DataDogbool
2834
// Exports traces to Honeycomb.io with the provided API key.
2935
Honeycombstring
3036
}
@@ -45,6 +51,35 @@ func TracerProvider(ctx context.Context, service string, opts TracerOpts) (*sdkt
4551
closers= []func(context.Context)error{}
4652
)
4753

54+
ifopts.DataDog {
55+
// See more:
56+
// https://docs.datadoghq.com/tracing/metrics/runtime_metrics/go/
57+
dd:=ddotel.NewTracerProvider(ddtracer.WithRuntimeMetrics())
58+
closers=append(closers,func(_ context.Context)error {
59+
// For some reason, this doesn't appear to actually wind down
60+
// the goroutines.
61+
returndd.Shutdown()
62+
})
63+
64+
// See https://docs.datadoghq.com/profiler/enabling/go/
65+
_=ddprofiler.Start(
66+
ddprofiler.WithService("coderd"),
67+
ddprofiler.WithProfileTypes(
68+
ddprofiler.CPUProfile,
69+
ddprofiler.HeapProfile,
70+
ddprofiler.GoroutineProfile,
71+
72+
// In the future, we may want to enable:
73+
// ddprofiler.BlockProfile,
74+
// ddprofiler.MutexProfile,
75+
),
76+
)
77+
closers=append(closers,func(_ context.Context)error {
78+
ddprofiler.Stop()
79+
returnnil
80+
})
81+
}
82+
4883
ifopts.Default {
4984
exporter,err:=DefaultExporter(ctx)
5085
iferr!=nil {

‎codersdk/deployment.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ type TraceConfig struct {
310310
Enable clibase.Bool`json:"enable" typescript:",notnull"`
311311
HoneycombAPIKey clibase.String`json:"honeycomb_api_key" typescript:",notnull"`
312312
CaptureLogs clibase.Bool`json:"capture_logs" typescript:",notnull"`
313+
DataDog clibase.Bool`json:"data_dog" typescript:",notnull"`
313314
}
314315

315316
typeGitAuthConfigstruct {
@@ -1237,6 +1238,22 @@ when required by your organization's security policy.`,
12371238
YAML:"captureLogs",
12381239
Annotations: clibase.Annotations{}.Mark(annotationExternalProxies,"true"),
12391240
},
1241+
{
1242+
Name:"Send Go runtime traces to DataDog",
1243+
Description:"Enables sending Go runtime traces to the local DataDog agent.",
1244+
Flag:"trace-datadog",
1245+
Env:"CODER_TRACE_DATADOG",
1246+
Value:&c.Trace.DataDog,
1247+
Group:&deploymentGroupIntrospectionTracing,
1248+
YAML:"dataDog",
1249+
// Hidden until an external user asks for it. For the time being,
1250+
// it's used to detect leaks in dogfood.
1251+
Hidden:true,
1252+
// Default is false because datadog creates a bunch of goroutines that
1253+
// don't get cleaned up and trip the leak detector.
1254+
Default:"false",
1255+
Annotations: clibase.Annotations{}.Mark(annotationExternalProxies,"true"),
1256+
},
12401257
// Provisioner settings
12411258
{
12421259
Name:"Provisioner Daemons",

‎docs/api/general.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/api/schemas.md

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎go.mod

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,22 @@ require (
196196
tailscale.comv1.46.1
197197
)
198198

199+
requiregopkg.in/DataDog/dd-trace-go.v1v1.54.0
200+
199201
require (
200202
cloud.google.com/go/computev1.23.0// indirect
201203
cloud.google.com/go/loggingv1.8.1// indirect
202204
cloud.google.com/go/longrunningv0.5.1// indirect
203205
filippo.io/edwards25519v1.0.0// indirect
204206
github.com/Azure/go-ansitermv0.0.0-20230124172434-306776ec8161// indirect
207+
github.com/DataDog/appsec-internal-gov1.0.0// indirect
208+
github.com/DataDog/datadog-agent/pkg/obfuscatev0.45.0-rc.1// indirect
209+
github.com/DataDog/datadog-agent/pkg/remoteconfig/statev0.48.0-devel.0.20230725154044-2549ba9058df// indirect
210+
github.com/DataDog/datadog-go/v5v5.1.1// indirect
211+
github.com/DataDog/go-libddwafv1.4.2// indirect
212+
github.com/DataDog/go-tufv1.0.1-0.5.2// indirect
213+
github.com/DataDog/gostackparsev0.5.0// indirect
214+
github.com/DataDog/sketches-gov1.2.1// indirect
205215
github.com/KyleBanks/depthv1.2.1// indirect
206216
github.com/Microsoft/go-winiov0.6.1// indirect
207217
github.com/Nvveen/Gottyv0.0.0-20120604004816-cd527374f1e5// indirect
@@ -247,11 +257,12 @@ require (
247257
github.com/docker/dockerv23.0.5+incompatible// indirect
248258
github.com/docker/go-connectionsv0.4.0// indirect
249259
github.com/docker/go-unitsv0.5.0// indirect
260+
github.com/dustin/go-humanizev1.0.1// indirect
261+
github.com/ebitengine/puregov0.5.0-alpha// indirect
250262
github.com/elastic/go-windowsv1.0.0// indirect
251263
github.com/fxamacker/cbor/v2v2.4.0// indirect
252264
github.com/gabriel-vasile/mimetypev1.4.2// indirect
253265
github.com/ghodss/yamlv1.0.0// indirect
254-
github.com/gin-gonic/ginv1.9.1// indirect
255266
github.com/go-chi/chiv1.5.4// indirect
256267
github.com/go-ini/iniv1.67.0// indirect
257268
github.com/go-logr/stdrv1.2.2// indirect
@@ -276,6 +287,7 @@ require (
276287
github.com/google/flatbuffersv23.1.21+incompatible// indirect
277288
github.com/google/go-querystringv1.1.0// indirect
278289
github.com/google/nftablesv0.1.1-0.20230115205135-9aa6fdf5a28c// indirect
290+
github.com/google/pprofv0.0.0-20230509042627-b1315fad0c5a// indirect
279291
github.com/google/s2a-gov0.1.5// indirect
280292
github.com/google/shlexv0.0.0-20191202100458-e7afc7fbc510// indirect
281293
github.com/googleapis/enterprise-certificate-proxyv0.2.5// indirect
@@ -335,16 +347,21 @@ require (
335347
github.com/opencontainers/go-digestv1.0.0// indirect
336348
github.com/opencontainers/image-specv1.1.0-rc4// indirect
337349
github.com/opencontainers/runcv1.1.5// indirect
350+
github.com/outcaste-io/ristrettov0.2.1// indirect
338351
github.com/pelletier/go-toml/v2v2.0.9// indirect
352+
github.com/philhofer/fwdv1.1.2// indirect
339353
github.com/pierrec/lz4/v4v4.1.17// indirect
340354
github.com/pion/transportv0.14.1// indirect
341355
github.com/pkg/errorsv0.9.1// indirect
342356
github.com/pmezard/go-difflibv1.0.0// indirect
343357
github.com/prometheus/procfsv0.10.1// indirect
344358
github.com/rcrowley/go-metricsv0.0.0-20200313005456-10cdbea86bc0// indirect
359+
github.com/richardartoul/moleculev1.0.1-0.20221107223329-32cfee06a052// indirect
345360
github.com/rivo/unisegv0.4.4// indirect
346361
github.com/satori/go.uuidv1.2.1-0.20181028125025-b2ce2384e17b// indirect
362+
github.com/secure-systems-lab/go-securesystemslibv0.7.0// indirect
347363
github.com/sirupsen/logrusv1.9.3// indirect
364+
github.com/spaolacci/murmur3v0.0.0-20180118202830-f09979ecbc72// indirect
348365
github.com/spf13/castv1.5.1// indirect
349366
github.com/swaggo/files/v2v2.0.0// indirect
350367
github.com/tadvi/systrayv0.0.0-20190226123456-11a2b8fa57af// indirect
@@ -357,13 +374,14 @@ require (
357374
github.com/tcnksm/go-httpstatv0.2.0// indirect
358375
github.com/tdewolff/parse/v2v2.6.6// indirect
359376
github.com/tdewolff/testv1.0.9// indirect
377+
github.com/tinylib/msgpv1.1.8// indirect
360378
github.com/u-root/uiov0.0.0-20230305220412-3e8cd9d6bf63// indirect
361379
github.com/ulikunitz/xzv0.5.11// indirect
362380
github.com/vishvananda/netlinkv1.2.1-beta.2// indirect
363381
github.com/vishvananda/netnsv0.0.4// indirect
364382
github.com/vmihailenco/msgpackv4.0.4+incompatible// indirect
365383
github.com/vmihailenco/msgpack/v4v4.3.12// indirect
366-
github.com/vmihailenco/tagparserv0.1.1// indirect
384+
github.com/vmihailenco/tagparserv0.1.2// indirect
367385
github.com/x448/float16v0.8.4// indirect
368386
github.com/xeipuuv/gojsonpointerv0.0.0-20190905194746-02993c407bfb// indirect
369387
github.com/xeipuuv/gojsonreferencev0.0.0-20180127040603-bd5ef7bd5415// indirect
@@ -378,7 +396,9 @@ require (
378396
go.opentelemetry.io/otel/exporters/otlp/internal/retryv1.16.0// indirect
379397
go.opentelemetry.io/otel/metricv1.16.0// indirect
380398
go.opentelemetry.io/proto/otlpv0.19.0// indirect
399+
go4.org/internv0.0.0-20211027215823-ae77deb06f29// indirect
381400
go4.org/memv0.0.0-20220726221520-4f986261bf13// indirect
401+
go4.org/unsafe/assume-no-moving-gcv0.0.0-20220617031537-928513b29760// indirect
382402
golang.zx2c4.com/wintunv0.0.0-20230126152724-0fa3db229ce2// indirect
383403
golang.zx2c4.com/wireguard/wgctrlv0.0.0-20230215201556-9c5414ab4bde// indirect
384404
golang.zx2c4.com/wireguard/windowsv0.5.3// indirect
@@ -388,5 +408,6 @@ require (
388408
google.golang.org/genproto/googleapis/rpcv0.0.0-20230807174057-1744710a1577// indirect
389409
gopkg.in/yaml.v2v2.4.0// indirect
390410
howett.net/plistv1.0.0// indirect
411+
inet.af/netaddrv0.0.0-20220811202034-502d2d690317// indirect
391412
inet.af/peercredv0.0.0-20210906144145-0893ea02156a// indirect
392413
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp