dd-trace-go

module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2018 License: BSD-3-Clause

README

CircleCI Godoc

Datadog APM client that implements an OpenTracing Tracer.

Initialization

To start using the Datadog Tracer with the OpenTracing API, you should first initialize the tracer with a proper Configuration object:

import (
	// ddtrace namespace is suggested
	ddtrace "github.com/DataDog/dd-trace-go/opentracing"
	opentracing "github.com/opentracing/opentracing-go"
)

func main() {
	// create a Tracer configuration
	config := ddtrace.NewConfiguration()
	config.ServiceName = "api-intake"
	config.AgentHostname = "ddagent.consul.local"

	// initialize a Tracer and ensure a graceful shutdown
	// using the `closer.Close()`
	tracer, closer, err := ddtrace.NewTracer(config)
	if err != nil {
		// handle the configuration error
	}
	defer closer.Close()

	// set the Datadog tracer as a GlobalTracer
	opentracing.SetGlobalTracer(tracer)
	startWebServer()
}

Function NewTracer(config) returns an io.Closer instance that can be used to gracefully shutdown the tracer. It's recommended to always call the closer.Close(), otherwise internal buffers are not flushed and you may lose some traces.

Usage

See Opentracing documentation for some usage patterns. Legacy documentation is available in GoDoc format.

Contributing Quick Start

Requirements:

Run the tests

Start the containers defined in docker-compose.yml so that integrations can be tested:

$ docker-compose up -d
$ ./wait-for-services.sh  # wait that all services are up and running

Fetch package's third-party dependencies (integrations and testing utilities):

$ rake init

This will only work if your working directory is in $GOPATH/src.

Now, you can run your tests via :

$ rake test:lint  # linting via gometalinter
$ rake test:all   # test the tracer and all integrations
$ rake test:race  # use the -race flag

Further Reading

Automatically traced libraries and frameworks: https://godoc.org/github.com/DataDog/dd-trace-go/tracer#pkg-subdirectories Sample code: https://godoc.org/github.com/DataDog/dd-trace-go/tracer#pkg-examples

Directories

Path Synopsis
contrib
database/sql
Package sqltraced provides a traced version of any driver implementing the database/sql/driver interface.
Package sqltraced provides a traced version of any driver implementing the database/sql/driver interface.
database/sql/parsedsn
Package parsedsn provides functions to parse any kind of DSNs into a map[string]string
Package parsedsn provides functions to parse any kind of DSNs into a map[string]string
database/sql/parsedsn/mysql
Package mysql is the minimal fork of go-sql-driver/mysql so we can use their code to parse the mysql DSNs
Package mysql is the minimal fork of go-sql-driver/mysql so we can use their code to parse the mysql DSNs
database/sql/parsedsn/pq
Package pq is the minimal fork of lib/pq so we can use their code to parse the postgres DSNs
Package pq is the minimal fork of lib/pq so we can use their code to parse the postgres DSNs
database/sql/sqltest
Package sqltest is used for testing sql packages
Package sqltest is used for testing sql packages
database/sql/sqlutils
Package sqlutils share some utils functions for sql packages
Package sqlutils share some utils functions for sql packages
garyburd/redigo
Package redigo provides tracing for the Redigo Redis client (https://github.com/garyburd/redigo)
Package redigo provides tracing for the Redigo Redis client (https://github.com/garyburd/redigo)
gin-gonic/gin
Package gin provides tracing middleware for the Gin web framework.
Package gin provides tracing middleware for the Gin web framework.
go-redis/redis
Package redis provides tracing for the go-redis Redis client (https://github.com/go-redis/redis)
Package redis provides tracing for the go-redis Redis client (https://github.com/go-redis/redis)
gocql/gocql
Package gocql provides tracing for the Cassandra Gocql client (https://github.com/gocql/gocql)
Package gocql provides tracing for the Cassandra Gocql client (https://github.com/gocql/gocql)
gorilla/mux
Package mux provides tracing functions for the Gorilla Mux framework.
Package mux provides tracing functions for the Gorilla Mux framework.
jmoiron/sqlx
Package sqlxtraced provides a traced version of the "jmoiron/sqlx" package For more information about the API, see https://godoc.org/github.com/DataDog/dd-trace-go/tracer/contrib/sqltraced.
Package sqlxtraced provides a traced version of the "jmoiron/sqlx" package For more information about the API, see https://godoc.org/github.com/DataDog/dd-trace-go/tracer/contrib/sqltraced.
olivere/elastic
Package elastictrace provides tracing for the Elastic Elasticsearch client.
Package elastictrace provides tracing for the Elastic Elasticsearch client.
Package opentracing implements an OpenTracing (http://opentracing.io) compatible tracer.
Package opentracing implements an OpenTracing (http://opentracing.io) compatible tracer.
Package tracer contains Datadog's tracing client.
Package tracer contains Datadog's tracing client.
contrib/elastictraced
Package elastictraced provides tracing for the Elastic Elasticsearch client.
Package elastictraced provides tracing for the Elastic Elasticsearch client.
contrib/gin-gonic/gintrace
Package gintrace provides tracing middleware for the Gin web framework.
Package gintrace provides tracing middleware for the Gin web framework.
contrib/go-redis
Package goredistrace provides tracing for the go-redis Redis client (https://github.com/go-redis/redis)
Package goredistrace provides tracing for the go-redis Redis client (https://github.com/go-redis/redis)
contrib/gocql
Package gocqltrace provides tracing for the Cassandra Gocql client (https://github.com/gocql/gocql)
Package gocqltrace provides tracing for the Cassandra Gocql client (https://github.com/gocql/gocql)
contrib/gorilla/muxtrace
Package muxtrace provides tracing functions for the Gorilla Mux framework.
Package muxtrace provides tracing functions for the Gorilla Mux framework.
contrib/redigo
Package redigotrace provides tracing for the Redigo Redis client (https://github.com/garyburd/redigo)
Package redigotrace provides tracing for the Redigo Redis client (https://github.com/garyburd/redigo)
contrib/sqltraced
Package sqltraced provides a traced version of any driver implementing the database/sql/driver interface.
Package sqltraced provides a traced version of any driver implementing the database/sql/driver interface.
contrib/sqltraced/parsedsn
Package parsedsn provides functions to parse any kind of DSNs into a map[string]string
Package parsedsn provides functions to parse any kind of DSNs into a map[string]string
contrib/sqltraced/parsedsn/mysql
Package mysql is the minimal fork of go-sql-driver/mysql so we can use their code to parse the mysql DSNs
Package mysql is the minimal fork of go-sql-driver/mysql so we can use their code to parse the mysql DSNs
contrib/sqltraced/parsedsn/pq
Package pq is the minimal fork of lib/pq so we can use their code to parse the postgres DSNs
Package pq is the minimal fork of lib/pq so we can use their code to parse the postgres DSNs
contrib/sqltraced/sqltest
Package sqltest is used for testing sql packages
Package sqltest is used for testing sql packages
contrib/sqltraced/sqlutils
Package sqlutils share some utils functions for sql packages
Package sqlutils share some utils functions for sql packages
contrib/sqlxtraced
Package sqlxtraced provides a traced version of the "jmoiron/sqlx" package For more information about the API, see https://godoc.org/github.com/DataDog/dd-trace-go/tracer/contrib/sqltraced.
Package sqlxtraced provides a traced version of the "jmoiron/sqlx" package For more information about the API, see https://godoc.org/github.com/DataDog/dd-trace-go/tracer/contrib/sqltraced.
ext

Jump to

Keyboard shortcuts

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