Skip to content

Misleading description of IsRecording() in trace API #3006

@utezduyar

Description

@utezduyar

I believe the text below from the spec misleading.

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md
IsRecording
Returns true if this Span is recording information like events with the AddEvent operation, attributes using SetAttributes, status with SetStatus, etc.

The text makes me think that if any of these APIs (AddEvent, SetAttribute..) are called, the recording status will be TRUE. Seems like IsRecording returns True if the Span is sampled and the sample hasn't ended. At least the go implementation tells me that.

// IsRecording returns if this span is being recorded. If this span has ended
// this will return false.
func (s *recordingSpan) IsRecording() bool {
	if s == nil {
		return false
	}
	s.mu.Lock()
	defer s.mu.Unlock()

	return s.endTime.IsZero()
}

I believe the current text is valuable but needs to be added in a way that none of these APIs (AddEvent, SetAttribute..) will work (in other terms will be NOOP) after the span is ended. I would be happy to send a patch if I have a point.

Metadata

Metadata

Assignees

Labels

area:apiCross language API specification issueeditorialEditorial changes only (typos, changelog, ...). No content-related changes of any kind.spec:traceRelated to the specification/trace directory

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions