示例#1
0
def test_time_synthetic_monitoring_event_in_save_event(mock_metrics_timing):
    tags = {
        "source_region": "region-1",
        "target": "target.io",
        "source": "source-1",
    }
    extra = {"key": "value", "another": "val"}
    extra.update(tags)
    data = {
        "project": 1,
        "timestamp": time(),
        "extra": {
            "_sentry_synthetic_monitoring": extra
        },
    }
    with override_settings(SENTRY_SYNTHETIC_MONITORING_PROJECT_ID=1):
        assert time_synthetic_monitoring_event(data, 1, time()) is True

    to_ingest, to_process = mock_metrics_timing.mock_calls

    assert to_ingest.args == (
        "events.synthetic-monitoring.time-to-ingest-total",
        mock.ANY,
    )
    assert to_ingest.kwargs == {"tags": tags, "sample_rate": 1.0}

    assert to_process.args == (
        "events.synthetic-monitoring.time-to-process",
        mock.ANY,
    )
    assert to_process.kwargs == {"tags": tags, "sample_rate": 1.0}
示例#2
0
def test_time_synthetic_monitoring_event_in_save_event_missing_extra(
        mock_metrics_timing):
    data = {"project": 1}
    with override_settings(SENTRY_SYNTHETIC_MONITORING_PROJECT_ID=1):
        assert time_synthetic_monitoring_event(data, 1, time()) is False
    assert mock_metrics_timing.call_count == 0