Skip to content

flush_stats can't be called without a Lambda context #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nr-synth opened this issue Sep 27, 2024 · 3 comments
Closed

flush_stats can't be called without a Lambda context #515

nr-synth opened this issue Sep 27, 2024 · 3 comments

Comments

@nr-synth
Copy link

nr-synth commented Sep 27, 2024

Expected Behavior

metric.flush_stats has an optional lambda_context argument, defaulting to None.

Omitting this argument shouldn't cause issues, and didn't in earlier versions of the library.

Actual Behavior

Exception thrown: builtins.UnboundLocalError: local variable 'tags' referenced before assignment

Steps to Reproduce the Problem

  1. metric.flush_stats()

Specifications

  • Datadog Lambda Layer version: v6.98.0
  • Python version: 3.10

Stacktrace

Traceback (most recent call last):
  [...]
  File "/home/lambda/[...]", line 55, in send
    flush_stats()
  File "/home/lambda/datadog_lambda/metric.py", line 136, in flush_stats
    extension_thread_stats.flush(tags)
UnboundLocalError: local variable 'tags' referenced before assignment
@purple4reina
Copy link
Contributor

Thanks for reporting this @nr-synth, this is indeed a bug in the library. I'll get started working on a fix.

However, you shouldn't need to ever call this method manually yourself. The datadog wrapper will do it for you after each invocation. Are you calling this manually?

@nr-synth
Copy link
Author

nr-synth commented Sep 28, 2024

Thanks @purple4reina - I don't have the full context, best I can surmise is that we were using this function when locally testing Lambda code with Datadog.

@purple4reina
Copy link
Contributor

The change has been merged and will go out with our next release. Thanks again for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants