Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Add optional body delivery IDs, source admission and acknowledgement profiles.

Revision ID: 038
Revises: 037
Revision ID: 039
Revises: 038
"""

from collections.abc import Sequence
Expand All @@ -10,8 +10,8 @@
from alembic import op


revision: str = "038"
down_revision: str = "037"
revision: str = "039"
down_revision: str = "038"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None

Expand Down
27 changes: 14 additions & 13 deletions openhands/automation/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,21 @@ async def accept_event(
org_id,
)
pending_telemetry: list[tuple[str, dict[str, Any]]] = []
pending_telemetry.append(
(
"automation_event_matched",
{
"properties": {
"event_source": source,
"event_key": event.event_key,
"org_id": str(org_id),
"candidate_count": len(automations),
"matched_count": len(matched),
}
},
if matched:
pending_telemetry.append(
(
"automation_event_matched",
{
"properties": {
"event_source": source,
"event_key": event.event_key,
"org_id": str(org_id),
"candidate_count": len(automations),
"matched_count": len(matched),
}
},
)
)
)

event_parent_span_context = current_span_context()

Expand Down
37 changes: 37 additions & 0 deletions tests/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,43 @@ async def test_accept_event_telemetry_needs_a_session_source(
assert captured_telemetry == []


@pytest.mark.asyncio
async def test_accept_event_skips_product_telemetry_when_nothing_matches(
org_id: uuid.UUID,
async_session,
async_session_factory,
slack_payload: dict,
mock_authenticated_user,
captured_telemetry: list[str],
):
async_session.add(
make_automation(
org_id,
mock_authenticated_user.user_id,
{"type": "event", "source": "slack", "on": "message"},
)
)
await async_session.commit()

result = await accept_event(
org_id,
AcceptedEvent(
source="slack",
event_key="app_mention",
payload=slack_payload,
),
async_session,
session_factory=async_session_factory,
)

assert result.matched == 0
assert captured_telemetry == []

events = await fetch_events(async_session)
assert len(events) == 1
assert events[0].matched_count == 0


@pytest.mark.asyncio
async def test_accepted_event_defaults():
"""Only `source` and `event_key` are required."""
Expand Down
Loading