func main()

The entry point of a Go program.

Start Datadog Tracer and Profiler

Join Point
All of
  • Package namemain
  • Function body
    • Function declaration
      • Function namemain
      • Signature matches
        • ArgumentsNone
        • Return ValuesNone
Advice
Prepend statements produced by the following template:
// Using the following synthetic imports:
import (
	log      "log"
	os       "os"
	profiler "gopkg.in/DataDog/dd-trace-go.v1/profiler"
	tracer   "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
tracer.Start(tracer.WithOrchestrion(map[string]string{"version": {{printf "%q" Version}}}))
defer tracer.Stop()

switch os.Getenv("DD_PROFILING_ENABLED") {
case "1", "true", "auto":
	// The "auto" value can be set if profiling is enabled via the
	// Datadog Admission Controller. We always turn on the profiler in
	// the "auto" case since we only send profiles after at least a
	// minute, and we assume anything running that long is worth
	// profiling.
	err := profiler.Start(
		profiler.WithProfileTypes(
			profiler.CPUProfile,
			profiler.HeapProfile,
			// Non-default profiles which are highly likely to be useful:
			profiler.GoroutineProfile,
			profiler.MutexProfile,
		),
		profiler.WithTags("orchestrion:true"),
	)
	if err != nil {
		// TODO: is there a better reporting mechanism?
		// The tracer and profiler already use the stdlib logger, so
		// we're not adding anything new. But users might be using a
		// different logger.
		log.Printf("failed to start profiling: %s", err)
	}
	defer profiler.Stop()
}