Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle analytics publishing errors more gracefully #10185

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions localstack/utils/analytics/usage.py
@@ -1,4 +1,5 @@
import datetime
import logging
import math
from typing import Any

Expand All @@ -7,6 +8,8 @@
from localstack.utils.analytics.events import Event, EventMetadata
from localstack.utils.analytics.publisher import AnalyticsClientPublisher

LOG = logging.getLogger(__name__)

# Counters have to register with the registry
collector_registry: dict[str, Any] = dict()

Expand Down Expand Up @@ -116,6 +119,9 @@ def aggregate_and_send():
aggregated_payload = aggregate()

publisher = AnalyticsClientPublisher()
publisher.publish(
[Event(name="ls:usage_analytics", metadata=metadata, payload=aggregated_payload)]
)
try:
publisher.publish(
[Event(name="ls:usage_analytics", metadata=metadata, payload=aggregated_payload)]
)
Comment on lines +123 to +125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason for not using the global analytics bus here? it already does buffering and graceful handling of errors

except Exception as e:
LOG.info("Unable to report analytics: %s", e)
whummer marked this conversation as resolved.
Show resolved Hide resolved