-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle special cases for span frames min duration #1188
handle special cases for span frames min duration #1188
Conversation
cases: 0: never capture stacktraces -1: always capture stacktraces
switch s.stackFramesMinDuration { | ||
case -1: | ||
// Always set stacktrace | ||
s.setStacktrace(1) | ||
case 0: | ||
// If s.stackFramesMinDuration == 0, we never set stacktrace. | ||
default: | ||
if !s.dropped() && len(s.stacktrace) == 0 && | ||
s.Duration >= s.stackFramesMinDuration { | ||
s.setStacktrace(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could have been squished into a single conditional, and I'm happy to do so. This just seemed to be more easy to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Maybe we can revisit when we get to #1142
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
span_test.go
Outdated
|
||
spans = tracer.Payloads().Spans | ||
require.Len(t, spans, 1) | ||
assert.Len(t, spans[0].Stacktrace, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just check it's non-empty? The Go runtime or testing package might add more frames in the future.
Verified using package main
import (
"time"
"go.elastic.co/apm/v2"
)
func main() {
tracer := apm.DefaultTracer()
defer tracer.Flush(nil)
tx := tracer.StartTransaction("name", "type")
defer tx.End()
span := tx.StartSpan("name", "type", nil)
time.Sleep(5 * time.Millisecond)
span.End()
}
|
cases:
0: never capture stacktraces
-1: always capture stacktraces
Closes #465