allow skipping callstack in errors and events

This commit is contained in:
2024-05-20 13:39:55 +02:00
parent c70a285e70
commit f5819972a4
3 changed files with 13 additions and 3 deletions

View File

@ -47,6 +47,11 @@ func (e Event) AsOpts() trace.EventOption {
return trace.WithAttributes(e.IntoTraceAttributes()...)
}
func (e Event) SkipMoreInCallStack(skip int) Event {
e.extraSkipInStack += skip
return e
}
func NewInSpan[E IntoEvent](ev E, span trace.Span) {
event := ev.IntoEvent()
event.extraSkipInStack += 1
@ -93,6 +98,11 @@ func (e Error) AsOpts() trace.EventOption {
return trace.WithAttributes(e.IntoTraceAttributes()...)
}
func (e Error) SkipMoreInCallStack(skip int) Error {
e.extraSkipInStack += skip
return e
}
func NewErrInSpan[E IntoErrorEvent](err E, span trace.Span) E {
er := err.IntoErrorEvent()
er.extraSkipInStack += 1