Skip to content

Commit

Permalink
Merge branch 'v1' of https://github.com/DataDog/dd-trace-go into v1
Browse files Browse the repository at this point in the history
* 'v1' of https://github.com/DataDog/dd-trace-go:
  Implement DD_PROFILING_OUTPUT_DIR for dev/debug (DataDog#924)
  contrib/go-pg/pg.v10: add INTEGRATION flag check for tests (DataDog#921)
  contrib/go-redis/redis.v8: optimize BeforeProcess and BeforeProcessPipeline (DataDog#920)
  CI: check go.sum is up-to-date (DataDog#918)
  README: Fix go get instructions (DataDog#913)
  internal/log: Improve API for testing (DataDog#916)
  ddtrace/tracer: add support for agent discovery endpoint, feature flags, stats & drops (DataDog#859)
  internal/version: bump to v1.31.0 (DataDog#910)
  CONTRIBUTING.md: add link to contrib/README.md (DataDog#802)
  profiler: Disable agentless mode for WithAPIKey (DataDog#906)
  contrib/Shopify/sarama: fix possible deadlock in WrapAsyncProducer (DataDog#907)
  contrib/database/sql.tracedConn implement driver.SessionResetter (DataDog#908)
  ddtrace/opentracer: consider FollowsFrom references as children (DataDog#905)
  ddtrace/opentracer: add support for opentracing.TracerContextWithSpanExtension (DataDog#855)
  ddtrace/tracer: follow noDebugStack setting when using SetTag with an error (DataDog#900)
  contrib/net/http: add a getter to retrieve original round tripper (DataDog#903)
  ddtrace/tracer: ensure Flush call is synchronous (DataDog#901)
  • Loading branch information
Lim Swee Tat committed May 17, 2021
2 parents 3c73c98 + 434d62f commit fabf2b9
Show file tree
Hide file tree
Showing 34 changed files with 1,843 additions and 175 deletions.
35 changes: 32 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ jobs:
steps:
- checkout

# -mod=readonly is enabled by default starting in go1.16 causing many go
# tools and editor integrations to report problems if the go.sum file is
# not up-to-date, so let's make sure it is.
- run:
name: go.sum up-to-date
command: |
go run -mod=readonly gosum.go
- run:
name: milestone
command: |
Expand Down Expand Up @@ -186,13 +194,34 @@ jobs:
command: dockerize -wait http://localhost:8500 -timeout 1m

- run:
name: Testing
name: Testing integrations
command: |
INTEGRATION=1 go test -v -race -coverprofile=coverage.txt -covermode=atomic `go list ./contrib/... | grep -v -e grpc.v12 -e google.golang.org/api`
- run:
name: Testing outlier google.golang.org/api
command: |
go get google.golang.org/grpc@v1.29.0 # https://github.com/grpc/grpc-go/issues/3726
go test -v ./contrib/google.golang.org/api/...
go get google.golang.org/grpc@v1.2.0
go test -v ./contrib/google.golang.org/grpc.v12/...
- run:
name: Testing outlier gRPC v1.2
command: |
# This hacky approach is necessary because running the tests regularly
# do not allow using grpc-go@v1.2.0 alongside sketches-go@v1.0.0
go mod vendor
# Checkout grpc-go@v1.2.0
cd vendor/google.golang.org && rm -rf grpc
git clone git@github.com:grpc/grpc-go grpc && cd grpc
git fetch origin && git checkout v1.2.0 && cd ../..
# Checkout sketches-go@v1.0.0
cd vendor/github.com/DataDog && rm -rf sketches-go
git clone git@github.com:DataDog/sketches-go && cd sketches-go
git fetch origin && git checkout v1.0.0 && cd ../..
go test -mod=vendor -v ./contrib/google.golang.org/grpc.v12/...
- run:
name: Upload coverage report to Codecov
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ the official [Go language](https://github.com/golang/go/pulls).
A set of [Style guidelines](https://github.com/DataDog/dd-trace-go/wiki/Style-guidelines) was added to our Wiki. Please spend some time browsing it.
It will help tremendously in avoiding comments and speeding up the PR process.


### Integrations

Please view our contrib [README.md](contrib/README.md) for information on new integrations.

### Go Modules

This repository currently takes an [idiosyncratic approach](https://github.com/DataDog/dd-trace-go/issues/810) to using Go modules which means that you should not commit modified versions of the `go.mod` or `go.sum` files.
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@

### Installing

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

```bash
go get github.com/stlimtat/dd-trace-go/...
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](./contrib) packages that can be installed as needed like this:

```
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.

Requires:

* Go >= 1.12
* Datadog's Trace Agent >= 5.21.1

### Documentation

The API is documented on [godoc](https://godoc.org/github.com/stlimtat/dd-trace-go/ddtrace) as well as Datadog's [official documentation](https://docs.datadoghq.com/tracing/setup/go/). If you are migrating
from an older version of the tracer (e.g. 0.6.x) you may also find the [migration document](https://github.com/DataDog/dd-trace-go/blob/v1/MIGRATING.md) we've put together helpful.
The API is documented on [godoc](https://godoc.org/gopkg.in/DataDog/dd-trace-go.v1/ddtrace) as well as Datadog's official documentation for [Tracing Go Applications](https://docs.datadoghq.com/tracing/setup/go/) and the [Continuous Go Profiler](https://docs.datadoghq.com/tracing/profiler/getting_started/?code-lang=go). If you are migrating from an older version of the tracer (e.g. 0.6.x) you may also find the [migration document](https://github.com/DataDog/dd-trace-go/blob/v1/MIGRATING.md) we've put together helpful.

### Contributing

Expand Down
1 change: 1 addition & 0 deletions contrib/Shopify/sarama/sarama.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func WrapAsyncProducer(saramaConfig *sarama.Config, p sarama.AsyncProducer, opts
}
go func() {
spans := make(map[uint64]ddtrace.Span)
defer close(wrapped.input)
defer close(wrapped.successes)
defer close(wrapped.errors)
for {
Expand Down
10 changes: 10 additions & 0 deletions contrib/database/sql/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ func (tc *tracedConn) CheckNamedValue(value *driver.NamedValue) error {
return driver.ErrSkip
}

var _ driver.SessionResetter = (*tracedConn)(nil)

// ResetSession implements driver.SessionResetter
func (tc *tracedConn) ResetSession(ctx context.Context) error {
if resetter, ok := tc.Conn.(driver.SessionResetter); ok {
return resetter.ResetSession(ctx)
}
return driver.ErrSkip
}

// traceParams stores all information related to tracing the driver.Conn
type traceParams struct {
cfg *config
Expand Down
11 changes: 11 additions & 0 deletions contrib/go-pg/pg.v10/pg_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package pg

import (
"context"
"fmt"
"os"
"testing"

"github.com/stlimtat/dd-trace-go/ddtrace/ext"
Expand All @@ -18,6 +20,15 @@ import (
"github.com/stretchr/testify/require"
)

func TestMain(m *testing.M) {
_, ok := os.LookupEnv("INTEGRATION")
if !ok {
fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable")
os.Exit(0)
}
os.Exit(m.Run())
}

func TestImplementsHook(t *testing.T) {
var _ pg.QueryHook = (*queryHook)(nil)
}
Expand Down
20 changes: 10 additions & 10 deletions contrib/go-redis/redis.v8/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ func additionalTagOptions(client redis.UniversalClient) []ddtrace.StartSpanOptio

func (ddh *datadogHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error) {
raw := cmd.String()
parts := strings.Split(raw, " ")
length := len(parts) - 1
length := strings.Count(raw, " ")
p := ddh.params
opts := []ddtrace.StartSpanOption{
opts := make([]ddtrace.StartSpanOption, 0, 5+len(ddh.additionalTags)+1) // 5 options below + for additionalTags + for analyticsRate
opts = append(opts,
tracer.SpanType(ext.SpanTypeRedis),
tracer.ServiceName(p.config.serviceName),
tracer.ResourceName(parts[0]),
tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]),
tracer.Tag("redis.raw_command", raw),
tracer.Tag("redis.args_length", strconv.Itoa(length)),
}
)
opts = append(opts, ddh.additionalTags...)
if !math.IsNaN(p.config.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate))
Expand All @@ -132,18 +132,18 @@ func (ddh *datadogHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error

func (ddh *datadogHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error) {
raw := commandsToString(cmds)
parts := strings.Split(raw, " ")
length := len(parts) - 1
length := strings.Count(raw, " ")
p := ddh.params
opts := []ddtrace.StartSpanOption{
opts := make([]ddtrace.StartSpanOption, 0, 7+len(ddh.additionalTags)+1) // 7 options below + for additionalTags + for analyticsRate
opts = append(opts,
tracer.SpanType(ext.SpanTypeRedis),
tracer.ServiceName(p.config.serviceName),
tracer.ResourceName(parts[0]),
tracer.ResourceName(raw[:strings.IndexByte(raw, ' ')]),
tracer.Tag("redis.raw_command", raw),
tracer.Tag("redis.args_length", strconv.Itoa(length)),
tracer.Tag(ext.ResourceName, raw),
tracer.Tag("redis.pipeline_length", strconv.Itoa(len(cmds))),
}
)
opts = append(opts, ddh.additionalTags...)
if !math.IsNaN(p.config.analyticsRate) {
opts = append(opts, tracer.Tag(ext.EventSampleRate, p.config.analyticsRate))
Expand Down
5 changes: 5 additions & 0 deletions contrib/net/http/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (res *http.Response, err er
return res, err
}

// Unwrap returns the original http.RoundTripper.
func (rt *roundTripper) Unwrap() http.RoundTripper {
return rt.base
}

// WrapRoundTripper returns a new RoundTripper which traces all requests sent
// over the transport.
func WrapRoundTripper(rt http.RoundTripper, opts ...RoundTripperOption) http.RoundTripper {
Expand Down
9 changes: 6 additions & 3 deletions ddtrace/internal/globaltracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ var (
// SetGlobalTracer sets the global tracer to t.
func SetGlobalTracer(t ddtrace.Tracer) {
mu.Lock()
defer mu.Unlock()
old := globalTracer
globalTracer = t
// Unlock before potentially calling Stop, to allow any shutdown mechanism
// to retrieve the active tracer without causing a deadlock on mutex mu.
mu.Unlock()
if !Testing {
// avoid infinite loop when calling (*mocktracer.Tracer).Stop
globalTracer.Stop()
old.Stop()
}
globalTracer = t
}

// GetGlobalTracer returns the currently active tracer.
Expand Down
23 changes: 19 additions & 4 deletions ddtrace/opentracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
package opentracer

import (
"github.com/stlimtat/dd-trace-go/ddtrace"
"github.com/stlimtat/dd-trace-go/ddtrace/internal"
"github.com/stlimtat/dd-trace-go/ddtrace/tracer"
"context"

"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/internal"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"

opentracing "github.com/opentracing/opentracing-go"
)
Expand All @@ -47,7 +49,9 @@ func (t *opentracer) StartSpan(operationName string, options ...opentracing.Star
}
opts := []ddtrace.StartSpanOption{tracer.StartTime(sso.StartTime)}
for _, ref := range sso.References {
if v, ok := ref.ReferencedContext.(ddtrace.SpanContext); ok && ref.Type == opentracing.ChildOfRef {
if v, ok := ref.ReferencedContext.(ddtrace.SpanContext); ok {
// opentracing.ChildOfRef and opentracing.FollowsFromRef will both be represented as
// children because Datadog APM does not have a concept of FollowsFrom references.
opts = append(opts, tracer.ChildOf(v))
break // can only have one parent
}
Expand Down Expand Up @@ -84,3 +88,14 @@ func (t *opentracer) Extract(format interface{}, carrier interface{}) (opentraci
return nil, opentracing.ErrUnsupportedFormat
}
}

var _ opentracing.TracerContextWithSpanExtension = (*opentracer)(nil)

// ContextWithSpan implements opentracing.TracerContextWithSpanExtension.
func (t *opentracer) ContextWithSpanHook(ctx context.Context, openSpan opentracing.Span) context.Context {
ddSpan, ok := openSpan.(*span)
if !ok {
return ctx
}
return tracer.ContextWithSpan(ctx, ddSpan.Span)
}
18 changes: 16 additions & 2 deletions ddtrace/opentracer/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
package opentracer

import (
"context"
"testing"

"github.com/stlimtat/dd-trace-go/ddtrace"
"github.com/stlimtat/dd-trace-go/ddtrace/internal"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/internal"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"

"github.com/opentracing/opentracing-go"
"github.com/stretchr/testify/assert"
)

Expand All @@ -23,3 +26,14 @@ func TestStart(t *testing.T) {
assert.True(ok)
assert.Equal(ott.Tracer, dd)
}

func TestSpanWithContext(t *testing.T) {
assert := assert.New(t)
ot, ok := New().(*opentracer)
assert.True(ok)
opentracing.SetGlobalTracer(ot)
want, ctx := opentracing.StartSpanFromContext(context.Background(), "test.operation")
got, ok := tracer.SpanFromContext(ctx)
assert.True(ok)
assert.Equal(got, want.(*span).Span)
}
10 changes: 6 additions & 4 deletions ddtrace/tracer/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type startupInfo struct {
Architecture string `json:"architecture"` // Architecture of host machine
GlobalService string `json:"global_service"` // Global service string. If not-nil should be same as Service. (#614)
LambdaMode string `json:"lambda_mode"` // Whether or not the client has enabled lambda mode
AgentFeatures agentFeatures `json:"agent_features"` // Lists the capabilities of the agent.
}

// checkEndpoint tries to connect to the URL specified by endpoint.
Expand All @@ -70,7 +71,7 @@ func checkEndpoint(endpoint string) error {
// JSON format.
func logStartup(t *tracer) {
tags := make(map[string]string)
for k, v := range t.globalTags {
for k, v := range t.config.globalTags {
tags[k] = fmt.Sprintf("%v", v)
}

Expand All @@ -83,7 +84,7 @@ func logStartup(t *tracer) {
LangVersion: runtime.Version(),
Env: t.config.env,
Service: t.config.serviceName,
AgentURL: t.transport.endpoint(),
AgentURL: t.config.transport.endpoint(),
Debug: t.config.debug,
AnalyticsEnabled: !math.IsNaN(globalconfig.AnalyticsRate()),
SampleRate: fmt.Sprintf("%f", t.rulesSampling.globalRate),
Expand All @@ -95,14 +96,15 @@ func logStartup(t *tracer) {
Architecture: runtime.GOARCH,
GlobalService: globalconfig.ServiceName(),
LambdaMode: fmt.Sprintf("%t", t.config.logToStdout),
AgentFeatures: t.features.Load(),
}
if _, err := samplingRulesFromEnv(); err != nil {
info.SamplingRulesError = fmt.Sprintf("%s", err)
}
if !t.config.logToStdout {
if err := checkEndpoint(t.transport.endpoint()); err != nil {
if err := checkEndpoint(t.config.transport.endpoint()); err != nil {
info.AgentError = fmt.Sprintf("%s", err)
log.Warn("DIAGNOSTICS Unable to reach agent: %s", err)
log.Warn("DIAGNOSTICS Unable to reach agent intake: %s", err)
}
}
bs, err := json.Marshal(info)
Expand Down
10 changes: 5 additions & 5 deletions ddtrace/tracer/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestStartupLog(t *testing.T) {
tp.Reset()
logStartup(tracer)
assert.Len(tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false"}`, tp.Lines()[1])
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","agent_features":{"DropP0s":false,"V05":false,"Stats":false}}`, tp.Lines()[1])
})

t.Run("configured", func(t *testing.T) {
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestStartupLog(t *testing.T) {
tp.Reset()
logStartup(tracer)
assert.Len(tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75}\],"sampling_rules_error":"","tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false"}`, tp.Lines()[1])
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75}\],"sampling_rules_error":"","tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false","agent_features":{"DropP0s":false,"V05":false,"Stats":false}}`, tp.Lines()[1])
})

t.Run("errors", func(t *testing.T) {
Expand All @@ -67,7 +67,7 @@ func TestStartupLog(t *testing.T) {
tp.Reset()
logStartup(tracer)
assert.Len(tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":\[{"service":"some.service","name":"","sample_rate":0\.234}\],"sampling_rules_error":"found errors:\\n\\tat index 1: rate not provided","tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false"}`, tp.Lines()[1])
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":\[{"service":"some.service","name":"","sample_rate":0\.234}\],"sampling_rules_error":"found errors:\\n\\tat index 1: rate not provided","tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","agent_features":{"DropP0s":false,"V05":false,"Stats":false}}`, tp.Lines()[1])
})

t.Run("lambda", func(t *testing.T) {
Expand All @@ -79,7 +79,7 @@ func TestStartupLog(t *testing.T) {
tp.Reset()
logStartup(tracer)
assert.Len(tp.Lines(), 1)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"true"}`, tp.Lines()[0])
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"true","agent_features":{"DropP0s":false,"V05":false,"Stats":false}}`, tp.Lines()[0])
})
}

Expand All @@ -104,7 +104,7 @@ func TestLogAgentReachable(t *testing.T) {
tp.Reset()
logStartup(tracer)
assert.Len(tp.Lines(), 2)
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ WARN: DIAGNOSTICS Unable to reach agent: Post`, tp.Lines()[0])
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ WARN: DIAGNOSTICS Unable to reach agent intake: Post`, tp.Lines()[0])
}

func TestLogFormat(t *testing.T) {
Expand Down
Loading

0 comments on commit fabf2b9

Please sign in to comment.