Skip to content

Conversation

@jcstorms1
Copy link
Contributor

@jcstorms1 jcstorms1 commented Jun 4, 2020

What does this PR do?

Adds an init duration enhanced metric for cold starts
Adds a cold_start tag for all metrics

Motivation

Testing Guidelines

Additional Notes

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@jcstorms1 jcstorms1 changed the title Jordan.storms/add init duration and coldstart tags Jordan.storms/add init duration metric and cold_start tags Jun 4, 2020
@jcstorms1 jcstorms1 requested a review from DarcyRaynerDD June 4, 2020 21:50
@tianchu
Copy link
Contributor

tianchu commented Jun 4, 2020

Can you add a test case for the new metric and tag https://github.com/DataDog/datadog-serverless-functions/blob/master/aws/logs_monitoring/tests/test_enhanced_lambda_metrics.py?

@jcstorms1 jcstorms1 removed the request for review from DarcyRaynerDD June 5, 2020 18:43
Copy link
Contributor

@tianchu tianchu left a comment

Choose a reason for hiding this comment

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

👍 LGTM! One last thing, do you mind check all the boxes that apply from the PR template?

@jcstorms1 jcstorms1 merged commit 266dfb3 into master Jun 8, 2020
Comment on lines +454 to +469
# if cold_start:
if regex_match.group(INIT_DURATION_METRIC_NAME):
metric_point_value = float(regex_match.group(INIT_DURATION_METRIC_NAME))
# Multiply by 1/1000 to convert ms to seconds
metric_point_value *= METRIC_ADJUSTMENT_FACTORS[INIT_DURATION_METRIC_NAME]

initial_duration = DatadogMetricPoint(
"{}.{}".format(
ENHANCED_METRICS_NAMESPACE_PREFIX, INIT_DURATION_METRIC_NAME
),
metric_point_value,
)

initial_duration.add_tags(tags)

metrics.append(initial_duration)
Copy link
Contributor

Choose a reason for hiding this comment

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

@jcstorms1 my apologies, after a weekend, I totally forgot that another suggestion I pointed out last week was merging line 454-469 (after change) to the for loop of line 471 (after change), their logic are 99% same. I suggest adding INIT_DURATION_METRIC_NAME to METRICS_TO_PARSE_FROM_REPORT and add a check within the for loop like this

for metric_name in METRICS_TO_PARSE_FROM_REPORT:
    if not regex_match.group(metric_name):
        continue
    metric_point_value = float(regex_match.group(metric_name))
    ....

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.

2 participants