Skip to content

Commit 2a5e619

Browse files
authored
Merge branch 'main' into rarguelloF/process-tags-profiling
2 parents 3f4df93 + b7ba964 commit 2a5e619

File tree

177 files changed

+8002
-6770
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+8002
-6770
lines changed

.github/workflows/all-green.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ jobs:
2121
with:
2222
initial-delay-seconds: "1000" # smoke tests takes approx 20 mn to finish
2323
max-retries: "60"
24+
ignored-name-patterns: |
25+
devflow/merge
26+
27+
# Reason for ignored-name-patterns:
28+
#
29+
# * devflow/merge: technical job used by the merge queue, do not remove it.

.github/workflows/apps/go.mod

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ require (
99

1010
require (
1111
github.com/DataDog/appsec-internal-go v1.12.0 // indirect
12-
github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.64.0-rc.1 // indirect
13-
github.com/DataDog/datadog-agent/pkg/obfuscate v0.64.0-rc.1 // indirect
14-
github.com/DataDog/datadog-agent/pkg/proto v0.64.0-rc.1 // indirect
15-
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.64.0-rc.1 // indirect
16-
github.com/DataDog/datadog-agent/pkg/trace v0.64.0-rc.1 // indirect
17-
github.com/DataDog/datadog-agent/pkg/util/log v0.64.0-rc.1 // indirect
18-
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.64.0-rc.1 // indirect
19-
github.com/DataDog/datadog-agent/pkg/version v0.64.0-rc.1 // indirect
12+
github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.66.0 // indirect
13+
github.com/DataDog/datadog-agent/pkg/obfuscate v0.66.0 // indirect
14+
github.com/DataDog/datadog-agent/pkg/proto v0.66.0 // indirect
15+
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.66.0 // indirect
16+
github.com/DataDog/datadog-agent/pkg/trace v0.66.0 // indirect
17+
github.com/DataDog/datadog-agent/pkg/util/log v0.66.0 // indirect
18+
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.66.0 // indirect
19+
github.com/DataDog/datadog-agent/pkg/version v0.66.0 // indirect
2020
github.com/DataDog/datadog-go/v5 v5.6.0 // indirect
2121
github.com/DataDog/go-libddwaf/v4 v4.1.0 // indirect
22-
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 // indirect
22+
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20250603194815-7edb7c2ad56a // indirect
2323
github.com/DataDog/go-sqllexer v0.1.6 // indirect
2424
github.com/DataDog/go-tuf v1.1.0-0.5.2 // indirect
2525
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.26.0 // indirect
@@ -52,25 +52,25 @@ require (
5252
github.com/tklauser/go-sysconf v0.3.14 // indirect
5353
github.com/tklauser/numcpus v0.8.0 // indirect
5454
github.com/yusufpapurcu/wmi v1.2.4 // indirect
55-
go.opentelemetry.io/collector/component v0.120.0 // indirect
56-
go.opentelemetry.io/collector/pdata v1.26.0 // indirect
57-
go.opentelemetry.io/collector/pdata/pprofile v0.120.0 // indirect
58-
go.opentelemetry.io/collector/semconv v0.120.0 // indirect
59-
go.opentelemetry.io/otel v1.34.0 // indirect
60-
go.opentelemetry.io/otel/metric v1.34.0 // indirect
61-
go.opentelemetry.io/otel/trace v1.34.0 // indirect
55+
go.opentelemetry.io/collector/component v1.28.1 // indirect
56+
go.opentelemetry.io/collector/pdata v1.28.1 // indirect
57+
go.opentelemetry.io/collector/pdata/pprofile v0.122.1 // indirect
58+
go.opentelemetry.io/collector/semconv v0.122.1 // indirect
59+
go.opentelemetry.io/otel v1.35.0 // indirect
60+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
61+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
6262
go.uber.org/atomic v1.11.0 // indirect
6363
go.uber.org/multierr v1.11.0 // indirect
6464
go.uber.org/zap v1.27.0 // indirect
6565
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
66-
golang.org/x/net v0.38.0 // indirect
66+
golang.org/x/net v0.39.0 // indirect
6767
golang.org/x/sys v0.33.0 // indirect
68-
golang.org/x/text v0.23.0 // indirect
69-
golang.org/x/time v0.9.0 // indirect
68+
golang.org/x/text v0.24.0 // indirect
69+
golang.org/x/time v0.11.0 // indirect
7070
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
71-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2 // indirect
72-
google.golang.org/grpc v1.70.0 // indirect
73-
google.golang.org/protobuf v1.36.5 // indirect
71+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250224174004-546df14abb99 // indirect
72+
google.golang.org/grpc v1.71.1 // indirect
73+
google.golang.org/protobuf v1.36.6 // indirect
7474
gopkg.in/ini.v1 v1.67.0 // indirect
7575
gopkg.in/yaml.v3 v3.0.1 // indirect
7676
)

.github/workflows/apps/go.sum

Lines changed: 78 additions & 75 deletions
Large diffs are not rendered by default.

.github/workflows/appsec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ jobs:
149149
echo "Skipped: env CGO_ENABLED=$cgo $appsec_enabled_env $cgocheck_env go test -v . (submodule: $submodule, reason: gin-gonic/gin depends on leodido/go-urn that causes an internal compiler when GOEXPERIMENT=cgocheck2)"
150150
continue
151151
fi
152+
152153
cd $submodule
153154
if ! env CGO_ENABLED=$cgo $appsec_enabled_env $cgocheck_env go test -v .; then
154155
echo "Failed: env CGO_ENABLED=$cgo $appsec_enabled_env $cgocheck_env go test -v . (submodule: $submodule)"
@@ -329,7 +330,6 @@ jobs:
329330
if: always()
330331
run: sudo docker rm --force test.runner || echo "Could not remove container"
331332

332-
# TODO(darccio): revert to use main on release
333333
test-app-smoke-tests:
334334
name: Smoke Tests
335335
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner == 'DataDog'

MIGRATING.md

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Migration Guide
1+
# Migration guide
22

33
This document outlines migrating from an older version of the Datadog tracer (v1.x.x) to v2.
44

@@ -10,7 +10,7 @@ We have also provided a new migration tool to help with the most essential chang
1010

1111
Our [godoc page](https://pkg.go.dev/github.com/DataDog/dd-trace-go/v2/ddtrace) should be helpful during this process. We also have the [official documentation](https://docs.datadoghq.com/tracing/setup/go/), which contains a couple of examples.
1212

13-
This document will further outline some _before_ and _after_ examples.
13+
Please follow this guide for migrating from v1 to v2 and creating new services using v2 directly. This document will further outline some _before_ and _after_ examples.
1414

1515
## Importing
1616

@@ -26,9 +26,21 @@ Becomes:
2626
import "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer"
2727
```
2828

29-
It is important to note that when using our contrib libraries, import URLs may be impacted differently. This will be covered in the next section:
29+
It is important to run `go mod tidy` after changing any import.
3030

31-
### Independent Contrib Packages
31+
It is also important to note that when using our contrib libraries, import URLs may be impacted differently. This will be covered in the section below [Independent contrib packages](#independent-contrib-packages).
32+
33+
### Gradual code repair
34+
35+
For customers that have large codebases and that are unable to immediately upgrade services to the v2 tracer, we are offering a special transitional version of the v1 tracer, the [v1 transitional version](https://pkg.go.dev/gopkg.in/DataDog/dd-trace-go.v1@v1.74.0) which is essentially a wrapper that preserves the API from v1 but uses v2 under the hood.
36+
37+
It’s safe for different services within your organization to use different tracer versions during the transition, some can use v1 while others adopt v2. Staggering the upgrade per service can minimize downtime and help ensure stability throughout your transition.
38+
39+
The transitional version is the only v1 version that allows both v1 and v2 to be imported in the same service, which enables you to migrate a service gradually. Using this v1 transitional version doesn’t require any code changes, but it also won’t support any new features introduced in v2.
40+
41+
When using the v1 transitional version, it is possible to gradually migrate a codebase to v2 by replacing imports and adapting the instrumentation to the new API file by file.
42+
43+
### Independent contrib packages
3244

3345
This version upgrade comes with a large overhaul of what was previously one single package that held all of our integrations. In v2, we introduce independent packages for each of our contribs, which will prevent false-positives in security scanners that were caused by indirect dependencies. As a result, importing contribs will also change. Before:
3446

@@ -59,7 +71,7 @@ var sp *tracer.Span = tracer.StartSpan("opname")
5971
var ctx *tracer.SpanContext = sp.Context()
6072
```
6173

62-
### Deprecated ddtrace interfaces
74+
### Deprecated `ddtrace` interfaces
6375

6476
All the interfaces in `ddtrace` have been removed in favor of struct types, except for `SpanContext`. The new types have moved into `ddtrace/tracer`.
6577

@@ -126,7 +138,7 @@ fmt.Printf("traceID: %d\n", sp.Context().TraceIDLower()) // for maintaining old
126138

127139
## WithService
128140

129-
The previously deprecated `tracer.WithServiceName()` has been fully removed and replaced with the method `tracer.WithService()`. If you would like to specify a service name upon starting the tracer, you would have before:
141+
The previously deprecated `tracer.WithServiceName` has been fully removed and replaced with the method `tracer.WithService`. If you would like to specify a service name upon starting the tracer, you would have before:
130142

131143
```go
132144
tracer.Start(tracer.WithServiceName("service"))
@@ -138,7 +150,29 @@ After:
138150
tracer.Start(tracer.WithService("service"))
139151
```
140152

141-
## NewStartSpanConfig, WithStartSpanConfig & WithFinishConfig
153+
## WithDogstatsdAddress
154+
155+
`tracer.WithDogstatsdAddr` has been renamed as `tracer.WithDogstatsdAddress`. If you would like to specify a different DogStatsD address upon starting the tracer, you would have before:
156+
157+
```go
158+
tracer.Start(tracer.WithDogstatsdAddr("10.1.0.12:4002"))
159+
```
160+
161+
After:
162+
163+
```go
164+
tracer.Start(tracer.WithDogstatsdAddress("10.1.0.12:4002"))
165+
```
166+
167+
## WithAgentURL
168+
169+
`tracer.WithAgentURL` sets the address by URL where the agent is located, in addition to the existing `WithAgentAddr` option. It is useful for setups where the agent is listening to a Unix Domain Socket:
170+
171+
```go
172+
tracer.Start(tracer.WithAgentURL("unix:///var/run/datadog/apm.socket"))
173+
```
174+
175+
## NewStartSpanConfig, WithStartSpanConfig, NewFinishConfig & WithFinishConfig
142176

143177
These functional options for `ddtrace/tracer.Tracer.StartSpan` and `ddtrace/tracer.Span.Finish` reduces the number of calls (in functional option form) in hot loops by giving the freedom to prepare a common span configuration in hot paths.
144178

@@ -169,9 +203,9 @@ cfg := tracer.NewStartSpanConfig(
169203
tracer.SpanType(ext.SpanTypeWeb),
170204
tracer.Tag("key", "value"),
171205
)
172-
finishCfg := &FinishConfig{
173-
NoDebugStack: true,
174-
}
206+
finishCfg := tracer.NewFinishConfig(
207+
NoDebugStack(),
208+
)
175209
// [...]
176210
// Reuse the configuration in your hot path:
177211
span := tracer.StartSpan("operation", tracer.WithStartSpanConfig(cfg))
@@ -197,7 +231,7 @@ Also, `ext.SamplingPriority` tag is deprecated. Use `ext.ManualKeep` and `ext.Ma
197231

198232
A support package to create contribs without depending on internal packages is available in `instrumentation`. Please refer to [`instrumentation` godoc page](https://pkg.go.dev/github.com/DataDog/dd-trace-go/v2/instrumentation) and existing contribs for more detail.
199233

200-
## Updated User Monitoring SDK for Appsec
234+
## Updated User Monitoring SDK for `appsec`
201235

202236
`appsec` package offers a new API for user monitoring; essentially deprecating login success & failure event functions, replacing them with versions that accept a `login` field, which is to be used by user monitoring rules (ATO monitoring & protection). Before:
203237

@@ -221,6 +255,26 @@ The API Security sampler now takes decisions specific to a given endpoint (metho
221255

222256
`opentracer` is in "Maintenance" mode and limited support was offered in `v1`. We recommend to use OpenTelemetry or ddtrace/tracer directly. For additional details, please see our [Support Policy](https://github.com/DataDog/dd-trace-go?tab=readme-ov-file#go-support-policy).
223257

258+
## SQLCommentInjectionMode deprecation for DBM
259+
260+
`SQLCommentInjectionMode` values have been replaced by `DBMPropagationMode` values. Before:
261+
262+
```go
263+
SQLInjectionUndefined // SQLInjectionUndefined represents the comment injection mode is not set. This is the same as SQLInjectionDisabled.
264+
SQLInjectionDisabled // SQLInjectionDisabled represents the comment injection mode where all injection is disabled.
265+
SQLInjectionModeService // SQLInjectionModeService represents the comment injection mode where only service tags (name, env, version) are injected.
266+
SQLInjectionModeFull // SQLInjectionModeFull represents the comment injection mode where both service tags and tracing tags. Tracing tags include span id, trace id and sampling priority.
267+
```
268+
269+
After:
270+
271+
```go
272+
DBMPropagationModeUndefined // DBMPropagationModeUndefined represents the dbm propagation mode not being set. This is the same as DBMPropagationModeDisabled.
273+
DBMPropagationModeDisabled // DBMPropagationModeDisabled represents the dbm propagation mode where all propagation is disabled.
274+
DBMPropagationModeService // DBMPropagationModeService represents the dbm propagation mode where only service tags (name, env, version) are propagated to dbm.
275+
DBMPropagationModeFull // DBMPropagationModeFull represents the dbm propagation mode where both service tags and tracing tags are propagated. Tracing tags include span id, trace id and the sampled flag.
276+
```
277+
224278
## Further reading
225279

226280
* package level documentation of the [`tracer` package](https://pkg.go.dev/github.com/DataDog/dd-trace-go/v2/ddtrace/tracer) for a better overview.

appsec/appsec.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ func MonitorParsedHTTPBody(ctx context.Context, body any) error {
5050
return httpsec.MonitorParsedBody(ctx, body)
5151
}
5252

53+
// MonitorHTTPResponseBody runs the security monitoring rules on the given
54+
// response body (in object form, not encoded as the literal HTTP response body
55+
// payload bytes), and returns an error if the HTTP response is configured to be
56+
// blocked. The given context must be the HTTP request context as returned by
57+
// the [net/http.Request.Context] method, or equivalent. Calls to this function
58+
// are ignored if AppSec is disabled or the provided context is incorrect.
59+
func MonitorHTTPResponseBody(ctx context.Context, body any) error {
60+
if !appsec.Enabled() {
61+
appsecDisabledLog.Do(func() { log.Warn("appsec: not enabled. Body blocking checks won't be performed.") })
62+
return nil
63+
}
64+
return httpsec.MonitorResponseBody(ctx, body)
65+
}
66+
5367
// SetUser wraps [tracer.SetUser] and extends it with user blocking.
5468
// On top of associating the authenticated user information to the service entry span,
5569
// it checks whether the given user ID is blocked or not by returning an error when it is.

contrib/99designs/gqlgen/go.mod

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ require (
1111

1212
require (
1313
github.com/DataDog/appsec-internal-go v1.12.0 // indirect
14-
github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.64.0-rc.1 // indirect
15-
github.com/DataDog/datadog-agent/pkg/obfuscate v0.64.0-rc.1 // indirect
16-
github.com/DataDog/datadog-agent/pkg/proto v0.64.0-rc.1 // indirect
17-
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.64.0-rc.1 // indirect
18-
github.com/DataDog/datadog-agent/pkg/trace v0.64.0-rc.1 // indirect
19-
github.com/DataDog/datadog-agent/pkg/util/log v0.64.0-rc.1 // indirect
20-
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.64.0-rc.1 // indirect
21-
github.com/DataDog/datadog-agent/pkg/version v0.64.0-rc.1 // indirect
14+
github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.66.0 // indirect
15+
github.com/DataDog/datadog-agent/pkg/obfuscate v0.66.0 // indirect
16+
github.com/DataDog/datadog-agent/pkg/proto v0.66.0 // indirect
17+
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.66.0 // indirect
18+
github.com/DataDog/datadog-agent/pkg/trace v0.66.0 // indirect
19+
github.com/DataDog/datadog-agent/pkg/util/log v0.66.0 // indirect
20+
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.66.0 // indirect
21+
github.com/DataDog/datadog-agent/pkg/version v0.66.0 // indirect
2222
github.com/DataDog/datadog-go/v5 v5.6.0 // indirect
2323
github.com/DataDog/go-libddwaf/v4 v4.1.0 // indirect
24-
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20241206090539-a14610dc22b6 // indirect
24+
github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20250603194815-7edb7c2ad56a // indirect
2525
github.com/DataDog/go-sqllexer v0.1.6 // indirect
2626
github.com/DataDog/go-tuf v1.1.0-0.5.2 // indirect
2727
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.26.0 // indirect
@@ -60,26 +60,26 @@ require (
6060
github.com/tklauser/go-sysconf v0.3.14 // indirect
6161
github.com/tklauser/numcpus v0.8.0 // indirect
6262
github.com/yusufpapurcu/wmi v1.2.4 // indirect
63-
go.opentelemetry.io/collector/component v0.120.0 // indirect
64-
go.opentelemetry.io/collector/pdata v1.26.0 // indirect
65-
go.opentelemetry.io/collector/pdata/pprofile v0.120.0 // indirect
66-
go.opentelemetry.io/collector/semconv v0.120.0 // indirect
67-
go.opentelemetry.io/otel v1.34.0 // indirect
68-
go.opentelemetry.io/otel/metric v1.34.0 // indirect
69-
go.opentelemetry.io/otel/trace v1.34.0 // indirect
63+
go.opentelemetry.io/collector/component v1.28.1 // indirect
64+
go.opentelemetry.io/collector/pdata v1.28.1 // indirect
65+
go.opentelemetry.io/collector/pdata/pprofile v0.122.1 // indirect
66+
go.opentelemetry.io/collector/semconv v0.122.1 // indirect
67+
go.opentelemetry.io/otel v1.35.0 // indirect
68+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
69+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
7070
go.uber.org/atomic v1.11.0 // indirect
7171
go.uber.org/multierr v1.11.0 // indirect
7272
go.uber.org/zap v1.27.0 // indirect
7373
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
7474
golang.org/x/mod v0.23.0 // indirect
75-
golang.org/x/net v0.38.0 // indirect
75+
golang.org/x/net v0.39.0 // indirect
7676
golang.org/x/sys v0.33.0 // indirect
77-
golang.org/x/text v0.23.0 // indirect
78-
golang.org/x/time v0.9.0 // indirect
77+
golang.org/x/text v0.24.0 // indirect
78+
golang.org/x/time v0.11.0 // indirect
7979
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
80-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2 // indirect
81-
google.golang.org/grpc v1.70.0 // indirect
82-
google.golang.org/protobuf v1.36.5 // indirect
80+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250224174004-546df14abb99 // indirect
81+
google.golang.org/grpc v1.71.1 // indirect
82+
google.golang.org/protobuf v1.36.6 // indirect
8383
gopkg.in/ini.v1 v1.67.0 // indirect
8484
gopkg.in/yaml.v3 v3.0.1 // indirect
8585
)

0 commit comments

Comments
 (0)