Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DataDog/dd-trace-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.55.0
Choose a base ref
...
head repository: DataDog/dd-trace-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.56.0
Choose a head ref

Commits on Sep 7, 2023

  1. Copy the full SHA
    9314217 View commit details
  2. contrib/labstack/echo.v4: add WithErrorTranslator Option (#2169)

    Co-authored-by: Zarir Hamza <zarir.hamza@datadoghq.com>
    Co-authored-by: Rodrigo Argüello <rodrigo.arguello@datadoghq.com>
    Co-authored-by: Andrew Glaude <andrew.glaude@datadoghq.com>
    4 people authored Sep 7, 2023
    Copy the full SHA
    c487104 View commit details

Commits on Sep 8, 2023

  1. all: downgrade google.golang.org/protobuf and golang.org/x/exp depend…

    …encies (#2212)
    
    A recent change to golang.org/x/exp/slices introduced an incompatibility
    which affects some of our downstream users. Additionally, upgrading the
    google.golang.org/protobuf dependency introduces lots of churn from
    differences in generated protobuf code. Neither dependency upgrade was
    needed by this library to address issues or use new features. Downgrade
    these dependencies to what they were prior to #2171.
    nsrip-dd authored Sep 8, 2023
    Copy the full SHA
    43a4d91 View commit details

Commits on Sep 11, 2023

  1. datastreams: Add version tag (#2211)

    Add a version tag to stats produced for data streams monitoring. This will help detect when deployments happen.
    piochelepiotr authored Sep 11, 2023
    1
    Copy the full SHA
    246238d View commit details

Commits on Sep 12, 2023

  1. 1
    Copy the full SHA
    f8a0ac2 View commit details

Commits on Sep 14, 2023

  1. profiler: disable when run in AWS Lambda. (#2216)

    Go profiling is not supported for AWS Lambda (or other serverless runtimes),
    so refuse to start if we detect we're in a Lambda. Otherwise the profiler will
    try (and most often fail) to send profiles which are unlikely to be useful.
    purple4reina authored Sep 14, 2023
    1
    Copy the full SHA
    9435e66 View commit details

Commits on Sep 15, 2023

  1. 1
    Copy the full SHA
    e0f9256 View commit details
  2. 1
    Copy the full SHA
    3679975 View commit details
  3. profiler: add go_num_goroutine metric (#2217)

    profiler: add go_num_goroutine metric
    
    Co-authored-by: Jeremy C <jeremy.comte@gmail.com>
    Co-authored-by: Felix Geisendörfer <felix@datadoghq.com>
    3 people authored Sep 15, 2023
    1
    Copy the full SHA
    f50b6be View commit details
  4. build(deps): bump github.com/gofiber/fiber/v2 from 2.48.0 to 2.49.2 (#…

    …2219)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Ahmed Mezghani <38987709+ahmed-mez@users.noreply.github.com>
    dependabot[bot] and ahmed-mez authored Sep 15, 2023
    1
    Copy the full SHA
    2ac90e1 View commit details

Commits on Sep 18, 2023

  1. contrib: add validation tests using test-agent (#2047)

    This PR adds the APM Test Agent to run alongside unit / contrib tests in CI testing. A testing interface is created in contrib/internal/validationtest, which can be implemented by each contrib integration in order to generate test traces which are emitted to the APM Test Agent using the real Golang tracer. These traces are tested against a number of centrally located checks written within the Test-Agent, including:
    
    Service naming checks
    Peer.service checks
    Trace header checks
    
    The APM Test Agent is being added to every DD APM Tracer with the primary purpose of providing a centralized location for writing tests which will subsequently be used for asserting on handled traces. This strategy will help bring consistency to Datadog APM Tagging/ integration support.
    rarguelloF authored Sep 18, 2023
    1
    Copy the full SHA
    992bbaf View commit details

Commits on Sep 25, 2023

  1. ddtrace/mocktracer: use lock in String method (#2229)

    ddtrace/mocktracer: use lock in String method
    
    Co-authored-by: iharzhavarankau <izhavarankau@fubo.tv>
    phoenix2x and phoenix2x authored Sep 25, 2023
    1
    Copy the full SHA
    6a938b3 View commit details

Commits on Sep 27, 2023

  1. 1
    Copy the full SHA
    04c819d View commit details

Commits on Sep 28, 2023

  1. 1
    Copy the full SHA
    93d4ab3 View commit details

Commits on Oct 2, 2023

  1. Copy the full SHA
    d91f79f View commit details

Commits on Oct 3, 2023

  1. Copy the full SHA
    19f9b7c View commit details

Commits on Oct 4, 2023

  1. Copy the full SHA
    08f3182 View commit details

Commits on Oct 5, 2023

  1. ci: use older Windows for Go 1.19 tests (#2250)

    Use windows-2019 runner when testing Go 1.19, since the windows-2022 image
    has an incompatible C toolchain which breaks some of our tests.
    
    (cherry picked from commit b4cc9ed)
    nsrip-dd authored and darccio committed Oct 5, 2023
    Copy the full SHA
    a95b2e9 View commit details
  2. contrib/google.golang.org/grpc: isolate tests using an independent ri…

    …g instance instead of a shared one
    darccio committed Oct 5, 2023
    Copy the full SHA
    8a5def5 View commit details
  3. contrib/google.golang.org/grpc: isolate more tests using an independe…

    …nt rig instance instead of a shared one
    darccio committed Oct 5, 2023
    Copy the full SHA
    bbc77a4 View commit details

Commits on Oct 18, 2023

  1. internal/version: v1.56.0

    darccio committed Oct 18, 2023
    Copy the full SHA
    5781af2 View commit details
Showing with 1,027 additions and 132 deletions.
  1. +1 −1 .github/workflows/main-branch-tests.yml
  2. +1 −1 .github/workflows/multios-unit-tests.yml
  3. +3 −0 .github/workflows/pull-request.yml
  4. +42 −0 .github/workflows/unit-integration-tests.yml
  5. +12 −1 SECURITY.md
  6. +55 −36 contrib/google.golang.org/grpc/appsec_test.go
  7. +5 −5 contrib/google.golang.org/grpc/grpc_test.go
  8. +41 −0 contrib/internal/fasthttptrace/fasthttpheaderscarrier.go
  9. +96 −0 contrib/internal/fasthttptrace/fasthttpheaderscarrier_test.go
  10. +24 −0 contrib/internal/fasthttptrace/fasthttptrace.go
  11. +26 −0 contrib/internal/fasthttptrace/fasthttptrace_test.go
  12. +53 −0 contrib/internal/validationtest/contrib/bradfitz_memcache.go
  13. +125 −0 contrib/internal/validationtest/contrib/miekg_dns.go
  14. +273 −0 contrib/internal/validationtest/validation_test.go
  15. +1 −3 contrib/labstack/echo.v4/echotrace.go
  16. +51 −0 contrib/labstack/echo.v4/echotrace_test.go
  17. +17 −0 contrib/labstack/echo.v4/option.go
  18. +2 −0 ddtrace/mocktracer/mockspan.go
  19. +8 −0 ddtrace/mocktracer/mockspan_test.go
  20. +6 −9 ddtrace/tracer/context.go
  21. +6 −5 ddtrace/tracer/context_test.go
  22. +2 −0 ddtrace/tracer/option.go
  23. +1 −1 ddtrace/tracer/tracer.go
  24. +12 −0 docker-compose.yaml
  25. +12 −12 go.mod
  26. +24 −24 go.sum
  27. +11 −0 internal/active_span_key.go
  28. +2 −0 internal/datastreams/payload.go
  29. +19 −3 internal/datastreams/payload_msgp.go
  30. +4 −1 internal/datastreams/processor.go
  31. +4 −2 internal/datastreams/processor_test.go
  32. +1 −1 internal/version/version.go
  33. +12 −0 profiler/go_lt_1_21.go
  34. +14 −7 profiler/metrics.go
  35. +27 −19 profiler/metrics_test.go
  36. +7 −1 profiler/options.go
  37. +3 −0 profiler/profiler.go
  38. +14 −0 profiler/profiler_test.go
  39. +10 −0 repository.datadog.yml
2 changes: 1 addition & 1 deletion .github/workflows/main-branch-tests.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ jobs:
multios-unit-tests:
strategy:
matrix:
runs-on: [ macos-latest, windows-latest, ubuntu-latest ]
runs-on: [ macos-latest, windows-2019, ubuntu-latest ]
go-version: ["1.19", "1.20", "1.21"]
fail-fast: false
uses: ./.github/workflows/multios-unit-tests.yml
2 changes: 1 addition & 1 deletion .github/workflows/multios-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ on:

jobs:
test-multi-os:
runs-on: ${{ inputs.runs-on }}
runs-on: "${{ (inputs.go-version == '1.19' && inputs.runs-on == 'windows-latest') && 'windows-2019' || inputs.runs-on }}"
env:
REPORT: gotestsum-report.xml # path to where test results will be saved
steps:
3 changes: 3 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@ on:
branches:
- "**"
merge_group:
push:
branches:
- 'mq-working-branch-**'

concurrency:
group: ${{ github.ref }}
42 changes: 42 additions & 0 deletions .github/workflows/unit-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -51,6 +51,8 @@ jobs:
DD_APM_ENABLED: true
DD_BIND_HOST: "0.0.0.0"
DD_API_KEY: "invalid_key_but_this_is_fine"
DD_TEST_AGENT_HOST: "localhost"
DD_TEST_AGENT_PORT: 9126
# We need to specify a custom health-check. By default, this container will remain "unhealthy" since
# we don't fully configure it with a valid API key (and possibly other reasons)
# This command just checks for our ability to connect to port 8126
@@ -59,6 +61,18 @@ jobs:
ports:
- 8125:8125/udp
- 8126:8126
testagent:
image: ghcr.io/datadog/dd-apm-test-agent/ddapm-test-agent:v1.11.0
ports:
- 9126:9126
env:
LOG_LEVEL: DEBUG
TRACE_LANGUAGE: golang
ENABLED_CHECKS: trace_stall,trace_count_header,trace_peer_service,trace_dd_service
PORT: 9126
DD_SUPPRESS_TRACE_PARSE_ERRORS: true
DD_POOL_TRACE_CHECK_FAILURES: true
DD_DISABLE_ERROR_RESPONSES: true
cassandra:
image: cassandra:3.7
env:
@@ -188,6 +202,34 @@ jobs:
shell: bash
run: bash <(curl -s https://codecov.io/bash)

- name: Get Datadog APM Test Agent Logs
if: always()
shell: bash
run: docker logs ${{ job.services.testagent.id }}

- name: Get Datadog APM Test Agent Trace Check Summary Results
if: always()
shell: bash
run: |
RESPONSE=$(curl -s -w "\n%{http_code}" -o response.txt "http://127.0.0.1:9126/test/trace_check/failures?return_all=true")
RESPONSE_CODE=$(echo "$RESPONSE" | awk 'END {print $NF}')
SUMMARY_RESPONSE=$(curl -s -w "\n%{http_code}" -o summary_response.txt "http://127.0.0.1:9126/test/trace_check/summary?return_all=true")
SUMMARY_RESPONSE_CODE=$(echo "$SUMMARY_RESPONSE" | awk 'END {print $NF}')
if [[ $RESPONSE_CODE -eq 200 ]]; then
echo " "
cat response.txt
echo " - All APM Test Agent Check Traces returned successful!"
echo "APM Test Agent Check Traces Summary Results:"
cat summary_response.txt | jq "."
else
echo "APM Test Agent Check Traces failed with response code: $RESPONSE_CODE"
echo "Failures:"
cat response.txt
echo "APM Test Agent Check Traces Summary Results:"
cat summary_response.txt | jq "."
exit 1
fi
- name: Testing outlier google.golang.org/api
run: |
go get google.golang.org/api@v0.121.0 # version used to generate code
13 changes: 12 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
@@ -15,4 +15,15 @@ However, these scanners can report false positives if the vulnerabilities affect

Given this information, please file an issue if you feel that golang.org/x/vuln/vulncheck has given a false negative and that our code is using a vulnerable function such that users of our code could be affected.

If you have found a security issue in our code directly, please contact the security team at security@datadoghq.com, rather than filing a public issue.
If you have found a security issue in our code directly, please contact the security team at security@datadoghq.com, rather than filing a public issue.

## Vulnerabilities in Contrib Dependencies

If you are using a vulnerability checker other than `golang.org/x/vuln/vulncheck` you may detect vulnerabilities in our contrib dependencies.
In general we like to specify non-vulnerable minimum versions of dependencies when we can do so in a non-breaking way. To avoid breaking users of this library
there may be contrib libraries that are deprecated/vulnerable but still appear in our go.mod file. If you are not using these contrib packages you are not vulnerable (i.e. if they do not appear in your go.sum file).
At the next major version we will drop support for these packages. (e.g. as of dd-trace-go@v1 labstack/echo v3 is considered deprecated and users should migrate to labstack/echo.v4)

Note that since library go.mod files only specify minimum version requirements you are welcome to specify a newer version of any dependencies to satisfy your tooling.
For example, if you would like to require a library like `github.com/labstack/echo/v4` use version v4.10.0 you can do so by running `go get github.com/labstack/echo/v4@v4.10.0`.
Additional documentation and details can be found [here](https://go.dev/ref/mod#go-get).
91 changes: 55 additions & 36 deletions contrib/google.golang.org/grpc/appsec_test.go
Original file line number Diff line number Diff line change
@@ -30,15 +30,21 @@ func TestAppSec(t *testing.T) {
t.Skip("appsec disabled")
}

rig, err := newRig(false)
require.NoError(t, err)
defer rig.Close()
setup := func() (FixtureClient, mocktracer.Tracer, func()) {
rig, err := newRig(false)
require.NoError(t, err)

mt := mocktracer.Start()

client := rig.client
return rig.client, mt, func() {
rig.Close()
mt.Stop()
}
}

t.Run("unary", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, mt, cleanup := setup()
defer cleanup()

// Send a XSS attack in the payload along with the canary value in the RPC metadata
ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("dd-canary", "dd-test-scanner-log"))
@@ -58,8 +64,8 @@ func TestAppSec(t *testing.T) {
})

t.Run("stream", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, mt, cleanup := setup()
defer cleanup()

// Send a XSS attack in the payload along with the canary value in the RPC metadata
ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("dd-canary", "dd-test-scanner-log"))
@@ -110,15 +116,21 @@ func TestBlocking(t *testing.T) {
t.Skip("appsec disabled")
}

rig, err := newRig(false)
require.NoError(t, err)
defer rig.Close()
setup := func() (FixtureClient, mocktracer.Tracer, func()) {
rig, err := newRig(false)
require.NoError(t, err)

client := rig.client
mt := mocktracer.Start()

return rig.client, mt, func() {
rig.Close()
mt.Stop()
}
}

t.Run("unary-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, mt, cleanup := setup()
defer cleanup()

// Send a XSS attack in the payload along with the canary value in the RPC metadata
ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("dd-canary", "dd-test-scanner-log", "x-client-ip", "1.2.3.4"))
@@ -136,8 +148,8 @@ func TestBlocking(t *testing.T) {
})

t.Run("unary-no-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, _, cleanup := setup()
defer cleanup()

// Send a XSS attack in the payload along with the canary value in the RPC metadata
ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("dd-canary", "dd-test-scanner-log", "x-client-ip", "1.2.3.5"))
@@ -148,8 +160,8 @@ func TestBlocking(t *testing.T) {
})

t.Run("stream-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, mt, cleanup := setup()
defer cleanup()

ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("dd-canary", "dd-test-scanner-log", "x-client-ip", "1.2.3.4"))
stream, err := client.StreamPing(ctx)
@@ -168,8 +180,8 @@ func TestBlocking(t *testing.T) {
})

t.Run("stream-no-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, _, cleanup := setup()
defer cleanup()

ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("dd-canary", "dd-test-scanner-log", "x-client-ip", "1.2.3.5"))
stream, err := client.StreamPing(ctx)
@@ -197,14 +209,21 @@ func TestUserBlocking(t *testing.T) {
t.Skip("appsec disabled")
}

rig, err := newAppsecRig(false)
require.NoError(t, err)
defer rig.Close()
client := rig.client
setup := func() (FixtureClient, mocktracer.Tracer, func()) {
rig, err := newAppsecRig(false)
require.NoError(t, err)

t.Run("unary-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()

return rig.client, mt, func() {
rig.Close()
mt.Stop()
}
}

t.Run("unary-block", func(t *testing.T) {
client, mt, cleanup := setup()
defer cleanup()

// Send a XSS attack in the payload along with the canary value in the RPC metadata
ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("user-id", "blocked-user-1"))
@@ -223,8 +242,8 @@ func TestUserBlocking(t *testing.T) {
})

t.Run("unary-no-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, _, cleanup := setup()
defer cleanup()

ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("user-id", "legit user"))
reply, err := client.Ping(ctx, &FixtureRequest{Name: "<script>alert('xss');</script>"})
@@ -236,8 +255,8 @@ func TestUserBlocking(t *testing.T) {
// This test checks that IP blocking happens BEFORE user blocking, since user blocking needs the request handler
// to be invoked while IP blocking doesn't
t.Run("unary-mixed-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, mt, cleanup := setup()
defer cleanup()

ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("user-id", "blocked-user-1", "x-forwarded-for", "1.2.3.4"))
reply, err := client.Ping(ctx, &FixtureRequest{})
@@ -253,8 +272,8 @@ func TestUserBlocking(t *testing.T) {
})

t.Run("stream-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, mt, cleanup := setup()
defer cleanup()

ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("user-id", "blocked-user-1"))
stream, err := client.StreamPing(ctx)
@@ -273,8 +292,8 @@ func TestUserBlocking(t *testing.T) {
})

t.Run("stream-no-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, _, cleanup := setup()
defer cleanup()

ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("user-id", "legit user"))
stream, err := client.StreamPing(ctx)
@@ -293,8 +312,8 @@ func TestUserBlocking(t *testing.T) {
// This test checks that IP blocking happens BEFORE user blocking, since user blocking needs the request handler
// to be invoked while IP blocking doesn't
t.Run("stream-mixed-block", func(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
client, mt, cleanup := setup()
defer cleanup()

ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("user-id", "blocked-user-1", "x-forwarded-for", "1.2.3.4"))
stream, err := client.StreamPing(ctx)
10 changes: 5 additions & 5 deletions contrib/google.golang.org/grpc/grpc_test.go
Original file line number Diff line number Diff line change
@@ -39,11 +39,6 @@ import (
func TestUnary(t *testing.T) {
assert := assert.New(t)

rig, err := newRig(true, WithServiceName("grpc"), WithRequestTags())
require.NoError(t, err, "error setting up rig")
defer rig.Close()
client := rig.client

for name, tt := range map[string]struct {
message string
error bool
@@ -67,6 +62,11 @@ func TestUnary(t *testing.T) {
},
} {
t.Run(name, func(t *testing.T) {
rig, err := newRig(true, WithServiceName("grpc"), WithRequestTags())
require.NoError(t, err, "error setting up rig")
defer rig.Close()
client := rig.client

mt := mocktracer.Start()
defer mt.Stop()

41 changes: 41 additions & 0 deletions contrib/internal/fasthttptrace/fasthttpheaderscarrier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016 Datadog, Inc.

package fasthttptrace

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

"github.com/valyala/fasthttp"
)

// FastHTTPHeadersCarrier implements tracer.TextMapWriter and tracer.TextMapReader on top
// of fasthttp's RequestHeader object, allowing it to be used as a span context carrier for
// distributed tracing.
type FastHTTPHeadersCarrier struct {
ReqHeader *fasthttp.RequestHeader
}

var _ tracer.TextMapWriter = (*FastHTTPHeadersCarrier)(nil)
var _ tracer.TextMapReader = (*FastHTTPHeadersCarrier)(nil)

// ForeachKey iterates over fasthttp request header keys and values
func (f *FastHTTPHeadersCarrier) ForeachKey(handler func(key, val string) error) error {
keys := f.ReqHeader.PeekKeys()
for _, key := range keys {
sKey := string(key)
v := f.ReqHeader.Peek(sKey)
if err := handler(sKey, string(v)); err != nil {
return err
}
}
return nil
}

// Set adds the given value to request header for key. Key will be lowercased to match
// the metadata implementation.
func (f *FastHTTPHeadersCarrier) Set(key, val string) {
f.ReqHeader.Set(key, val)
}
Loading