- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
The Go tracer v2 introduces API improvements, better performance, and enhanced compatibility with modern Go practices. It represents the latest stable version of Datadog’s Go tracing library.
When deciding which version of the Go tracer to use, consider the following guidance:
While v1 remains available, v2 is Datadog’s primary supported version. All v1 releases starting from v1.74.0 will not contain new features and are instead considered a transitional release. These releases maintain the v1 API while using v2 under the hood. Using a transitional v1 version together with v2 allows you to migrate your services gradually.
The first transitional release is planned for May 2025. After the v2 release, support for v1 will be as follows:
For more compatibility and support details, see Go Library Compatibility.
Different Datadog products have specific considerations when migrating from v1 to v2. Here is what you need to know for each.
The v2 tracing API offers significant improvements while maintaining a similar developer experience. The migration typically involves updating import paths and adapting to some API changes.
Supported frameworks have changed between v1 and v2 of the Go tracer.
For more information, see Go Library Compatibility.
For the Profiler, only import paths need to be updated. The profiling API functionality remains the same between v1 and v2.
Supported packages have changed between v1 and v2 of the Go tracer.
For more information, see ASM language and framework compatibility.
Only import paths need to be updated. The framework support for SCA is the same between v1 and v2.
The Go tracer v2 introduces several important improvements:
gopkg.in
to the standard GitHub import path for better compatibility with Go modules.Datadog provides a migration tool that automatically handles most code updates when upgrading from v1 to v2.
To check for updates, run the following command:
go install github.com/DataDog/dd-trace-go/tools/v2fix@latest
# In your repository's directory
v2fix .
To apply all suggested fixes, run:
v2fix -fix .
The tool makes the following changes:
gopkg.in/DataDog/dd-trace-go.v1
to github.com/DataDog/dd-trace-go/v2
.ddtrace/tracer
to ddtrace
where appropriate.Span
and SpanContext
calls to use pointers.WithServiceName()
calls with WithService()
.TraceID()
calls to TraceIDLower()
for obtaining uint64
trace IDs.Change all imports from:
import "gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
import "gopkg.in/DataDog/dd-trace-go.v1/profiler"
To:
import "github.com/DataDog/dd-trace-go/v2/ddtrace"
import "github.com/DataDog/dd-trace-go/v2/profiler"
The package organization has changed in v2. Many functions previously in ddtrace
have been moved to the ddtrace/tracer
package. While the v2fix
migration tool handles these changes automatically, you may need to manually update some import paths.
v1:
import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
func main() {
tracer.Start()
defer tracer.Stop()
s := tracer.StartSpan("op")
var ctx ddtrace.SpanContext = s.Context()
}
v2:
import "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer"
func main() {
tracer.Start()
defer tracer.Stop()
s := tracer.StartSpan("op")
var ctx *tracer.SpanContext = s.Context()
}
Improvements to the API have caused some functions to change. For example, child spans are started with StartChild
rather than ChildOf
:
v1:
import "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
func main() {
tracer.Start()
defer tracer.Stop()
parent := tracer.StartSpan("op").Context()
child := tracer.StartSpan("op", tracer.ChildOf(parent))
}
v2:
import "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer"
func main() {
tracer.Start()
defer tracer.Stop()
parent := tracer.StartSpan("op")
child := parent.StartChild("op")
}
The WithServiceName()
option has been replaced with WithService()
for consistency:
// v1
tracer.Start(tracer.WithServiceName("my-service"))
// v2
ddtrace.Start(ddtrace.WithService("my-service"))
For more information, see the godoc page for dd-trace-go v2.
추가 유용한 문서, 링크 및 기사: