From abe8abb62e0dd08c495818b2ab396d4add72ade9 Mon Sep 17 00:00:00 2001 From: Michael Lavers Date: Fri, 30 Nov 2018 11:16:51 -0800 Subject: [PATCH] Check if there's a report before labeling Closes #284 --- iopipe/context.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/iopipe/context.py b/iopipe/context.py index b0bc4cf3..8e91ec62 100644 --- a/iopipe/context.py +++ b/iopipe/context.py @@ -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. "