Skip to content

Filter Sanic config object to only include configration values in context #1414

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 1 commit into from
Nov 23, 2021

Conversation

ahopkins
Copy link
Contributor

What does this pull request do?

In the current master, the Sanic integration copies the entire sanic.config.Config object. This object includes some non-configuration values, which are not relevant to capturing in the environment context.

Furthermore, in Sanic v21.9.2, a change was introduced that added a reference to an object that could not be properly copied here: https://github.com/ahopkins/apm-agent-python/blob/060cec6efa22eecfaf773c2df935b6642f841bab/elasticapm/base.py#L456

This resulted in a failure for the response object to populate through the context and ultimately resulting in the error as seen in #1413.

This is a somewhat shortlived issue since the next version of Sanic will remove that. However, it underscores a flaw in this integration in that the only values that should be copied over from the Config object are those that are in all caps.

Therefore, this PR filters the values and will only extend the environment context with the actual configuration values.

Related issues

closes #1413

@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Nov 22, 2021
@ahopkins ahopkins changed the title Filter Sanic config onject to only include configration values in context Filter Sanic config object to only include configration values in context Nov 22, 2021
@apmmachine
Copy link
Contributor

apmmachine commented Nov 22, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-11-23T08:09:54.574+0000

  • Duration: 33 min 14 sec

  • Commit: 81921ee

Test stats 🧪

Test Results
Failed 0
Passed 10287
Skipped 9537
Total 19824

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /test linters : Run the Python linters only.

  • /test full : Run the full matrix of tests.

  • /test benchmark : Run the APM Agent Python benchmarks tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@ahopkins
Copy link
Contributor Author

ahopkins commented Nov 22, 2021

$ py.test tests/contrib/sanic

image

All Sanic tests are passing locally

Copy link
Contributor

@beniwohli beniwohli left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @ahopkins for the quick fix!

@beniwohli beniwohli merged commit 8b18ddc into elastic:master Nov 23, 2021
@ahopkins ahopkins deleted the filter-sanic-config branch November 23, 2021 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sanic 21.9.2 breaks exception tracking
3 participants