Skip to content

Commit f1db54e

Browse files
committed
Add hook to send provider assignment
1 parent 691b777 commit f1db54e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from localstack.runtime import hooks
2+
3+
4+
@hooks.on_runtime_ready()
5+
def publish_provider_assignment():
6+
"""
7+
Publishes the service provider assignment to the analytics service.
8+
"""
9+
from datetime import datetime
10+
11+
from localstack.config import SERVICE_PROVIDER_CONFIG
12+
from localstack.utils.analytics import get_session_id
13+
from localstack.utils.analytics.events import Event, EventMetadata
14+
from localstack.utils.analytics.publisher import AnalyticsClientPublisher
15+
16+
provider_assignment = {
17+
service: f"localstack.aws.provider/{service}:{provider}"
18+
for service, provider in SERVICE_PROVIDER_CONFIG.items()
19+
if provider
20+
}
21+
metadata = EventMetadata(
22+
session_id=get_session_id(),
23+
client_time=str(datetime.now()),
24+
)
25+
26+
event = Event(
27+
name="ls_service_provider_assignment", metadata=metadata, payload=provider_assignment
28+
)
29+
30+
AnalyticsClientPublisher().publish([event])

0 commit comments

Comments
 (0)