Go Tracer에는 Go 1.18+ 및 Datadog Agent >= 5.21.1이 필요합니다. Datadog의 Go 버전 및 프레임워크 지원(레거시 및 유지 관리 버전 포함) 전체 목록은 호환성 요구 사항 페이지를 참조하세요
Note: This documentation uses v2 of the Go tracer, which Datadog recommends for all users. If you are using v1, see the migration guide to upgrade to v2.
dd-trace-go를 Datadog의 통합 패키지와 함께 사용하여 사용자가 선택한 라이브러리에 관한 스팬을 자동으로 생성합니다. 이 옵션의 특징:
애플리케이션의 어느 부분을 추적할지 사용자에게 전적인 통제권을 부여합니다.
애플리케이션의 소스 코드를 수정해야 합니다.
아래에서 각 기본 설정에 해당하는 섹션의 지침을 참조하세요.
개요
Orchestrion은 컴파일 중에 Go 애플리케이션에 자동으로 계측을 추가하여 코드를 변경할 필요가 없습니다. 이렇게 하면 포괄적인 트레이싱 커버리지가 제공되고 독점 보안 기능이 활성화됩니다.
포괄적인 트레이싱 커버리지:
Go 표준 라이브러리를 포함해 코드 및 모든 종속성 계측
컴파일 중에 코드를 계측하여 간과된 수동 계측으로 인한 트레이싱 커버리지 빈틈 방지
독점적 App and API ProtectionExploit Prevention 기능. Exploit Prevention은 Runtime Application Self-Protection(RASP) 구현이며 Local File Inclusion(LFI)과 같은 RASP 방법을 포함합니다.
이제 orchestrion에서 다른 모든 종속성과 마찬가지로 go.mod 파일을 사용하여 종속성을 관리할 수 있습니다.
사용량
다음 중 한 가지 방법을 사용하여 빌드 프로세스에서 Orchestrion 활성화:
평소 사용하는 go 명령 앞에 orchestrion 추가:
orchestrion go build .
orchestrion go run .
orchestrion go test ./...
go 명령에 -toolexec="orchestrion toolexec" 인수 추가:
go build -toolexec="orchestrion toolexec" .
go run -toolexec="orchestrion toolexec" .
go test -toolexec="orchestrion toolexec" ./...
$GOFLAGS 환경 변수를 수정하여 Orchestrion을 주입하고, 평소처럼 go 명령 사용:
# Make sure to include the quotes as shown below, as these are required for# the Go toolchain to parse GOFLAGS properly!exportGOFLAGS="${GOFLAGS} '-toolexec=orchestrion toolexec'"go build .
go run .
go test ./...
트레이스 사용자 지정
Unified Service Tagging 설정
orchestrion으로 계측한 애플리케이션은 Unified Service Tagging(UST)을 지원합니다. 애플리케이션의 런타임 환경에서 해당하는 환경 변수를 설정하여 트레이스에 UST 태그를 설정할 수 있습니다.
//dd:span tag-name:spanName other-tag:bar span.name:operationNamefunctracedFunction(){// This function will be represented as a span named "operationName"}//dd:span tag-name:spanName other-tag:barfuncotherTracedFunction(){// This function will be represented as a span named "otherTracedFunction"}//dd:span tag-name:spanName other-tag:bartracedFunction:=func(){// This function will be represented as a span named "spanName"}
오류 결과
어노테이션된 함수가 error 결과를 반환하는 경우, 해당 함수가 반환한 모든 오류가 자동으로 상응하는 트레이스 스팬에 연결됩니다.
example.go
//dd:spanfuncfailableFunction()(any,error){// This span will have error information attached automatically.returnnil,errors.ErrUnsupported}
일부 코드의 계측 방지
//orchestrion:ignore 지시문을 사용하여 orchestrion이 어노테이션된 코드에서 아무런 수정도 수행하지 못하도록 방지할 수 있습니다.
이렇게 하면 호출자 측 계측이 특정 위치에 적용되지 않도록 방지할 수 있습니다.
example.go
import"database/sql"// Caller-side instrumentation normally happens within this function...funcnormal(){// The following assignment will NOT be modified to add any caller-side// instrumentation as it is opted out by the orchestrion:ignore directive://orchestrion:ignoredb,err:=sql.Open("driver-name","database=example")// ...}// Caller-side instrumentation will NOT happen in the following function// as it is annotated with orchestrion:ignore.//orchestrion:ignorefuncexcluded(){// The following assignment will NOT be modified to add any caller-side// instrumentation as the surrounding context is excluded by an// orchestrion:ignore directive:db,err:=sql.Open("driver-name","database=example")// ...}
orchestrion이 수행하는 계측 중 일부는 피호출자 측(또는 라이브러리 측)에서 수행되는데, 이는 통합이 종속성 자체 내에 직접 추가된다는 의미입니다. 이런 경우에는 해당 통합에서 로컬로 옵트아웃할 수 없습니다.
SDK 사용
Orchestrion으로 빌드한 애플리케이션에서 SDK를 사용할 수 있습니다. 이것은 Orchestrion으로 아직 지원되지 않는 프레임워크를 계측하는 데 유용합니다. 단, 이렇게 하면 Orchestrion 지원이 확장됨에 따라 향후 트레이스 스팬이 중복될 가능성이 있다는 점을 유의해야 합니다. orchestrion 종속성을 업데이트할 때 릴리스 노트를 검토하여 새 기능에 관한 최신 정보를 접하고 필요에 따라 수동 계측을 조정하세요.
Continuous Profiler 사용
Orchestrion으로 빌드한 애플리케이션에는 Continuous Profiler 계측이 포함되어 있습니다.
프로파일러를 활성화하려면 런타임에 DD_PROFILING_ENABLED=true 환경 변수를 설정하세요.
통합 제거
orchestrion.tool.go 파일에서 가져오기를 수정하여 통합을 제거할 수 있습니다.
orchestrion을 실행하기 전에 자체적으로 orchestrion.tool.go 파일을 생성할 수도 있습니다.
이 작업은 통합을 원하지 않는 경우,
또는 프로그램이 사용하지 않는 통합의 전이 종속성 수를 줄이고자 하는 경우에 할 수 있습니다.
기본적으로 Orchestrion은 github.com/DataDog/dd-trace-go/orchestrion/all/v2를 가져오며,
이것은 Orchestrion 통합이 있는 모든 라이브러리를 가져옵니다.
이 가져오기 대신 사용하려는 통합만 가져오기를 사용할 수 있습니다.
지원되는 통합 목록은 SDK 소스 코드를 참조하세요.
참고: 특정 통합을 가져오기로 하는 경우, 새 통합을 추가하고자 할 때마다 orchestrion.tool.go를 수동으로 업데이트해야 합니다.
스팬을 생성하려면 Go 통합을 활성화합니다. Datadog에는 일련의 플러그형 패키지가 있어서 일련의 라이브러리 및 프레임워크를 계측하기 위한 즉시 사용 가능한 지원을 제공합니다. 이러한 패키지 목록은 호환성 요구 사항 페이지에서 확인할 수 있습니다. 이러한 패키지를 애플리케이션에 가져온 다음 각 통합과 함께 목록으로 나열된 구성 지침을 따르세요.