Skip to content

Commit

Permalink
[getsentry/action-github-commit] Auto commit
Browse files Browse the repository at this point in the history
  • Loading branch information
getsantry[bot] authored Dec 13, 2024
1 parent b911509 commit c1aaf45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion snuba/manual_jobs/scrub_ips_from_eap_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def execute(self, logger: JobLogger) -> None:
logger.info("Executing query: {query}")
result = connection.execute(query=query, settings={"mutations_sync": 0})
logger.info("complete")
logger.info(repr(result))
logger.info(repr(result))
37 changes: 15 additions & 22 deletions tests/manual_jobs/test_scrub_ips_from_eap_spans.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import pytest
from snuba.datasets.processors.replays_processor import to_datetime

from snuba.manual_jobs import JobSpec
from snuba.manual_jobs.job_status import JobStatus
from snuba.manual_jobs.runner import get_job_status, run_job
from snuba.manual_jobs.scrub_ips_from_eap_spans import ScrubIpFromEAPSpans
from tests.helpers import write_raw_unprocessed_events
from datetime import datetime
from typing import Any, Mapping
import random
import uuid
from datetime import datetime, timedelta, timezone

from typing import Any, Mapping

import pytest
from google.protobuf.json_format import MessageToDict, ParseDict
Expand Down Expand Up @@ -43,8 +33,13 @@
TraceItemFilter,
)

from snuba.datasets.processors.replays_processor import to_datetime
from snuba.datasets.storages.factory import get_storage
from snuba.datasets.storages.storage_key import StorageKey
from snuba.manual_jobs import JobSpec
from snuba.manual_jobs.job_status import JobStatus
from snuba.manual_jobs.runner import get_job_status, run_job
from snuba.manual_jobs.scrub_ips_from_eap_spans import ScrubIpFromEAPSpans
from snuba.web.rpc.common.exceptions import BadSnubaRPCRequestException
from snuba.web.rpc.v1.endpoint_trace_item_table import (
EndpointTraceItemTable,
Expand Down Expand Up @@ -221,6 +216,7 @@ def _gen_message(
"end_timestamp_precise": dt.timestamp() + 1,
}


def _generate_request(ts: Any, hour_ago: int) -> TraceItemTableRequest:
return TraceItemTableRequest(
meta=RequestMeta(
Expand All @@ -238,27 +234,24 @@ def _generate_request(ts: Any, hour_ago: int) -> TraceItemTableRequest:
)
),
columns=[
Column(
key=AttributeKey(type=AttributeKey.TYPE_STRING, name="server_name")
)
Column(key=AttributeKey(type=AttributeKey.TYPE_STRING, name="server_name"))
],
order_by=[
TraceItemTableRequest.OrderBy(
column=Column(
key=AttributeKey(
type=AttributeKey.TYPE_STRING, name="server_name"
)
key=AttributeKey(type=AttributeKey.TYPE_STRING, name="server_name")
)
)
],
)


@pytest.mark.clickhouse_db
@pytest.mark.redis_db
def test_span_is_scrubbed() -> None:
BASE_TIME = datetime.utcnow().replace(minute=0, second=0, microsecond=0) - timedelta(
minutes=180
)
BASE_TIME = datetime.utcnow().replace(
minute=0, second=0, microsecond=0
) - timedelta(minutes=180)
spans_storage = get_storage(StorageKey("eap_spans"))
start = BASE_TIME
messages = [_gen_message(start - timedelta(minutes=i)) for i in range(2)]
Expand All @@ -279,7 +272,7 @@ def test_span_is_scrubbed() -> None:
page_token=PageToken(offset=2),
meta=ResponseMeta(request_id="be3123b3-2e5d-4eb9-bb48-f38eaa9e8480"),
)
assert response == expected_response # type: ignore
assert response == expected_response # type: ignore

run_job(
JobSpec(
Expand All @@ -296,4 +289,4 @@ def test_span_is_scrubbed() -> None:
message = _generate_request(ts, hour_ago)
response = EndpointTraceItemTable().execute(message)
print(response)
assert False
assert False

0 comments on commit c1aaf45

Please sign in to comment.