Skip to content

Commit

Permalink
Lambda Wrapper - Rename lambda_stats -> lambda_metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Pierre committed Nov 27, 2018
1 parent b8017bd commit 212744b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion datadog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# datadog
from datadog import api
from datadog.dogstatsd import DogStatsd, statsd # noqa
from datadog.threadstats import ThreadStats, datadog_lambda_wrapper, lambda_stats # noqa
from datadog.threadstats import ThreadStats, datadog_lambda_wrapper, lambda_metric # noqa
from datadog.util.compat import iteritems, NullHandler
from datadog.util.config import get_version
from datadog.util.hostname import get_hostname
Expand Down
2 changes: 1 addition & 1 deletion datadog/threadstats/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from datadog.threadstats.base import ThreadStats # noqa
from datadog.threadstats.aws_lambda import lambda_stats, datadog_lambda_wrapper # noqa
from datadog.threadstats.aws_lambda import lambda_metric, datadog_lambda_wrapper # noqa
6 changes: 3 additions & 3 deletions datadog/threadstats/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"""
Usage:
from datadog import datadog_lambda_wrapper, lambda_stats
from datadog import datadog_lambda_wrapper, lambda_metric
@datadog_lambda_wrapper
def my_lambda_handle(event, context):
lambda_stats.increment("some_metric", 10)
lambda_metric("some_metric", 10)
"""


Expand Down Expand Up @@ -67,6 +67,6 @@ def __call__(self, *args, **kw):
datadog_lambda_wrapper = _LambdaDecorator


def lambda_stats(*args, **kw):
def lambda_metric(*args, **kw):
""" Alias to expose only distributions for lambda functions"""
_lambda_stats.distribution(*args, **kw)
6 changes: 3 additions & 3 deletions tests/performance/test_lambda_wrapper_thread_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# import unittest
import threading

from datadog import lambda_stats, datadog_lambda_wrapper
from datadog import lambda_metric, datadog_lambda_wrapper
from datadog.threadstats.aws_lambda import _lambda_stats


Expand All @@ -23,11 +23,11 @@ def flush_distributions(self, dists):

@datadog_lambda_wrapper
def wrapped_function(id):
lambda_stats("dist_" + str(id), 42)
lambda_metric("dist_" + str(id), 42)
# sleep makes the os continue another thread
time.sleep(0.001)

lambda_stats("common_dist", 42)
lambda_metric("common_dist", 42)


class TestWrapperThreadSafety(object):
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/threadstats/test_threadstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import nose.tools as nt

# datadog
from datadog import ThreadStats, lambda_stats, datadog_lambda_wrapper
from datadog import ThreadStats, lambda_metric, datadog_lambda_wrapper
from datadog.threadstats.aws_lambda import _lambda_stats
from tests.util.contextmanagers import preserve_environment_variable

Expand Down Expand Up @@ -750,7 +750,7 @@ def test_basic_lambda_decorator(self):

@datadog_lambda_wrapper
def basic_wrapped_function():
lambda_stats("lambda.somemetric", 100)
lambda_metric("lambda.somemetric", 100)

_lambda_stats.reporter = self.reporter
basic_wrapped_function()
Expand All @@ -766,12 +766,12 @@ def test_embedded_lambda_decorator(self):

@datadog_lambda_wrapper
def wrapped_function_1():
lambda_stats("lambda.dist.1", 10)
lambda_metric("lambda.dist.1", 10)

@datadog_lambda_wrapper
def wrapped_function_2():
wrapped_function_1()
lambda_stats("lambda.dist.2", 30)
lambda_metric("lambda.dist.2", 30)

_lambda_stats.reporter = self.reporter
wrapped_function_2()
Expand Down

0 comments on commit 212744b

Please sign in to comment.