Description
Is this related to an existing feature request or issue?
Which Powertools for AWS Lambda (Python) utility does this relate to?
Metrics
Summary
We didn't included the Datadog metrics provider in our initial metrics provider release due to a dependency conflict. Now that the conflict is resolved, This RFC is for adding back the previously included Datadog metrics provider
Use case
If our customer would like to use Datadog for metrics. This pre-defined Datadog metrics provider is the solution. With pre-defined Datadog metrics provider, a current Cloudwatch EMF metrics user can switch to use Datadog metrics by making few lines of code changes.
Proposal
from aws_lambda_powertools.utilities.typing import LambdaContext
from aws_lambda_powertools.metrics.provider import DatadogMetrics
from aws_lambda_powertools.metrics.provider import DatadogMetricsProvider
# Use datadog-defined metrics provider
provider = DatadogMetricsProvider()
metrics = DatadogMetrics(provider=provider)
@metrics.log_metrics
def lambda_handler(event: dict, context: LambdaContext):
metrics.add_metric(name="SuccessfulBooking", value=1, tags={"product":"ticket","order":"online"})
# JSON output to log
# {
# "m": "SuccessfulBooking",
# "v": 1,
# "e": 1678509106,
# "t": "['product:ticket', 'order:online']"
# }
metrics.add_metric(name="SuccessfulBooking", value=1, product="ticket", order="online")
# JSON output to log
# {
# "m": "SuccessfulBooking",
# "v": 1,
# "e": 1678509106,
# "t": "['product:ticket', 'order:online']"
# }
Out of scope
Resolving Datadog side issue is out of scope
Potential challenges
Potential challenges includes Datadog might changes metrics from log format in the future, and
Dependencies and Integrations
Dependent on datadog lambda lib
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Type
Projects
Status