Skip to content
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

How to test for APM coverage? #20

Open
bulldoguk opened this issue Nov 22, 2023 · 2 comments
Open

How to test for APM coverage? #20

bulldoguk opened this issue Nov 22, 2023 · 2 comments

Comments

@bulldoguk
Copy link

This is not necessarily a django-apm specific question, but hopefully someone here has some thoughts... I've implemented class based views in my Django project and I want to add some pre-commit checking to make sure that those views (and future views) all inherit from ApmView. I have written a check for function based views using inspect.getsource to confirm that the @apm_view() decorator is present - but I'm struggling to validate for these class based views.

Any thoughts or direction would be appreciated. Thanks!

@leandrodesouzadev
Copy link
Contributor

Hey there!
That may depends on your current "check" implementation. If you're using flake8, you can use AST to check the view definition.
At runtime, we don't do anything on the view being decorated (for function-based views), or being subclassed (for class-based views), only on the request before your code.. so in this case i think it may be a bit hard to introspect the view to find out.

@bulldoguk
Copy link
Author

Thanks! We're using Ruff as our main linter, but I can add flake8 if that would support this. I'll take a look - appreciate the suggestion.

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