Skip to content

Conversation

@mrafi97
Copy link
Contributor

@mrafi97 mrafi97 commented Oct 30, 2025

What does this PR do?

This PR adds additional functionality to the tag_by and tag_queries parameters. Users can add aliases to tags collected from the properties defined in these parameters.

in tag_by users can define aliases by adding AS <Alias> to the property in the list:

tag_by: Name AS wmi_name,Label AS wmi_label

In tag_queries, users can add an entry to the list for the alias:

Current: 
[IDProcess, Win32_Process, Handle, Name]
[<LINK_SOURCE_PROPERTY>, <TARGET_CLASS>, <LINK_TARGET_CLASS_PROPERTY>, <TARGET_PROPERTY>]

New Change:
[IDProcess, Win32_Process, Handle, Name, wmi_tag]
[<LINK_SOURCE_PROPERTY>, <TARGET_CLASS>, <LINK_TARGET_CLASS_PROPERTY>, <TARGET_PROPERTY> AS <TAG_ALIAS>]

Motivation

https://datadoghq.atlassian.net/browse/WINA-1928

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.12%. Comparing base (3bdbe96) to head (291e2b3).
⚠️ Report is 46 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrafi97 mrafi97 force-pushed the mrafi/wmi-tag-alias branch from 91650cb to ea5fe72 Compare October 31, 2025 14:15
@datadog-agent-integrations-bot datadog-agent-integrations-bot bot added release qa/skip-qa Automatically skip this PR for the next QA labels Oct 31, 2025
@github-actions
Copy link

github-actions bot commented Oct 31, 2025

⚠️ The qa/skip-qa label has been added with shippable changes

The following files, which will be shipped with the agent, were modified in this PR and
the qa/skip-qa label has been added.

You can ignore this if you are sure the changes in this PR do not require QA. Otherwise, consider removing the label.

List of modified files that will be shipped with the agent
datadog_checks_base/changelog.d/21792.added
wmi_check/changelog.d/21792.added
datadog_checks_base/datadog_checks/base/checks/win/wmi/base.py
wmi_check/datadog_checks/wmi_check/data/conf.yaml.example
wmi_check/datadog_checks/wmi_check/wmi_check.py

Comment on lines 207 to 209
t_split = t.split(' as ')
t = t_split[0].strip()
alias = t_split[1].strip()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What alias will look like for foo as expression? Will it have even [1]? Meaning will not it crash?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also should it be done in initialization instead of on every check run to parse it again and again?

It looks even worse, the same value is or could be parsed more than once in the function because it is done in the loop.

Copy link
Contributor Author

@mrafi97 mrafi97 Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What alias will look like for foo as expression? Will it have even [1]? Meaning will not it crash?

@iglendd
I hadn't considered that, but I'd imagine the agent would try to submit a tag with an empty key which wouldn't be ideal. In a case like this we can either:

  • have the integration throw an error to let users know of the incomplete aliasing
    OR
  • have it throw a warning and just use the original property name for the time being.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, my worry was more that it would derail config/check code and exit prematurely or even crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understandable, I added some conditions where if the alias is empty, the check will use the property name and log a warning to let users know of the missing alias.

@mrafi97 mrafi97 requested a review from iglendd November 5, 2025 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants