-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from DataDog/stephenf/log-enhanced-metrics-by-…
…default Enable enhanced metrics by default and write enhanced metrics to logs
- Loading branch information
Showing
6 changed files
with
127 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# The minor version corresponds to the Lambda layer version. | ||
# E.g.,, version 0.5.0 gets packaged into layer version 5. | ||
__version__ = '0.11.0' | ||
__version__ = "1.12.0" | ||
|
||
|
||
import os | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.getLevelName(os.environ.get('DD_LOG_LEVEL', 'INFO').upper())) | ||
logger.setLevel(logging.getLevelName(os.environ.get("DD_LOG_LEVEL", "INFO").upper())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import os | ||
import unittest | ||
|
||
try: | ||
from unittest.mock import patch, call | ||
except ImportError: | ||
from mock import patch, call | ||
|
||
from datadog_lambda.metric import ( | ||
lambda_metric, | ||
_format_dd_lambda_layer_tag, | ||
) | ||
from datadog_lambda.metric import lambda_metric | ||
from datadog_lambda.tags import _format_dd_lambda_layer_tag | ||
|
||
|
||
class TestLambdaMetric(unittest.TestCase): | ||
|
||
def setUp(self): | ||
patcher = patch('datadog_lambda.metric.lambda_stats') | ||
patcher = patch("datadog_lambda.metric.lambda_stats") | ||
self.mock_metric_lambda_stats = patcher.start() | ||
self.addCleanup(patcher.stop) | ||
|
||
def test_lambda_metric_tagged_with_dd_lambda_layer(self): | ||
lambda_metric('test', 1) | ||
lambda_metric('test', 1, 123, []) | ||
lambda_metric('test', 1, tags=['tag1:test']) | ||
lambda_metric("test", 1) | ||
lambda_metric("test", 1, 123, []) | ||
lambda_metric("test", 1, tags=["tag1:test"]) | ||
expected_tag = _format_dd_lambda_layer_tag() | ||
self.mock_metric_lambda_stats.distribution.assert_has_calls([ | ||
call('test', 1, timestamp=None, tags=[expected_tag]), | ||
call('test', 1, timestamp=123, tags=[expected_tag]), | ||
call('test', 1, timestamp=None, tags=['tag1:test', expected_tag]), | ||
]) | ||
self.mock_metric_lambda_stats.distribution.assert_has_calls( | ||
[ | ||
call("test", 1, timestamp=None, tags=[expected_tag]), | ||
call("test", 1, timestamp=123, tags=[expected_tag]), | ||
call("test", 1, timestamp=None, tags=["tag1:test", expected_tag]), | ||
] | ||
) | ||
|
||
def test_lambda_metric_flush_to_log(self): | ||
os.environ["DD_FLUSH_TO_LOG"] = 'True' | ||
os.environ["DD_FLUSH_TO_LOG"] = "True" | ||
|
||
lambda_metric('test', 1) | ||
lambda_metric("test", 1) | ||
self.mock_metric_lambda_stats.distribution.assert_not_called() | ||
|
||
del os.environ["DD_FLUSH_TO_LOG"] |
Oops, something went wrong.