runtime

Operations that interact with Go’s runtime system.

⚠️
This configuration introduces a way to access the Goroutine Local Storage (GLS), which is not meant to be used directly by end-users. This is intended to be used only by tracer internals to enable trace context forwarding in places where a context.Context value is not available.

GLS Access

Join Point
Definition of runtime.g
Advice
Add new field __dd_gls of type any.
Advice
Add blank import of unsafe
Advice
Introduce new declarations:
//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
}

Clear GLS slot on goroutine exit

Join Point
All of
  • Import path runtime
  • Function body
    • Function declaration
      • Function name goexit1
Advice
Prepend statements produced by the following template:
getg().__dd_gls = nil

Hack tracer.SpanFromContext

Join Point
All of
Advice
Prepend statements produced by the following template:
// Using the following synthetic imports:
import (
	traceinternal "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/internal"
)
{{- $span := .Function.Result 0 -}}
{{- $ok := .Function.Result 1 -}}
defer func(){
	if !{{ $ok }} {
		return
	}
	switch {{ $span }}.(type) {
	case traceinternal.NoopSpan, *traceinternal.NoopSpan:
		{{ $ok }} = false
	}
}()