ddtrace/tracer
Those integrations are enabled by having the
following import
in the project’s orchestrion.tool.go
file:
import (
_ "github.com/DataDog/orchestrion"
_ "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" // integration
//...
)
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer
Automatically starts the gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer at the start of the application, and closes it at exit of the main function.
Adding the //dd:span
directive on functions creates custom spans
representing every call to that function. The default operation (span) name
is the name of the function, and this can be overridden using a "span.name"
argument to the directive:
//dd:span span.name:custom-operation-name other:tag
func myFunction() {
// The default operation name would have been "myFunction"
}
Function literal expressions don't have a function name, and their default operation name is the value of the very first directive argument (if there is one). If there are no directive arguments, the operation name will remain blank.
//dd:span other:tag span.name:custom-operation-name
myOp := func() {
// The default operation name would have been "tag"
}
__dd_gls
runtime.g
unsafe
//go:linkname __dd_orchestrion_gls_get __dd_orchestrion_gls_get
var __dd_orchestrion_gls_get = func() any {
return getg().m.curg.__dd_gls
}
//go:linkname __dd_orchestrion_gls_set __dd_orchestrion_gls_set
var __dd_orchestrion_gls_set = func(val any) {
getg().m.curg.__dd_gls = val
}
goexit1
- Import path
runtime
- Function body
- Function declaration
- Function name
goexit1
getg().__dd_gls = nil
func main()
- Package name
main
- Is test main
false
- Function body
- Function declaration
- Function name
main
- Signature matches
- Arguments None
- Results None
// Using the following synthetic imports:
import (
tracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
func init() {
tracer.Start(tracer.WithOrchestrion(map[string]string{"version": {{printf "%q" Version}}}))
}
// Using the following synthetic imports:
import (
tracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
defer tracer.Stop()
//dd:span
- Has directive
//dd:span
// Using the following synthetic imports:
import (
context "context"
tracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
{{- $ctx := .Function.ArgumentOfType "context.Context" -}}
{{- $req := .Function.ArgumentOfType "*net/http.Request" -}}
{{- if (eq $ctx "") -}}
{{- $ctx = "ctx" -}}
ctx := {{- with $req -}}
{{ $req }}.Context()
{{- else -}}
context.TODO()
{{- end }}
{{ end -}}
{{ $functionName := .Function.Name -}}
{{- $opName := $functionName -}}
{{- range .DirectiveArgs "dd:span" -}}
{{- if eq $opName "" -}}
{{ $opName = .Value }}
{{- end -}}
{{- if eq .Key "span.name" -}}
{{- $opName = .Value -}}
{{- break -}}
{{- end -}}
{{- end -}}
var span tracer.Span
span, {{ $ctx }} = tracer.StartSpanFromContext({{ $ctx }}, {{ printf "%q" $opName }},
{{- with $functionName }}
tracer.Tag("function-name", {{ printf "%q" $functionName }}),
{{ end -}}
{{- range .DirectiveArgs "dd:span" }}
{{ if eq .Key "span.name" -}}{{- continue -}}{{- end -}}
tracer.Tag({{ printf "%q" .Key }}, {{ printf "%q" .Value }}),
{{- end }}
)
{{- with $req }}
{{ $req }} = {{ $req }}.WithContext({{ $ctx }})
{{- end }}
{{ with .Function.ResultOfType "error" -}}
defer func(){
span.Finish(tracer.WithError({{ . }}))
}()
{{ else -}}
defer span.Finish()
{{- end -}}
gopkg.in/DataDog/dd-trace-go.v1/internal/orchestrion
Operations that interact with Go's runtime system.
__dd_gls
runtime.g
unsafe
//go:linkname __dd_orchestrion_gls_get __dd_orchestrion_gls_get
var __dd_orchestrion_gls_get = func() any {
return getg().m.curg.__dd_gls
}
//go:linkname __dd_orchestrion_gls_set __dd_orchestrion_gls_set
var __dd_orchestrion_gls_set = func(val any) {
getg().m.curg.__dd_gls = val
}
goexit1
- Import path
runtime
- Function body
- Function declaration
- Function name
goexit1
getg().__dd_gls = nil