February 16, 2024 — 5 min read
Elevating Feature Flag Analytics in Flipt
In the dynamic realm of software development, the ability to swiftly adapt and iterate is paramount. Central to this agility are feature flags, enabling teams to toggle features on and off without redeploying code. Yet, the power of feature flags extends beyond mere toggling, they generate invaluable data that can illuminate how features perform and are engaged with by users. This data, when analyzed, can guide more informed decisions, enhancing user experience and system performance.
Recognizing the critical role of analytics in unlocking these insights, we at Flipt are thrilled to introduce a major leap forward: first-class analytics for feature flag evaluations, now available in our v1.37.0 release!
The Journey to Analytics in Flipt
Our path to integrating analytics into Flipt was largely shaped by our community. Feedback and feature requests from our users highlighted a growing need for deeper insights into how feature flags impact user interactions and system performance. We envisioned a solution tailored to the unique needs of our open-source community, one that would provide comprehensive analytics without compromising performance or usability.
Why Analytics Matter
At the heart of every feature flag lies a decision point: will this change benefit our users? Analytics provide the answer, offering a clear view of user engagement, feature performance, and potential issues. By analyzing flag evaluations, teams can make data-driven decisions, enhancing feature rollouts and system stability.
One common issue when adopting feature flags in your development and release process is the lack of visibility into which flags are being evaluated and how often. This can lead to uncertainty about the impact and lifetime of feature flags, such as the inability to know if a flag is safe to be deleted or not. Analytics in Flipt aims to address this challenge by providing insights into flag evaluations, enabling teams to make informed decisions and optimize their feature flag strategies.
Architecting Analytics: The ClickHouse Advantage
To accommodate the high volume of data generated by flag evaluations, we embarked on a journey to find the perfect storage solution. After extensive research, ClickHouse emerged as the ideal choice for its robust data warehousing capabilities, OLAP (Online Analytical Processing) support, and exceptional performance with time-series data. Also, the fact that it is open source and has a vibrant community around it made it a perfect fit for Flipt.
ClickHouse's columnar storage model allows for efficient data ingestion and querying, making it perfect for analyzing flag evaluations across multiple dimensions. Its support for complex queries and real-time analytics means we can now offer insights like flag evaluation counts over time, complete with gap filling to ensure data continuity.
The fact that ClickHouse is designed to handle large volumes of data with minimal hardware requirements was a significant factor in our decision. This ensures that Flipt users can leverage analytics without worrying about performance bottlenecks or resource constraints. ClickHouse also has a cloud hosted version, which makes it easy for users to get started with analytics in Flipt on AWS or GCP without having to manage their own infrastructure.
Optimizing our ClickHouse Implementation
Our initial approach, while effective, was somewhat naive in its execution. We stored and queried analytical data in a straightforward manner, which, despite leveraging ClickHouse's efficiency, didn't fully harness its potential for lightning-fast analytics.
As we delved deeper into ClickHouse's features and functionality, we discovered the power of materialized views—a feature that would dramatically transform our analytics performance. Materialized views in ClickHouse allowed us to pre-aggregate data, significantly reducing the computational load for common queries.
By refactoring our analytics implementation to utilize materialized views, we achieved a monumental performance boost. Query times plummeted from an average of 2 seconds to an astonishing 0.02 seconds. This optimization significantly enhances the user experience by providing near-instantaneous access to analytics insights.
After the optimization, the query performance improved significantly:
Note: This optimized aggregation and query will be in the next release of Flipt.
Configuration and Event Sourcing
Implementing this feature required a thoughtful approach to configuration and data management. We introduced a new configuration section that allows users to specify how and when data is collected, including a flush period for data dumping and the destination for storage.
analytics:
storage:
clickhouse:
enabled: true
url: clickhouse://clickhouse:9000/flipt_analytics
buffer:
flush_period: 2m
Our event sourcing model, inspired by our work with audit events, leverages OpenTelemetry (OTEL) for efficient data collection. By adopting OTEL's batching and export mechanisms, we ensure reliable data capture without the need for custom processing. This integration not only simplifies data collection but also enhances visibility into flag evaluations through span events, which can be invaluable for debugging and performance monitoring.
For more information on how to enable analytics in Flipt, check out our documentation.
Looking Ahead: The Future of Feature Flags in Flipt
As we celebrate the launch of our analytics feature, we're already looking to the future. Our roadmap includes expanding our analytics offerings to include more detailed aggregations, such as histograms and quantile measurements, based on user feedback.
We also plan to look at other solutions for analytic data storage, giving users the flexibility to choose the best solution for their needs.
Conclusion
The introduction of analytics to Flipt marks a significant milestone in our journey to provide powerful, developer-driven feature flagging tools. We're excited to see how our community leverages these new capabilities to drive innovation and excellence in their software projects.
If you're as excited about these developments as we are, we'd love to hear from you! Reach out via GitHub, Discord, or X to share your thoughts, feedback, or questions.