You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document outlines migrating from an older version of the Datadog tracer (v1.x.x) to v2.
4
4
5
-
Datadog's v2 version of the Go tracer provides a huge refactor of our API, moving away from interfaces to provide flexibility in future works, isolating our integrations to prevent false-positives from security scanners, and enforcing proper library patterns to prevent misuse. This update is the result of continuous feedback from customers, the community, as well as our extensive internal usage.
5
+
Datadog's v2 version of the Go tracer provides a significant refactor of our API, moving away from interfaces to provide flexibility in future works, isolating our integrations to prevent false-positives from security scanners, and enforcing proper library patterns to prevent misuse. This update is the result of continuous feedback from customers, the community, as well as our extensive internal usage, introducing better maintainability, simplified APIs, and unlocking performance benefits.
6
6
7
7
As is common and recommended in the Go community, the best way to approach migrating to this new API is by using the [gradual code repair](https://talks.golang.org/2016/refactor.article) method. We have done the same internally and it has worked just great! For this exact reason we have provided a new, [semver](https://semver.org/) friendly import path to help with using both tracers in parallel, without conflict, for the duration of the migration. This new path is `github.com/DataDog/dd-trace-go/v2`.
8
8
9
9
We have also provided a new migration tool to help with the most essential changes made in v2, which you can read about [here](./tools/v2fix/README.md).
10
10
11
-
Our [godoc page](https://godoc.org/github.com/DataDog/dd-trace-go/v2/ddtrace) should deem helpful during this process. We also have the [official documentation](https://docs.datadoghq.com/tracing/setup/go/), which contains a couple of examples.
11
+
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.
12
12
13
13
This document will further outline some _before_ and _after_ examples.
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:
30
30
31
-
## Independent Contrib Packages
31
+
###Independent Contrib Packages
32
32
33
33
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:
34
34
@@ -59,18 +59,48 @@ var sp *tracer.Span = tracer.StartSpan("opname")
59
59
varctx *tracer.SpanContext = sp.Context()
60
60
```
61
61
62
-
##WithService()
62
+
### Deprecated ddtrace interfaces
63
63
64
-
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:
64
+
All the interfaces in `ddtrace` have been removed in favor of struct types, except for `SpanContext`. The new types have moved into `ddtrace/tracer`.
65
+
66
+
### Deprecated constants and options
67
+
68
+
The following constants and functions have been removed:
69
+
70
+
*`ddtrace/ext.AppTypeWeb`
71
+
*`ddtrace/ext.CassandraQuery`
72
+
*`ddtrace/ext.CassandraBatch`
73
+
*`ddtrace/tracer.WithPrioritySampling`; priority sampling is enabled by default.
74
+
*`ddtrace/tracer.WithHTTPRoundTripper`; use `WithHTTPClient` instead.
75
+
76
+
### StartChild
77
+
78
+
Child spans can be started with StartChild rather than ChildOf. Before:
@@ -90,9 +120,108 @@ fmt.Printf("traceID: %s\n", sp.Context().TraceID()) //recommended for using 128-
90
120
fmt.Printf("traceID: %d\n", sp.Context().TraceIDLower()) // for maintaining old behavior with 64-bit IDs
91
121
```
92
122
93
-
## Further reading
123
+
## Span Links API
124
+
125
+
`Span.AddSpanLink` has been renamed to `Span.AddLink`.
126
+
127
+
## WithService
128
+
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:
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.
The following functions have been removed in favour of `SpanSamplingRules` and `TraceSamplingRules`:
184
+
185
+
*`NameRule`
186
+
*`NameServiceRule`
187
+
*`RateRule`
188
+
*`ServiceRule`
189
+
*`SpanNameServiceMPSRule`
190
+
*`SpanNameServiceRule`
191
+
*`SpanTagsResourceRule`
192
+
*`TagsResourceRule`
193
+
194
+
Also, `ext.SamplingPriority` tag is deprecated. Use `ext.ManualKeep` and `ext.ManualDrop` instead.
195
+
196
+
## Contrib API
197
+
198
+
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.
199
+
200
+
## Updated User Monitoring SDK for Appsec
201
+
202
+
`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:
203
+
204
+
```go
205
+
appsec.TrackUserLoginSuccessEvent(...)
206
+
appsec.TrackUserLoginFailureEvent(...)
207
+
```
208
+
209
+
Becomes:
210
+
211
+
```go
212
+
appsec.TrackUserLoginSuccess(...)
213
+
appsec.TrackUserLoginFailure(...)
214
+
```
215
+
216
+
## API Security sampling
217
+
218
+
The API Security sampler now takes decisions specific to a given endpoint (method + route + response status code) instead of using a simplistic sampling rate. This allows for improved coverage and accuracy of schema extraction as part of API Security.
219
+
220
+
## Opentracing deprecation
221
+
222
+
`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).
94
223
95
-
The new version of the tracer also comes with a lot of new features, such as support for distributed tracing and distributed sampling priority.
224
+
## Further reading
96
225
97
-
* package level documentation of the [`tracer` package](https://godoc.org/github.com/DataDog/dd-trace-go/v2/ddtrace/tracer) for a better overview.
226
+
* package level documentation of the [`tracer` package](https://pkg.go.dev/github.com/DataDog/dd-trace-go/v2/ddtrace/tracer) for a better overview.
The purpose of these packages is to provide tracing on top of commonly used packages from the standard library as well as the
4
4
community in a "plug-and-play" manner. This means that by simply importing the appropriate path, functions are exposed having
@@ -34,7 +34,7 @@ Third, some guidelines to follow on naming functions:
34
34
35
35
* Use `WithService` instead of `WithServiceName` when setting the service name.
36
36
37
-
Each integration comes with a thorough documentation and usage examples. A good overview can be seen on our [godoc](https://godoc.org/github.com/DataDog/dd-trace-go/v2/contrib) page.
37
+
Each integration comes with a thorough documentation and usage examples. A good overview can be seen on our [godoc](https://pkg.go.dev/github.com/DataDog/dd-trace-go/v2/contrib) page.
0 commit comments