Skip to content

Commit

Permalink
Improve Agent Telemetry governance (#30792)
Browse files Browse the repository at this point in the history
  • Loading branch information
iglendd authored Nov 9, 2024
1 parent 92bf87a commit 55d2688
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@
/comp/checks/agentcrashdetect @DataDog/windows-kernel-integrations
/comp/checks/windowseventlog @DataDog/windows-agent
/comp/checks/winregistry @DataDog/windows-agent
/comp/core/agenttelemetry @DataDog/agent-metrics-logs
/comp/core/autodiscovery @DataDog/container-platform
/comp/core/sysprobeconfig @DataDog/ebpf-platform
/comp/core/tagger @DataDog/container-platform
Expand All @@ -321,6 +320,9 @@
/comp/snmpscan @DataDog/ndm-core
# END COMPONENTS

# Additional notification to @iglendd about Agent Telemetry changes for optional approval and governance acknowledgement
/comp/core/agenttelemetry @DataDog/agent-shared-components @iglendd

# pkg
/pkg/ @DataDog/agent-shared-components
/pkg/api/ @DataDog/agent-shared-components
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/label-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,21 @@ jobs:
echo "No issue with 'qa/done' and 'qa/no-code-change' labels"
env:
LABELS: ${{ needs.fetch-labels.outputs.LABELS}}
agenttelemetry-list-change-ack-check:
if: github.triggering_actor != 'dd-devflow[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
ref: ${{ github.head_ref }}
- name: Setup python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3.11
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
- name: Install dependencies
run: pip install -r requirements.txt -r tasks/requirements.txt
- name: Check agent telemetry metric list
run: inv -e github.agenttelemetry-list-change-ack-check --pr-id=${{ github.event.pull_request.number }}
2 changes: 0 additions & 2 deletions comp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ agent flavors and binaries.

### [comp/core/agenttelemetry](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/core/agenttelemetry)

*Datadog Team*: agent-metrics-logs

Package agenttelemetry implements a component to generate Agent telemetry

### [comp/core/autodiscovery](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/core/autodiscovery)
Expand Down
2 changes: 1 addition & 1 deletion comp/core/agenttelemetry/def/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Package agenttelemetry implements a component to generate Agent telemetry
package agenttelemetry

// team: agent-metrics-logs
// team: agent-shared-components

// Component is the component type
type Component interface {
Expand Down
27 changes: 27 additions & 0 deletions tasks/github_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
print_workflow_conclusion,
trigger_macos_workflow,
)
from tasks.libs.common.color import color_message
from tasks.libs.common.constants import DEFAULT_BRANCH, DEFAULT_INTEGRATIONS_CORE_BRANCH
from tasks.libs.common.datadog_api import create_gauge, send_event, send_metrics
from tasks.libs.common.junit_upload_core import repack_macos_junit_tar
Expand Down Expand Up @@ -511,3 +512,29 @@ def assign_codereview_label(_, pr_id=-1):
gh = GithubAPI('DataDog/datadog-agent')
complexity = gh.get_codereview_complexity(pr_id)
gh.update_review_complexity_labels(pr_id, complexity)


@task
def agenttelemetry_list_change_ack_check(_, pr_id=-1):
"""
Change to `comp/core/agenttelemetry/impl/config.go` file requires to acknowledge
potential changes to Agent Telemetry metrics. If Agent Telemetry metric list has been changed,
the PR should be labeled with `need-change/agenttelemetry-governance` and follow
`Agent Telemetry Governance` instructions to potentially perform additional changes. See
https://datadoghq.atlassian.net/wiki/spaces/ASUP/pages/4340679635/Agent+Telemetry+Governance
for details.
"""
from tasks.libs.ciproviders.github_api import GithubAPI

gh = GithubAPI('DataDog/datadog-agent')

labels = gh.get_pr_labels(pr_id)
files = gh.get_pr_files(pr_id)
if "comp/core/agenttelemetry/impl/config.go" in files:
if "need-change/agenttelemetry-governance" not in labels:
message = f"{color_message('Error', 'red')}: If you change the `comp/core/agenttelemetry/impl/config.go` file, you need to add `need-change/agenttelemetry-governance` label. If you have access, pleas follow the instructions specified in https://datadoghq.atlassian.net/wiki/spaces/ASUP/pages/4340679635/Agent+Telemetry+Governance"
raise Exit(message, code=1)
else:
print(
"'need-change/agenttelemetry-governance' label found on the PR: potential change to Agent Telemetry metrics is acknowledged and the governance instructions are followed."
)

0 comments on commit 55d2688

Please sign in to comment.