crashtracker

Those integration are enabled by having the following import in the project’s orchestrion.tool.go file:

import (
	_ "github.com/DataDog/orchestrion"

	_ "github.com/DataDog/dd-trace-go/v2/crashtracker" // integration
	//...
)

Starts the Datadog crashtracker as the first statement of main(), so the monitor process is established before any goroutine can crash. The injected start uses DD_* environment configuration; a later programmatic Start call in main is a no-op because crashtracker keeps the first successful start.

Ordering with respect to the tracer and profiler: the tracer and profiler aspects use inject-declarations to emit func init() calls, which run before main() starts. This aspect uses prepend-statements inside main(), so crashtracker.Start() always runs after the tracer starts, and resolveService reads the tracer-attributed service name from globalconfig. The call site also matches crashtracker/doc.go, which says to call Start as early as possible in main.

The tracer and profiler also each prepend a defer ...Stop() into main(), and neither sets an explicit order, so without one here the three prepended blocks sorted and applied in declaration order alone – observed to place crashtracker's call third in the generated code, after both defer statements. prepend-statements always inserts at the front of whatever the block already contains, so the advice applied LAST ends up FIRST in the generated code; crashtracker's default-order block was simply applied before the other two. A defer doesn't run anything before crashtracker.Start(), but the ordering was otherwise unpinned: a future default-order advice that runs real code, not just a defer, could apply even later and still land ahead of it. The explicit high order below (matching instrumentation/errortrace/orchestrion.yml's own order: 100) guarantees this block applies last, and therefore lands first in the generated code, regardless of what else targets this join point.

Note: crashes that occur during init() functions (before main() is reached) are not captured because SetCrashOutput is wired inside crashtracker.Start().

func main()

Join Point
All of
  • Package name main
  • Is test main false
  • Function body
    • Function declaration
      • Function name main
      • Signature matches
        • Arguments None
        • Results None
Advice
Prepend statements produced by the following template:
// Using the following synthetic imports:
import (
	crashtracker "github.com/DataDog/dd-trace-go/v2/crashtracker"
	log "log"
)
if err := crashtracker.Start(); err != nil {
	log.Printf("failed to start crashtracker: %s", err.Error())
}