File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed
Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515- Adjust ` B3Format ` propagator to be spec compliant by not modifying context
1616 when propagation headers are not present/invalid/empty
1717 ([ #1728 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/1728 ) )
18+ - Silence unnecessary warning when creating a new Status object without description.
19+ ([ #1721 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/1721 ) )
1820- Update bootstrap cmd to use exact version when installing instrumentation packages.
1921 ([ #1722 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/1722 ) )
2022
Original file line number Diff line number Diff line change @@ -49,15 +49,15 @@ def __init__(
4949 self ._status_code = status_code
5050 self ._description = None
5151
52- if description is not None and not isinstance ( description , str ) :
53- logger . warning ( "Invalid status description type, expected str" )
54- return
55-
56- if status_code is not StatusCode .ERROR :
57- logger .warning (
58- "description should only be set when status_code is set to StatusCode.ERROR"
59- )
60- return
52+ if description :
53+ if not isinstance ( description , str ):
54+ logger . warning ( "Invalid status description type, expected str" )
55+ return
56+ if status_code is not StatusCode .ERROR :
57+ logger .warning (
58+ "description should only be set when status_code is set to StatusCode.ERROR"
59+ )
60+ return
6161
6262 self ._description = description
6363
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ def test_constructor(self):
3030
3131 def test_invalid_description (self ):
3232 with self .assertLogs (level = WARNING ) as warning :
33- status = Status (description = {"test" : "val" }) # type: ignore
34- self .assertIs (status .status_code , StatusCode .UNSET )
33+ status = Status (status_code = StatusCode . ERROR , description = {"test" : "val" }) # type: ignore
34+ self .assertIs (status .status_code , StatusCode .ERROR )
3535 self .assertEqual (status .description , None )
3636 self .assertIn (
3737 "Invalid status description type, expected str" ,
You can’t perform that action at this time.
0 commit comments