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

Enforce (or provide user-facing warnings) instantiating the Python client as a singleton #152

Open
dmarticus opened this issue Dec 17, 2024 · 0 comments

Comments

@dmarticus
Copy link
Contributor

Full context can be found here: https://posthog.slack.com/archives/C03P7NL6RMW/p1733514026622539, but here's the summary for external stakeholders:

Issue:

  • Users were experiencing dropped events when using the Python SDK
  • Feature flag events were being captured but other events weren't
  • Investigation revealed multiple SDK client instances were being instantiated
  • No warnings/exceptions were thrown on multiple client instantiations

Root Cause:

  • The SDK doesn't enforce a singleton pattern for client instances
  • Multiple client instances in the same application can cause event capture issues
  • This becomes particularly problematic in containerized environments like Kubernetes

Solution:

  • Implement a singleton factory pattern to prevent multiple client instantiations
  • Add explicit warnings/exceptions when users try to create multiple clients
  • Update documentation to:
    • Clearly explain the singleton requirement
    • Provide best practices for client instantiation
    • Include guidance for complex infrastructure setups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant