Skip to content

Commit

Permalink
Merge branch 'main' into stream-patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Mar 5, 2024
2 parents 71df89a + da28801 commit c97d229
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 66 deletions.
114 changes: 57 additions & 57 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pytest = {version=">=7.2.1", optional = true}
pytest-durations = {version = ">=1.2.0", optional = true}

# installed as optional 'faker' extra
faker = {version = ">=22.5,<24.0", optional = true}
faker = {version = ">=22.5,<25.0", optional = true}

[tool.poetry.extras]
docs = [
Expand Down
19 changes: 11 additions & 8 deletions tests/core/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

import logging
import time

import pytest
import time_machine

from singer_sdk import metrics

Expand Down Expand Up @@ -79,13 +79,16 @@ def test_record_counter(caplog: pytest.LogCaptureFixture):

def test_sync_timer(caplog: pytest.LogCaptureFixture):
caplog.set_level(logging.INFO, logger=metrics.METRICS_LOGGER_NAME)
with metrics.sync_timer("test_stream", custom_tag="pytest") as timer:
start_time = timer.start_time
for _ in range(1000):
time.sleep(0.001)
end_time = time.time()
traveler = time_machine.travel(0, tick=False)
traveler.start()

assert len(caplog.records) == 1
with metrics.sync_timer("test_stream", custom_tag="pytest"):
traveler.stop()

traveler = time_machine.travel(10, tick=False)
traveler.start()

traveler.stop()

record = caplog.records[0]
assert record.levelname == "INFO"
Expand All @@ -100,4 +103,4 @@ def test_sync_timer(caplog: pytest.LogCaptureFixture):
"custom_tag": "pytest",
}

assert pytest.approx(point.value, rel=0.001) == end_time - start_time
assert pytest.approx(point.value, rel=0.001) == 10.0

0 comments on commit c97d229

Please sign in to comment.