dd-trace-go

module
v1.66.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0

README

Main Branch and Release Tests System Tests CodeQL APM Parametric Tests codecov

Godoc

Datadog Client Libraries for Go

This repository contains Go packages for the client-side components of the Datadog product suite for Application Performance Monitoring, Continuous Profiling and Application Security Monitoring of Go applications.

  • Datadog Application Performance Monitoring (APM): Trace requests as they flow across web servers, databases and microservices so that developers have great visiblity into bottlenecks and troublesome requests. The package gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer allows you to trace any piece of your Go code, and commonly used Go libraries can be automatically traced thanks to our out-of-the-box integrations which can be found in the package gopkg.in/DataDog/dd-trace-go.v1/ddtrace/contrib.

  • Datadog Go Continuous Profiler: Continuously profile your Go apps to find CPU, memory, and synchronization bottlenecks, broken down by function name, and line number, to significantly reduce end-user latency and infrastructure costs. The package gopkg.in/DataDog/dd-trace-go.v1/profiler allows you to periodically collect and send Go profiles to the Datadog API.

  • Datadog Application Security Management (ASM) provides in-app monitoring and protection against application-level attacks that aim to exploit code-level vulnerabilities, such as a Server-Side-Request-Forgery (SSRF), a SQL injection (SQLi), or Reflected Cross-Site-Scripting (XSS). ASM identifies services exposed to application attacks and leverages in-app security rules to detect and protect against threats in your application environment. ASM is not a standalone Go package and is transparently integrated into the APM tracer. You can simply enable it with DD_APPSEC_ENABLED=true.

Installing

This module contains many packages, but most users should probably install the two packages below:

go get gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer
go get gopkg.in/DataDog/dd-trace-go.v1/profiler

Additionally there are many contrib packages that can be installed to automatically instrument and trace commonly used Go libraries such as net/http, gorilla/mux or database/sql:

go get gopkg.in/DataDog/dd-trace-go.v1/contrib/gorilla/mux

If you installed more packages than you intended, you can use go mod tidy to remove any unused packages.

Documentation

Go Support Policy

Datadog APM for Go is built upon dependencies defined in specific versions of the host operating system, Go releases, and the Datadog Agent/API. dd-trace-go supports the two latest releases of Go, matching the official Go policy. This library only officially supports first class ports of Go.

Contributing

Before considering contributions to the project, please take a moment to read our brief contribution guidelines.

Testing

Tests can be run locally using the Go toolset. The grpc.v12 integration will fail (and this is normal), because it covers for deprecated methods. In the CI environment we vendor this version of the library inside the integration. Under normal circumstances this is not something that we want to do, because users using this integration might be running versions different from the vendored one, creating hard to debug conflicts.

To run integration tests locally, you should set the INTEGRATION environment variable. The dependencies of the integration tests are best run via Docker. To get an idea about the versions and the set-up take a look at our docker-compose config.

The best way to run the entire test suite is using the test.sh script. You'll need Docker and docker-compose installed. If this is your first time running the tests, you should run ./test.sh -t to install any missing test tools/dependencies. Run ./test.sh --all to run all of the integration tests through the docker-compose environment. Run ./test.sh --help for more options.

If you're only interested in the tests for a specific integration it can be useful to spin up just the required containers via docker-compose. For example if you're running tests that need the mysql database container to be up:

docker compose -f docker-compose.yaml -p dd-trace-go up -d mysql

Directories

