이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Manual injection

The Go tracer API allows printing span information along with log statements using the %v format specifier:

package main

import (
    "net/http"

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

func handler(w http.ResponseWriter, r *http.Request) {
    // Create a span for a web request at the /posts URL.
    span := tracer.StartSpan("web.request", tracer.ResourceName("/posts"))
    defer span.Finish()

    // Append span info to log messages:
    log.Printf("my log message %v", span)
}

The above example illustrates how to use the span’s context in the standard library’s log package. Similar logic may be applied to third party packages too.

Note: If you are not using a Datadog Log Integration to parse your logs, custom log parsing rules need to ensure that dd.trace_id, dd.span_id, dd.service, dd.env and dd.version are being parsed as strings. More information can be found in Correlated Logs Not Showing Up in the Trace ID Panel.

Further Reading