-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: refactor code_owner code from edx-dajango-utils #838
base: main
Are you sure you want to change the base?
Conversation
This is the code_owner code as found in edx-django-utils.
Initial rollout of moving code_owner monitoring code from edx-django-utils to this plugin. - Adds near duplicate of code owner middleware from edx-django-utils. - Adds code owner for celery using Datadog span processing of celery.run spans. - Uses temporary span tags names using `_2`, like `code_owner_2`, for rollout and comparison with the original span tags. See #784
code_owner_mappings = getattr(settings, 'CODE_OWNER_MAPPINGS', None) | ||
if code_owner_mappings is None: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for Reviewer: A bug was found in this code, because there was a bug in the original test for this that didn't catch this problem.
As a reviewer, feel free to mark this resolved once you have read this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What impact would this have had?
ce0a75e
to
1d3af1c
Compare
Note to Reviewer: I did initial local testing to POC the celery span resource name was available locally, but I did not do a final local test. I wasn't able to get to a real celery task locally. |
# We can use this for celery spans, because the resource name is more predictable | ||
# and available from the start. For django requests, we'll instead continue to use | ||
# django middleware for setting code owner. | ||
get_code_owner_from_module(span.resource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be set_code_owner_attribute_from_module
?
code_owner_squad IN ('old-squad-name', 'new-squad-name') | ||
code_owner_theme IN ('old-theme-name', 'new-theme-name') | ||
code_owner_2_squad:('old-squad-name', 'new-squad-name') | ||
code_owner_2_theme:('old-theme-name', 'new-theme-name') | ||
|
||
Example contract phase NRQL:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some NRQL references here.
|
||
Usage:: | ||
|
||
@task() | ||
@set_code_owner_attribute | ||
@set_code_owner_2_attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded change here -- can just delete these functions, though.
|
||
If you first need some background on the ``code_owner_2_squad`` and ``code_owner_2_theme`` custom attributes, see `Using Code_Owner Custom Span Tags`_. | ||
|
||
.. _Using Code_Owner Custom Span Tags: https://github.com/openedx/edx-arch-experiments/blob/master/edx_arch_experiments/datadog_monitoring/docs/how_tos/add_code_owner_custom_attribute_to_an_ida.rst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. _Using Code_Owner Custom Span Tags: https://github.com/openedx/edx-arch-experiments/blob/master/edx_arch_experiments/datadog_monitoring/docs/how_tos/add_code_owner_custom_attribute_to_an_ida.rst | |
.. _Using Code_Owner Custom Span Tags: https://github.com/edx/edx-arch-experiments/blob/main/edx_arch_experiments/datadog_monitoring/docs/how_tos/add_code_owner_custom_attribute_to_an_ida.rst |
class TestDatadogMonitoringSpanProcessor(TestCase): | ||
"""Tests for DatadogMonitoringSpanProcessor.""" | ||
|
||
@patch('edx_arch_experiments.datadog_monitoring.apps.get_code_owner_from_module') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these patches be adjusted to mock out the setter?
Note to Reviewer: The original edx-django-utils code was copied in as a separate commit to make it easier to see what was added and what was updated if you review commit by commit.
Initial rollout of moving code_owner monitoring code from edx-django-utils to this plugin.
_2
, likecode_owner_2
, for rollout and comparison with the original span tags.See #784
Merge checklist:
Check off if complete or not applicable: