Skip to content

Commit

Permalink
Merge branch 'main' into mackjmr/add-aws-sdk-go-context-example
Browse files Browse the repository at this point in the history
  • Loading branch information
katiehockman committed Sep 28, 2023
2 parents 71f44a7 + 04c819d commit bec66de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions profiler/go_lt_1_21.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023 Datadog, Inc.

//go:build !go1.21

package profiler

func init() {
executionTraceEnabledDefault = false
}
8 changes: 7 additions & 1 deletion profiler/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,17 @@ type executionTraceConfig struct {
warned bool
}

// executionTraceEnabledDefault depends on the Go version and CPU architecture,
// see go_lt_1_21.go and this [article][] for more details.
//
// [article]: https://blog.felixge.de/waiting-for-go1-21-execution-tracing-with-less-than-one-percent-overhead/
var executionTraceEnabledDefault = runtime.GOARCH == "arm64" || runtime.GOARCH == "amd64"

// Refresh updates the execution trace configuration to reflect any run-time
// changes to the configuration environment variables, applying defaults as
// needed.
func (e *executionTraceConfig) Refresh() {
e.Enabled = internal.BoolEnv("DD_PROFILING_EXECUTION_TRACE_ENABLED", false)
e.Enabled = internal.BoolEnv("DD_PROFILING_EXECUTION_TRACE_ENABLED", executionTraceEnabledDefault)
e.Period = internal.DurationEnv("DD_PROFILING_EXECUTION_TRACE_PERIOD", 15*time.Minute)
e.Limit = internal.IntEnv("DD_PROFILING_EXECUTION_TRACE_LIMIT_BYTES", defaultExecutionTraceSizeLimit)

Expand Down
7 changes: 7 additions & 0 deletions profiler/profiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func TestProfilerPassthrough(t *testing.T) {
if testing.Short() {
return
}
beforeExecutionTraceEnabledDefault := executionTraceEnabledDefault
executionTraceEnabledDefault = false
defer func() { executionTraceEnabledDefault = beforeExecutionTraceEnabledDefault }()

out := make(chan batch)
p, err := newProfiler()
require.NoError(t, err)
Expand Down Expand Up @@ -378,6 +382,9 @@ func TestAllUploaded(t *testing.T) {
"goroutines.pprof",
"goroutineswait.pprof",
}
if executionTraceEnabledDefault && seq == 0 {
expected = append(expected, "go.trace")
}
assert.ElementsMatch(t, expected, profile.event.Attachments)

assert.Contains(t, profile.tags, fmt.Sprintf("profile_seq:%d", seq))
Expand Down

0 comments on commit bec66de

Please sign in to comment.