- Notifications
You must be signed in to change notification settings - Fork928
feat(cli): add DataDog Go tracer#9411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,6 +13,10 @@ import ( | ||
"go.opentelemetry.io/otel/sdk/resource" | ||
sdktrace"go.opentelemetry.io/otel/sdk/trace" | ||
semconv"go.opentelemetry.io/otel/semconv/v1.14.0" | ||
ddotel"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentelemetry" | ||
ddtracer"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" | ||
ddprofiler"gopkg.in/DataDog/dd-trace-go.v1/profiler" | ||
"golang.org/x/xerrors" | ||
"google.golang.org/grpc/credentials" | ||
) | ||
@@ -25,6 +29,8 @@ type TracerOpts struct { | ||
// Coder exports traces to Coder's public tracing ingest service and is used | ||
// to improve the product. It is disabled when opting out of telemetry. | ||
Coderbool | ||
// DataDog exports traces and profiles to the local DataDog daemon. | ||
DataDogbool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Should add a comment | ||
// Exports traces to Honeycomb.io with the provided API key. | ||
Honeycombstring | ||
} | ||
@@ -45,6 +51,35 @@ func TracerProvider(ctx context.Context, service string, opts TracerOpts) (*sdkt | ||
closers= []func(context.Context)error{} | ||
) | ||
ifopts.DataDog { | ||
// See more: | ||
// https://docs.datadoghq.com/tracing/metrics/runtime_metrics/go/ | ||
dd:=ddotel.NewTracerProvider(ddtracer.WithRuntimeMetrics()) | ||
closers=append(closers,func(_ context.Context)error { | ||
// For some reason, this doesn't appear to actually wind down | ||
// the goroutines. | ||
returndd.Shutdown() | ||
}) | ||
coadler marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
// See https://docs.datadoghq.com/profiler/enabling/go/ | ||
_=ddprofiler.Start( | ||
ddprofiler.WithService("coderd"), | ||
ddprofiler.WithProfileTypes( | ||
ddprofiler.CPUProfile, | ||
ddprofiler.HeapProfile, | ||
ddprofiler.GoroutineProfile, | ||
// In the future, we may want to enable: | ||
// ddprofiler.BlockProfile, | ||
// ddprofiler.MutexProfile, | ||
), | ||
) | ||
closers=append(closers,func(_ context.Context)error { | ||
ddprofiler.Stop() | ||
returnnil | ||
}) | ||
} | ||
ifopts.Default { | ||
exporter,err:=DefaultExporter(ctx) | ||
iferr!=nil { | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.