mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-02-05 13:15:41 +02:00
Remove setting error status while recording error with Span from oteltest package (#1729)
* Remove setting error status while recording error * Update CHANGELOG Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
6defcfdf45
commit
862a5a68a8
@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- No longer set the links for a `Span` in `go.opentelemetry.io/otel/sdk/trace` that is configured to be a new root.
|
||||
This is unspecified behavior that the OpenTelemetry community plans to standardize in the future.
|
||||
To prevent backwards incompatible changes when it is specified, these links are removed. (#1726)
|
||||
- Setting error status while recording error with Span from oteltest package. (#1729)
|
||||
|
||||
## [0.19.0] - 2021-03-18
|
||||
|
||||
|
@ -91,7 +91,6 @@ func (s *Span) RecordError(err error, opts ...trace.EventOption) {
|
||||
errTypeString = errType.String()
|
||||
}
|
||||
|
||||
s.SetStatus(codes.Error, "")
|
||||
opts = append(opts, trace.WithAttributes(
|
||||
errorTypeKey.String(errTypeString),
|
||||
errorMessageKey.String(err.Error()),
|
||||
|
@ -167,39 +167,11 @@ func TestSpan(t *testing.T) {
|
||||
},
|
||||
}}
|
||||
e.Expect(subject.Events()).ToEqual(expectedEvents)
|
||||
e.Expect(subject.StatusCode()).ToEqual(codes.Error)
|
||||
e.Expect(subject.StatusCode()).ToEqual(codes.Unset)
|
||||
e.Expect(subject.StatusMessage()).ToEqual("")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("sets span status if provided", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
e := matchers.NewExpecter(t)
|
||||
|
||||
tracer := tp.Tracer(t.Name())
|
||||
_, span := tracer.Start(context.Background(), "test")
|
||||
|
||||
subject, ok := span.(*oteltest.Span)
|
||||
e.Expect(ok).ToBeTrue()
|
||||
|
||||
errMsg := "test error message"
|
||||
testErr := ottest.NewTestError(errMsg)
|
||||
testTime := time.Now()
|
||||
subject.RecordError(testErr, trace.WithTimestamp(testTime))
|
||||
|
||||
expectedEvents := []oteltest.Event{{
|
||||
Timestamp: testTime,
|
||||
Name: "error",
|
||||
Attributes: map[attribute.Key]attribute.Value{
|
||||
attribute.Key("error.type"): attribute.StringValue("go.opentelemetry.io/otel/internal/internaltest.TestError"),
|
||||
attribute.Key("error.message"): attribute.StringValue(errMsg),
|
||||
},
|
||||
}}
|
||||
e.Expect(subject.Events()).ToEqual(expectedEvents)
|
||||
e.Expect(subject.StatusCode()).ToEqual(codes.Error)
|
||||
})
|
||||
|
||||
t.Run("cannot be set after the span has ended", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
@ -545,7 +545,10 @@ type Span interface {
|
||||
// true if the Span is active and events can be recorded.
|
||||
IsRecording() bool
|
||||
|
||||
// RecordError records an error as a Span event.
|
||||
// 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.
|
||||
RecordError(err error, options ...EventOption)
|
||||
|
||||
// SpanContext returns the SpanContext of the Span. The returned
|
||||
|
Loading…
x
Reference in New Issue
Block a user