Path Synopsis
Package appsec provides application security features in the form of SDK functions that can be manually called to monitor specific code paths and data.
Package appsec provides application security features in the form of SDK functions that can be manually called to monitor specific code paths and data.
events
Package events provides security event types that appsec can return in function calls it monitors when blocking them.
Package events provides security event types that appsec can return in function calls it monitors when blocking them.
contrib
99designs/gqlgen
Package gqlgen contains an implementation of a gqlgen tracer, and functions to construct and configure the tracer.
Package gqlgen contains an implementation of a gqlgen tracer, and functions to construct and configure the tracer.
IBM/sarama.v1
Package sarama provides functions to trace the IBM/sarama package (https://github.com/IBM/sarama).
Package sarama provides functions to trace the IBM/sarama package (https://github.com/IBM/sarama).
Shopify/sarama
Package sarama provides functions to trace the Shopify/sarama package (https://github.com/Shopify/sarama).
Package sarama provides functions to trace the Shopify/sarama package (https://github.com/Shopify/sarama).
aws/aws-sdk-go-v2/aws
Package aws provides functions to trace aws/aws-sdk-go-v2 (https://github.com/aws/aws-sdk-go-v2).
Package aws provides functions to trace aws/aws-sdk-go-v2 (https://github.com/aws/aws-sdk-go-v2).
aws/aws-sdk-go/aws
Package aws provides functions to trace aws/aws-sdk-go (https://github.com/aws/aws-sdk-go).
Package aws provides functions to trace aws/aws-sdk-go (https://github.com/aws/aws-sdk-go).
bradfitz/gomemcache/memcache
Package memcache provides functions to trace the bradfitz/gomemcache package (https://github.com/bradfitz/gomemcache).
Package memcache provides functions to trace the bradfitz/gomemcache package (https://github.com/bradfitz/gomemcache).
cloud.google.com/go/pubsub.v1
Package pubsub provides functions to trace the cloud.google.com/pubsub/go package.
Package pubsub provides functions to trace the cloud.google.com/pubsub/go package.
confluentinc/confluent-kafka-go/kafka
Package kafka provides functions to trace the confluentinc/confluent-kafka-go package (https://github.com/confluentinc/confluent-kafka-go).
Package kafka provides functions to trace the confluentinc/confluent-kafka-go package (https://github.com/confluentinc/confluent-kafka-go).
confluentinc/confluent-kafka-go/kafka.v2
Package kafka provides functions to trace the confluentinc/confluent-kafka-go package (https://github.com/confluentinc/confluent-kafka-go).
Package kafka provides functions to trace the confluentinc/confluent-kafka-go package (https://github.com/confluentinc/confluent-kafka-go).
database/sql
Package sql provides functions to trace the database/sql package (https://golang.org/pkg/database/sql).
Package sql provides functions to trace the database/sql package (https://golang.org/pkg/database/sql).
dimfeld/httptreemux.v5
Package httptreemux provides functions to trace the dimfeld/httptreemux/v5 package (https://github.com/dimfeld/httptreemux).
Package httptreemux provides functions to trace the dimfeld/httptreemux/v5 package (https://github.com/dimfeld/httptreemux).
elastic/go-elasticsearch.v6
Package elastic provides functions to trace the github.com/elastic/go-elasticsearch packages.
Package elastic provides functions to trace the github.com/elastic/go-elasticsearch packages.
emicklei/go-restful
Package restful provides functions to trace the emicklei/go-restful package (https://github.com/emicklei/go-restful).
Package restful provides functions to trace the emicklei/go-restful package (https://github.com/emicklei/go-restful).
emicklei/go-restful.v3
Package restful provides functions to trace the emicklei/go-restful package (https://github.com/emicklei/go-restful).
Package restful provides functions to trace the emicklei/go-restful package (https://github.com/emicklei/go-restful).
garyburd/redigo
Package redigo provides functions to trace the garyburd/redigo package (https://github.com/garyburd/redigo).
Package redigo provides functions to trace the garyburd/redigo package (https://github.com/garyburd/redigo).
gin-gonic/gin
Package gin provides functions to trace the gin-gonic/gin package (https://github.com/gin-gonic/gin).
Package gin provides functions to trace the gin-gonic/gin package (https://github.com/gin-gonic/gin).
globalsign/mgo
Package mgo provides functions and types which allow tracing of the MGO MongoDB client (https://github.com/globalsign/mgo)
Package mgo provides functions and types which allow tracing of the MGO MongoDB client (https://github.com/globalsign/mgo)
go-chi/chi
Package chi provides tracing functions for tracing the go-chi/chi package (https://github.com/go-chi/chi).
Package chi provides tracing functions for tracing the go-chi/chi package (https://github.com/go-chi/chi).
go-chi/chi.v5
Package chi provides tracing functions for tracing the go-chi/chi/v5 package (https://github.com/go-chi/chi).
Package chi provides tracing functions for tracing the go-chi/chi/v5 package (https://github.com/go-chi/chi).
go-redis/redis
Package redis provides tracing functions for tracing the go-redis/redis package (https://github.com/go-redis/redis).
Package redis provides tracing functions for tracing the go-redis/redis package (https://github.com/go-redis/redis).
go-redis/redis.v7
Package redis provides tracing functions for tracing the go-redis/redis package (https://github.com/go-redis/redis).
Package redis provides tracing functions for tracing the go-redis/redis package (https://github.com/go-redis/redis).
go-redis/redis.v8
Package redis provides tracing functions for tracing the go-redis/redis package (https://github.com/go-redis/redis).
Package redis provides tracing functions for tracing the go-redis/redis package (https://github.com/go-redis/redis).
go.mongodb.org/mongo-driver/mongo
Package mongo provides functions to trace the mongodb/mongo-go-driver package (https://github.com/mongodb/mongo-go-driver).
Package mongo provides functions to trace the mongodb/mongo-go-driver package (https://github.com/mongodb/mongo-go-driver).
gocql/gocql
Package gocql provides functions to trace the gocql/gocql package (https://github.com/gocql/gocql).
Package gocql provides functions to trace the gocql/gocql package (https://github.com/gocql/gocql).
gofiber/fiber.v2
Package fiber provides tracing functions for tracing the fiber package (https://github.com/gofiber/fiber).
Package fiber provides tracing functions for tracing the fiber package (https://github.com/gofiber/fiber).
gomodule/redigo
Package redigo provides functions to trace the gomodule/redigo package (https://github.com/gomodule/redigo).
Package redigo provides functions to trace the gomodule/redigo package (https://github.com/gomodule/redigo).
google.golang.org/api
Package api provides functions to trace the google.golang.org/api package.
Package api provides functions to trace the google.golang.org/api package.
google.golang.org/grpc
Package grpc provides functions to trace the google.golang.org/grpc package v1.2.
Package grpc provides functions to trace the google.golang.org/grpc package v1.2.
google.golang.org/grpc.v12
Package grpc is a generated protocol buffer package.
Package grpc is a generated protocol buffer package.
gopkg.in/jinzhu/gorm.v1
Package gorm provides helper functions for tracing the jinzhu/gorm package (https://github.com/jinzhu/gorm).
Package gorm provides helper functions for tracing the jinzhu/gorm package (https://github.com/jinzhu/gorm).
gorilla/mux
Package mux provides tracing functions for tracing the gorilla/mux package (https://github.com/gorilla/mux).
Package mux provides tracing functions for tracing the gorilla/mux package (https://github.com/gorilla/mux).
gorm.io/gorm.v1
Package gorm provides helper functions for tracing the gorm.io/gorm package (https://github.com/go-gorm/gorm).
Package gorm provides helper functions for tracing the gorm.io/gorm package (https://github.com/go-gorm/gorm).
graph-gophers/graphql-go
Package graphql provides functions to trace the graph-gophers/graphql-go package (https://github.com/graph-gophers/graphql-go).
Package graphql provides functions to trace the graph-gophers/graphql-go package (https://github.com/graph-gophers/graphql-go).
hashicorp/vault
Package vault contains functions to construct or augment an http.Client that will integrate with the github.com/hashicorp/vault/api and collect traces to send to Datadog.
Package vault contains functions to construct or augment an http.Client that will integrate with the github.com/hashicorp/vault/api and collect traces to send to Datadog.
internal/httptrace
Package httptrace provides functionalities to trace HTTP requests that are commonly required and used across contrib/** integrations.
Package httptrace provides functionalities to trace HTTP requests that are commonly required and used across contrib/** integrations.
internal/namingschematest
Package namingschematest provides utilities to test naming schemas across different integrations.
Package namingschematest provides utilities to test naming schemas across different integrations.
jinzhu/gorm
Package gorm provides helper functions for tracing the jinzhu/gorm package (https://github.com/jinzhu/gorm).
Package gorm provides helper functions for tracing the jinzhu/gorm package (https://github.com/jinzhu/gorm).
jmoiron/sqlx
Package sqlx provides functions to trace the jmoiron/sqlx package (https://github.com/jmoiron/sqlx).
Package sqlx provides functions to trace the jmoiron/sqlx package (https://github.com/jmoiron/sqlx).
julienschmidt/httprouter
Package httprouter provides functions to trace the julienschmidt/httprouter package (https://github.com/julienschmidt/httprouter).
Package httprouter provides functions to trace the julienschmidt/httprouter package (https://github.com/julienschmidt/httprouter).
k8s.io/client-go/kubernetes
Package kubernetes provides functions to trace k8s.io/client-go (https://github.com/kubernetes/client-go).
Package kubernetes provides functions to trace k8s.io/client-go (https://github.com/kubernetes/client-go).
labstack/echo
Package echo provides functions to trace the labstack/echo package (https://github.com/labstack/echo).
Package echo provides functions to trace the labstack/echo package (https://github.com/labstack/echo).
labstack/echo.v4
Package echo provides functions to trace the labstack/echo package (https://github.com/labstack/echo).
Package echo provides functions to trace the labstack/echo package (https://github.com/labstack/echo).
log/slog
Package slog provides functions to correlate logs and traces using log/slog package (https://pkg.go.dev/log/slog).
Package slog provides functions to correlate logs and traces using log/slog package (https://pkg.go.dev/log/slog).
net/http
Package http provides functions to trace the net/http package (https://golang.org/pkg/net/http).
Package http provides functions to trace the net/http package (https://golang.org/pkg/net/http).
olivere/elastic
Package elastic provides functions to trace the gopkg.in/olivere/elastic.v{3,5} packages.
Package elastic provides functions to trace the gopkg.in/olivere/elastic.v{3,5} packages.
redis/go-redis.v9
Package redis provides functions to trace the redis/go-redis package (https://github.com/redis/go-redis).
Package redis provides functions to trace the redis/go-redis package (https://github.com/redis/go-redis).
sirupsen/logrus
Package logrus provides a log/span correlation hook for the sirupsen/logrus package (https://github.com/sirupsen/logrus).
Package logrus provides a log/span correlation hook for the sirupsen/logrus package (https://github.com/sirupsen/logrus).
syndtr/goleveldb/leveldb
Package leveldb provides functions to trace the syndtr/goleveldb package (https://github.com/syndtr/goleveldb).
Package leveldb provides functions to trace the syndtr/goleveldb package (https://github.com/syndtr/goleveldb).
twitchtv/twirp
Package twirp provides tracing functions for tracing clients and servers generated by the twirp framework (https://github.com/twitchtv/twirp).
Package twirp provides tracing functions for tracing clients and servers generated by the twirp framework (https://github.com/twitchtv/twirp).
urfave/negroni
Package negroni provides helper functions for tracing the urfave/negroni package (https://github.com/urfave/negroni).
Package negroni provides helper functions for tracing the urfave/negroni package (https://github.com/urfave/negroni).
valyala/fasthttp.v1
Package fasthttp provides functions to trace the valyala/fasthttp package (https://github.com/valyala/fasthttp)
Package fasthttp provides functions to trace the valyala/fasthttp package (https://github.com/valyala/fasthttp)
zenazn/goji.v1/web
Package web provides functions to trace the zenazn/goji/web package (https://github.com/zenazn/goji).
Package web provides functions to trace the zenazn/goji/web package (https://github.com/zenazn/goji).
Package ddtrace contains the interfaces that specify the implementations of Datadog's tracing library, as well as a set of sub-packages containing various implementations: our native implementation ("tracer"), a wrapper that can be used with Opentracing ("opentracer") and a mock tracer to be used for testing ("mocktracer").
Package ddtrace contains the interfaces that specify the implementations of Datadog's tracing library, as well as a set of sub-packages containing various implementations: our native implementation ("tracer"), a wrapper that can be used with Opentracing ("opentracer") and a mock tracer to be used for testing ("mocktracer").
ext
Package ext contains a set of Datadog-specific constants.
Package ext contains a set of Datadog-specific constants.
mocktracer
Package mocktracer provides a mock implementation of the tracer used in testing.
Package mocktracer provides a mock implementation of the tracer used in testing.
opentelemetry
Package opentelemetry provides a wrapper on top of the Datadog tracer that can be used with OpenTelemetry.
Package opentelemetry provides a wrapper on top of the Datadog tracer that can be used with OpenTelemetry.
opentracer
Package opentracer is in "Maintenance" mode and limited support is offered.
Package opentracer is in "Maintenance" mode and limited support is offered.
tracer
Package tracer contains Datadog's core tracing client.
Package tracer contains Datadog's core tracing client.
appsec/dyngo
Package dyngo is the Go implementation of Datadog's Instrumentation Gateway which provides an event-based instrumentation API based on a stack representation of instrumented functions along with nested event listeners.
Package dyngo is the Go implementation of Datadog's Instrumentation Gateway which provides an event-based instrumentation API based on a stack representation of instrumented functions along with nested event listeners.
appsec/emitter
Package emitter provides functions and types used to instrument go libraries to integrate them with Datadog AppSec features.
Package emitter provides functions and types used to instrument go libraries to integrate them with Datadog AppSec features.
appsec/emitter/graphqlsec
Package graphql is the GraphQL instrumentation API and contract for AppSec defining an abstract run-time representation of AppSec middleware.
Package graphql is the GraphQL instrumentation API and contract for AppSec defining an abstract run-time representation of AppSec middleware.
appsec/emitter/grpcsec
Package grpcsec is the gRPC instrumentation API and contract for AppSec defining an abstract run-time representation of gRPC handlers.
Package grpcsec is the gRPC instrumentation API and contract for AppSec defining an abstract run-time representation of gRPC handlers.
appsec/emitter/httpsec
Package httpsec defines is the HTTP instrumentation API and contract for AppSec.
Package httpsec defines is the HTTP instrumentation API and contract for AppSec.
appsec/listener
Package listener provides functions and types used to listen to AppSec instrumentation events produced by code usintrumented using the functions and types found in gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/emitter.
Package listener provides functions and types used to listen to AppSec instrumentation events produced by code usintrumented using the functions and types found in gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/emitter.
appsec/trace
Package trace provides functions to annotate trace spans with AppSec related information.
Package trace provides functions to annotate trace spans with AppSec related information.
globalconfig
Package globalconfig stores configuration which applies globally to both the tracer and integrations.
Package globalconfig stores configuration which applies globally to both the tracer and integrations.
hostname/cachedfetch
Package cachedfetch provides a read-through cache for fetched values.
Package cachedfetch provides a read-through cache for fetched values.
hostname/validate
Package validate provides hostname validation helpers
Package validate provides hostname validation helpers
httpmem
Package httpmem provides an in-memory HTTP server and client, for testing
Package httpmem provides an in-memory HTTP server and client, for testing
log
Package log provides logging utilities for the tracer.
Package log provides logging utilities for the tracer.
namingschema
Package namingschema allows to use the naming schema from the integrations to set different service and span/operation names based on the value of the DD_TRACE_SPAN_ATTRIBUTE_SCHEMA environment variable.
Package namingschema allows to use the naming schema from the integrations to set different service and span/operation names based on the value of the DD_TRACE_SPAN_ATTRIBUTE_SCHEMA environment variable.
normalizer
Package normalizer provides tag normalization
Package normalizer provides tag normalization
osinfo
Package osinfo provides information about the current operating system release
Package osinfo provides information about the current operating system release
telemetry
Package telemetry implements a client for sending telemetry information to Datadog regarding usage of an APM library such as tracing or profiling.
Package telemetry implements a client for sending telemetry information to Datadog regarding usage of an APM library such as tracing or profiling.
telemetry/telemetrytest
Package telemetrytest provides a mock implementation of the telemetry client for testing purposes
Package telemetrytest provides a mock implementation of the telemetry client for testing purposes
traceprof
Package traceprof contains shared logic for cross-cutting tracer/profiler features.
Package traceprof contains shared logic for cross-cutting tracer/profiler features.
traceprof/testapp
Package testapp has the protbuf/grpc definitions for the test application implemented in traceproftest.
Package testapp has the protbuf/grpc definitions for the test application implemented in traceproftest.
traceprof/traceproftest
Package traceproftest contains test cases and test helpers for testing cross-cutting tracer/profiler features such as code hotspots and endpoints.
Package traceproftest contains test cases and test helpers for testing cross-cutting tracer/profiler features such as code hotspots and endpoints.
Package profiler periodically collects and sends profiles to the Datadog API.
Package profiler periodically collects and sends profiles to the Datadog API.
internal/fastdelta
Package fastdelta tries to match up samples between two pprof profiles and take their difference.
Package fastdelta tries to match up samples between two pprof profiles and take their difference.
internal/immutable
Package immutable provides read-only types
Package immutable provides read-only types
internal/pproflite
Package pproflite implements zero-allocation pprof encoding and decoding.
Package pproflite implements zero-allocation pprof encoding and decoding.
internal/pprofutils
Package pprofutils is a fork of github.com/felixge/pprofutils, see README.
Package pprofutils is a fork of github.com/felixge/pprofutils, see README.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL