File tree Expand file tree Collapse file tree 5 files changed +25
-16
lines changed
src/opentelemetry/sdk/trace Expand file tree Collapse file tree 5 files changed +25
-16
lines changed Original file line number Diff line number Diff line change 4
4
5
5
- Return INVALID_SPAN if no TracerProvider set for get_current_span
6
6
([ #751 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/751 ) )
7
+ - Rename record_error to record_exception
8
+ ([ #927 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/927 ) )
7
9
8
10
## 0.9b0
9
11
Original file line number Diff line number Diff line change @@ -89,8 +89,8 @@ def set_status(self, status: Status) -> None:
89
89
"""
90
90
91
91
@abc .abstractmethod
92
- def record_error (self , err : Exception ) -> None :
93
- """Records an error as a span event."""
92
+ def record_exception (self , exception : Exception ) -> None :
93
+ """Records an exception as a span event."""
94
94
95
95
def __enter__ (self ) -> "Span" :
96
96
"""Invoked when `Span` is used as a context manager.
@@ -257,7 +257,7 @@ def update_name(self, name: str) -> None:
257
257
def set_status (self , status : Status ) -> None :
258
258
pass
259
259
260
- def record_error (self , err : Exception ) -> None :
260
+ def record_exception (self , exception : Exception ) -> None :
261
261
pass
262
262
263
263
Original file line number Diff line number Diff line change 4
4
5
5
- Add support for resources and resource detector
6
6
([ #853 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/853 ) )
7
+ - Rename record_error to record_exception
8
+ ([ #927 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/927 ) )
7
9
8
10
## Version 0.10b0
9
11
Original file line number Diff line number Diff line change @@ -683,14 +683,14 @@ def __exit__(
683
683
684
684
super ().__exit__ (exc_type , exc_val , exc_tb )
685
685
686
- def record_error (self , err : Exception ) -> None :
687
- """Records an error as a span event."""
686
+ def record_exception (self , exception : Exception ) -> None :
687
+ """Records an exception as a span event."""
688
688
self .add_event (
689
- name = "error " ,
689
+ name = "exception " ,
690
690
attributes = {
691
- "error .type" : err .__class__ .__name__ ,
692
- "error .message" : str (err ),
693
- "error.stack " : traceback .format_exc (),
691
+ "exception .type" : exception .__class__ .__name__ ,
692
+ "exception .message" : str (exception ),
693
+ "exception.stacktrace " : traceback .format_exc (),
694
694
},
695
695
)
696
696
Original file line number Diff line number Diff line change @@ -801,18 +801,23 @@ def error_status_test(context):
801
801
.start_as_current_span ("root" )
802
802
)
803
803
804
- def test_record_error (self ):
804
+ def test_record_exception (self ):
805
805
span = trace .Span ("name" , mock .Mock (spec = trace_api .SpanContext ))
806
806
try :
807
807
raise ValueError ("invalid" )
808
808
except ValueError as err :
809
- span .record_error (err )
810
- error_event = span .events [0 ]
811
- self .assertEqual ("error" , error_event .name )
812
- self .assertEqual ("invalid" , error_event .attributes ["error.message" ])
813
- self .assertEqual ("ValueError" , error_event .attributes ["error.type" ])
809
+ span .record_exception (err )
810
+ exception_event = span .events [0 ]
811
+ self .assertEqual ("exception" , exception_event .name )
812
+ self .assertEqual (
813
+ "invalid" , exception_event .attributes ["exception.message" ]
814
+ )
815
+ self .assertEqual (
816
+ "ValueError" , exception_event .attributes ["exception.type" ]
817
+ )
814
818
self .assertIn (
815
- "ValueError: invalid" , error_event .attributes ["error.stack" ]
819
+ "ValueError: invalid" ,
820
+ exception_event .attributes ["exception.stacktrace" ],
816
821
)
817
822
818
823
You can’t perform that action at this time.
0 commit comments