Skip to content
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

fix: WithStackTrace option on AddEvent method #2336

Conversation

marcaudefroy
Copy link

Signed-off-by: marc audefroy marc.audefroy@corp.ovh.com

Signed-off-by: marc audefroy <marc.audefroy@corp.ovh.com>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 29, 2021

CLA Signed

The committers are authorized under a signed CLA.

@marcaudefroy
Copy link
Author

marcaudefroy commented Oct 29, 2021

Hi, this PR is related to this PR: #2163

Comment on lines +333 to +337
if c.StackTrace() {
o = append(o, trace.WithAttributes(
semconv.ExceptionStacktraceKey.String(recordStackTrace()),
))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to allow adding a stack trace to all events then we should just move this into span.addEvent() and avoid calling trace.NewEventConfig() multiple times.

That said, I'm not sure it is correct to do this. The semantic conventions for the attribute key it is using relate to exceptions/errors. If there is no error being recorded then we should either not record a stack trace or we should record it using a different convention. To use a different convention we'd need to work that through the spec SIG to get agreement on the new convention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, I'm not sure it is correct to do this. The semantic conventions for the attribute key it is using relate to exceptions/errors. If there is no error being recorded then we should either not record a stack trace or we should record it using a different convention. To use a different convention we'd need to work that through the spec SIG to get agreement on the new convention.

That's a good point. Storing this under the exception semantic convention name does sound incorrect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you for the semantic convention.

"To use a different convention we'd need to work that through the spec SIG to get agreement on the new convention." => Or maybe add a stacktrace into an event for a no error/exception is just a bad idea and we must decline this PR. I create it 'cause it was weird to can add a stacktrace config to an event without it being taken into account.

@@ -328,6 +328,14 @@ func (s *recordingSpan) AddEvent(name string, o ...trace.EventOption) {
if !s.IsRecording() {
return
}

c := trace.NewEventConfig(o...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to the wrapped addEvent method instead so we do not parse the EventConfig twice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll also mean removing the similar logic from RecordError() and End() to avoid building and setting the stack trace twice.

Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, supporting this option in the AddEvent method seems like a good idea. One comment on where we are adding the code though.

@MrAlias
Copy link
Contributor

MrAlias commented Nov 22, 2021

I'm going to close this for now given there isn't a clear path forward. Please reopen if this is in error or we resolve this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants