Skip to content

Commit

Permalink
Check if there's a report before labeling (#285)
Browse files Browse the repository at this point in the history
Closes #284
  • Loading branch information
kolanos authored Nov 30, 2018
1 parent eabf43a commit 4f48fbc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions iopipe/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def metric(self, key, value):
log = metric

def label(self, name):
if self.instance.report is None:
warnings.warn(
"Attempting to add label before function decorated with IOpipe. "
"This label will not be recorded."
)
return

if not isinstance(name, string_types):
warnings.warn(
"Attempted to add a label that is not of type string. "
Expand Down

0 comments on commit 4f48fbc

Please sign in to comment.