feat: add contextmanager-based management command observability filter - #400
Open
rahulkanneri-2u wants to merge 1 commit into
Open
rahulkanneri-2u wants to merge 1 commit into
rahulkanneri-2u wants to merge 1 commit into
Conversation
Adds the ManagementCommandContextmanagerRequested filter under the openedx_filters.management package. The filter is invoked in manage.py before a Django management command is executed, allowing pipeline steps to wrap the command's execution in a context manager (for example, to add observability such as Datadog tracing and structured logging) without changing each command individually, since management commands don't go through Django's normal request middleware. Supersedes openedx#344, rebased onto main to resolve conflicts, with the version bump and changelog entry requested in review.
rahulkanneri-2u
force-pushed
the
rahul/mgmt-command-observability-filter
branch
from
September 29, 2026 12:33
9b10059 to
b12a35e
Compare
Author
|
@pwnage101 @feanil I took over openedx/openedx-filters#344 and brought the changes over to this PR, along with a rebase and fixes for the outstanding review comments. Could you review this so we can take it forward? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds the
ManagementCommandContextmanagerRequestedfilter underopenedx_filters.management. The filter is triggered inmanage.pybefore a Django management command executes, and lets pipeline steps wrap the command's execution in a context manager (for example, to add observability such as Datadog tracing, custom attributes, or structured logging).Management commands don't go through Django's normal request middleware, so this gives pipeline authors one shared instrumentation point instead of having to modify every command individually.
Why this PR (supersedes #344)
This supersedes #344 — that PR's branch lives on a fork that can no longer be updated, so this PR continues the same work on a new branch. All outstanding review feedback from #344 is carried over here: the output tuple now matches the input signature (command_contextmanager, command_name, service_variant); the trigger repository is corrected to openedx/openedx-platform; the docstring is expanded to explain why the filter exists (management commands skip middleware) and includes a usage example, addressing the request for "a more detailed docstring about the expected use case"; tests use pytest-style assert statements; the version is bumped 3.14.0 to 3.15.0 with a changelog fragment added via scriv; commits are squashed into one; and the branch is rebased onto current main.
Original implementation credit is preserved via the commit author.
Testing instructions
Ran
pytest openedx_filters/management/(1 test, passes) and the full suitepytest(116 passed). Also ranpycodestyle --max-line-length=120 openedx_filters/management/filters.pywith no violations.Other information
Supersedes #344, which will be closed with a link to this PR. Downstream, edx-platform PR 200, edx-filters-pipelines PR 16, and edx-internal PR 14130 depend on this being released to bump their openedx-filters pin. CI (Python CI / Lint Commit Messages) is queued behind maintainer approval since this is a first PR from this fork account, so it hasn't run yet.
Merge checklist status
Done: changelog entry added via scriv, docstring/documentation updated, no new dependencies, commits squashed into one, unit tests added. Not yet: reviewer approval, CI build (queued on maintainer approval to run). Post-merge steps (release workflow, PyPI check, branch deletion, bumping the package in downstream Open edX platform requirements) are not started.