Filter Sanic config object to only include configration values in context #1414
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this pull request do?
In the current
master
, the Sanic integration copies the entiresanic.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