Skip to content

Update temporal integration generate_metadata.py script #20469

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

phuongdnguyen
Copy link

@phuongdnguyen phuongdnguyen commented Jun 7, 2025

What does this PR do?

Update the metadata generation script to:

  • Preserves existing metadata for backward compatibility.
  • Fetch metrics definition from temporal repo url instead of reading from local file.
  • Change the way we parse the go file from line by line to read the whole file at once, this is to handle recent change in temporal metrics def where metrics def function changed into a variadic func.
  • Special handling for native_dynamic metrics so the script doesnt produce a malformed entry in the metadata.csv file.

Motivation

This PR is split from #20142, the purpose is for us to able to support metrics in recent version of temporal.
Related support request https://help.datadoghq.com/hc/en-us/requests/2152576

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

Copy link
Contributor

@iliakur iliakur left a comment

Choose a reason for hiding this comment

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

to me the blockers are mostly the inline comments, otherwise looking good, thanks

metric_name = match.group(3)

# Extract type from function name (everything between New and Def)
type_name = func_name[3:-3] # Remove "New" prefix and "Def" suffix
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to tweak the regex in such a way that we don't need to do this extraction later?

For instance have something like ...New(\w*)Def.

Copy link
Author

@phuongdnguyen phuongdnguyen Jun 15, 2025

Choose a reason for hiding this comment

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

Updated, thanks!

Copy link

codecov bot commented Jun 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.18%. Comparing base (9ee6ff2) to head (1e9cf5f).

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
confluent_platform ?
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
mac_audit_logs ?
presto ?
solr ?
temporal 100.00% <ø> (ø)
tomcat ?
weblogic ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 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.

@phuongdnguyen phuongdnguyen force-pushed the update-temporal-generate-metadata-script branch from 9314a78 to dd8fb92 Compare June 15, 2025 04:11
@phuongdnguyen phuongdnguyen requested a review from iliakur June 15, 2025 05:20
Copy link
Contributor

@iliakur iliakur left a comment

Choose a reason for hiding this comment

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

A couple more points, not sure why CI is unhappy.

"and is not present in the current metadata.csv file"
)
continue

try:
temporal_type = temporal_metric_types[temporal_name]
except KeyError:
Copy link
Contributor

Choose a reason for hiding this comment

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

How exceptional is this? How often do we except it to happen?

Copy link
Author

Choose a reason for hiding this comment

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

Agree, use a cleaner lookup mechanism here

tuple: (metadata list with any existing metrics added, boolean indicating if metric exists)
"""
pattern = re.compile(rf"^temporal\.server\.{re.escape(name)}(?:\.[a-z]+)*$")
exist = False
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this variable since it's the same as bool(result). If result is not empty, then exist is always True, and if result is empty, then exist is False.

Comment on lines 119 to 132
# If metrics does not exist in this Temporal version, try to search metric in
# the current metadata file and preserve it if it's already exist
existing_dd_metric, existed_dd_metric = check_existing_metric(
dd_metric, previous_metadata, added_dd_metrics
)
if existed_dd_metric:
metadata.extend(existing_dd_metric)
else:
print(
f"WARNING: skipping metric `{temporal_name}/{dd_metric}` because it's "
"not present in both temporal metric definitions and the current "
"metatada.csv file"
)
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get rid of the duplication between this and the block above it?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure we should remove it. Those have different meaning: not processing and log out its existent vs not processing because it's not exist

@phuongdnguyen phuongdnguyen force-pushed the update-temporal-generate-metadata-script branch from 5d805cd to ee98200 Compare June 17, 2025 08:24
@phuongdnguyen phuongdnguyen force-pushed the update-temporal-generate-metadata-script branch from ee98200 to 1634997 Compare June 17, 2025 09:23
@phuongdnguyen phuongdnguyen requested a review from iliakur June 17, 2025 09:29
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.

2 participants