Skip to content

fix: Add management command monitoring pipeline#16

Draft
ktyagiapphelix2u wants to merge 2 commits intomainfrom
ktyagi/filter
Draft

fix: Add management command monitoring pipeline#16
ktyagiapphelix2u wants to merge 2 commits intomainfrom
ktyagi/filter

Conversation

@ktyagiapphelix2u
Copy link
Copy Markdown

Summary

Adds a new ManagementCommandMonitoringPipelineStep that wraps Django management command execution with Datadog monitoring/observability.

This is part of a multi-repo effort to add Datadog monitoring around management command execution using the Open edX Filters framework (OEP-50).

Changes

New Pipeline Step: edx_filters_pipelines/management/pipelines/monitoring.py

  • ManagementCommandMonitoringPipelineStep: PipelineStep implementation that wraps the command_runner callable with Datadog monitoring context
  • monitor_management_command(): Context manager that sets Datadog transaction name, custom attributes, and traces command execution
  • Gated by filters_pipelines.enable_management_command_monitoring waffle flag

Waffle Flag: edx_filters_pipelines/waffle.py

  • ENABLE_MANAGEMENT_COMMAND_MONITORING: Opt-in waffle flag to enable/disable monitoring per environment or command

Test Coverage: tests/test_edx-filters-pipelines.py

  • Test flag disabled: command runs without monitoring
  • Test flag enabled: monitoring context wraps execution, Datadog calls verified
  • Test custom trace name: configurable via extra_config

Dependencies: requirements/test.in

  • Added pytest-mock for testing

Datadog Attributes Set

When the waffle flag is enabled, the following custom attributes are sent to Datadog:

  • management_command.name — command name (e.g., migrate)
  • management_command.service_variantlms or cms
  • management_command.transaction_name — e.g., lms.management.migrate
  • management_command.statussuccess or failure
  • management_command.duration_seconds — execution time
  • management_command.exception_class — if exception raised
  • management_command.exit_code — if SystemExit raised

Transaction name format: {service_variant}.management.{command_name}

Wiring

This pipeline step is bound to filter type org.openedx.platform.management.command.execute.requested.v1 via OPEN_EDX_FILTERS_CONFIG in edx-internal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant