Skip to content

chore: lazy load some imports #581

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

Merged
merged 5 commits into from
Mar 28, 2025
Merged

Conversation

duncanista
Copy link
Contributor

@duncanista duncanista commented Mar 28, 2025

What does this PR do?

Lazy loads some imports for metrics and hashlib

Motivation

Metrics submission for invocations and errors doesn't need to be called if there's an extension active.
Hashlib import shouldn't occur unless the method for step functions is called.

Testing Guidelines

Tested manually

Before:
Screenshot 2025-03-28 at 4 25 43 PM

After:
Screenshot 2025-03-28 at 4 24 18 PM

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

Sorry, something went wrong.

also hashlib right away
@duncanista duncanista requested a review from a team as a code owner March 28, 2025 04:10
if not should_use_extension:
from datadog_lambda.metric import submit_invocations_metric

submit_invocations_metric(context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want this change. You replaced an errors metric with an invocation metric. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, thanks for catching that!

Copy link
Contributor

@purple4reina purple4reina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The errors metric was changed into an invocation metric.

@duncanista duncanista requested a review from a team as a code owner March 28, 2025 16:22
@duncanista duncanista merged commit 2320c0a into main Mar 28, 2025
61 checks passed
@duncanista duncanista deleted the jordan.gonzalez/lazy-load-metrics branch March 28, 2025 20:28
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

Successfully merging this pull request may close these issues.

None yet

3 participants