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

Add wrapper instrumentation for Django #1780

Merged
merged 7 commits into from Mar 29, 2023

Conversation

beniwohli
Copy link
Contributor

@beniwohli beniwohli commented Mar 21, 2023

What does this pull request do?

We instrument Apps.populate to insert our own app at the top of the list. This takes care of initialization.

As Django requires a client of type DjangoClient, we can't initialize the client in sitecustomize already. Hence, we only load a limited config object to check enabled/instrument config values, and move client initialization into the actual instrumentation.

Related issues

Closes #1597
Ref #1709

We instrument Apps.populate to insert our own app at the top of the
list. This takes care of initialization.

As Django requires a client of type DjangoClient, we can't initialize
the client in sitecustomize already. Hence, we only load a limited
config object to check enabled/instrument config values, and move client
initialization into the actual instrumentation.
turns out we run into some fun corners of the Python object model,
and fixing those would be much more involved than just some code
duplication
Copy link
Contributor

@basepi basepi left a comment

Choose a reason for hiding this comment

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

This is great! Glad it was so easy.

As for testing, I'm a bit torn. I think right now this instrumentation is simple enough that we can probably skip an end to end test. But if for some reason this gets more complicated or brittle in the future, I think an end to end test (similar to the one I do for the wrapper script, where we actually shell out) would be worthwhile.

@beniwohli beniwohli merged commit 3c6b585 into elastic:main Mar 29, 2023
94 checks passed
APM-Agents (OLD) automation moved this from In Progress to Done Mar 29, 2023
@beniwohli beniwohli deleted the wrapper-script-django-support branch April 4, 2023 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

No-Code-Changes Instrumentation: Django
2 participants