Skip to content

Commit

Permalink
Removed setting error status while recording err as span event (#1663)
Browse files Browse the repository at this point in the history
* Fix #1661 Removed setting error status while recording err as span event

* Update CHANGELOG.md

Co-authored-by: Anthony Mirabella <[email protected]>

* Update RecordError method doc

Co-authored-by: Tyler Yahn <[email protected]>

* Fix grammatical errors in Changelog

Co-authored-by: Tyler Yahn <[email protected]>

* Update RecordError method doc

Co-authored-by: Anthony Mirabella <[email protected]>
Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
3 people authored Mar 8, 2021
1 parent e981475 commit a5edd79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added `Marshler` config option to `otlphttp` to enable otlp over json or protobufs. (#1586)
- A `ForceFlush` method to the `"go.opentelemetry.io/otel/sdk/trace".TracerProvider` to flush all registered `SpanProcessor`s. (#1608)


### Changed

- Update the `ForceFlush` method signature to the `"go.opentelemetry.io/otel/sdk/trace".SpanProcessor` to accept a `context.Context` and return an error. (#1608)
Expand All @@ -26,6 +27,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Removed the exported `SimpleSpanProcessor` and `BatchSpanProcessor` structs.
These are now returned as a SpanProcessor interface from their respective constructors. (#1638)
- Removed setting status to `Error` while recording an error as a span event in `RecordError`. (#1663)


### Fixed

Expand Down
7 changes: 4 additions & 3 deletions sdk/trace/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,15 @@ func (s *span) End(options ...trace.SpanOption) {
}
}

// RecordError will record err as a span event for this span. If this span is
// not being recorded or err is nil than this method does nothing.
// RecordError will record err as a span event for this span. An additional call to
// SetStatus is required if the Status of the Span should be set to Error, this method
// does not change the Span status. If this span is not being recorded or err is nil
// than this method does nothing.
func (s *span) RecordError(err error, opts ...trace.EventOption) {
if s == nil || err == nil || !s.IsRecording() {
return
}

s.SetStatus(codes.Error, "")
opts = append(opts, trace.WithAttributes(
errorTypeKey.String(typeStr(err)),
errorMessageKey.String(err.Error()),
Expand Down
2 changes: 1 addition & 1 deletion sdk/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ func TestRecordError(t *testing.T) {
},
ParentSpanID: sid,
Name: "span0",
StatusCode: codes.Error,
StatusCode: codes.Unset,
SpanKind: trace.SpanKindInternal,
HasRemoteParent: true,
MessageEvents: []trace.Event{
Expand Down

0 comments on commit a5edd79

Please sign in to comment.