Skip to content

Commit

Permalink
rewrite conditions for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Jun 10, 2020
1 parent 0e77604 commit fcf8143
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ def add(self, value: metrics_api.ValueT) -> None:
self.update(value)

def _validate_update(self, value: metrics_api.ValueT) -> bool:
if super()._validate_update(value):
if value >= 0:
return True
if not super()._validate_update(value):
return False
if value < 0:
logger.warning(
"Invalid value %s passed to Counter, value must be "
"non-negative. For a Counter that can decrease, use "
"UpDownCounter.",
"Invalid value %s passed to Counter, value must be non-negative. "
"For a Counter that can decrease, use UpDownCounter.",
value,
)
return False
return False
return True


class BoundUpDownCounter(metrics_api.BoundUpDownCounter, BaseBoundInstrument):
Expand Down

0 comments on commit fcf8143

Please sign in to comment.