Skip to content

chore(ci): add the Metrics feature to nox tests #4552

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

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,26 @@ def build_and_run_test(session: nox.Session, folders: List, extras: Optional[str
def test_with_only_required_packages(session: nox.Session):
"""Tests that only depends for required libraries"""
# Logger
# Metrics - Amazon CloudWatch EMF
# Metrics - Base provider
build_and_run_test(
session,
folders=[
f"{PREFIX_TESTS_FUNCTIONAL}/logger/",
f"{PREFIX_TESTS_FUNCTIONAL}/metrics/cloudwatch_emf/",
f"{PREFIX_TESTS_FUNCTIONAL}/metrics/provider/",
],
)


@nox.session()
def test_with_datadog_as_required_package(session: nox.Session):
"""Tests that depends on Datadog library"""
# Metrics - Datadog
build_and_run_test(
session,
folders=[
f"{PREFIX_TESTS_FUNCTIONAL}/metrics/datadog/",
],
extras="datadog",
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections import namedtuple

import pytest
from test_metrics_provider import capture_metrics_output

from aws_lambda_powertools.metrics.exceptions import MetricValueError, SchemaValidationError
from aws_lambda_powertools.metrics.provider.cold_start import reset_cold_start_flag
Expand Down Expand Up @@ -40,7 +39,7 @@ def test_datadog_write_to_log_with_env_variable(capsys, monkeypatch):
# WHEN we add a metric
metrics.add_metric(name="item_sold", value=1, product="latte", order="online")
metrics.flush_metrics()
logs = capture_metrics_output(capsys)
logs = json.loads(capsys.readouterr().out.strip())

# THEN metrics is flushed to log
logs["e"] = ""
Expand Down