Pinterest Engineering

Build an end to end JSON logging system for clients apps

thumbnail

Introduction

This article discusses the implementation and use cases of an end-to-end JSON logging system for client apps. It describes the state of logging prior to this system, and highlights the need for a better approach.

State of Logging

Before the implementation of this system, logging on the client side was limited to a few methods such as context logging. These methods were often time-critical and only logged impressions or anything related to business. This made it difficult for developers to log other types of data, and made it hard to visualize or aggregate the logs. Additionally, there wasn't a system for real-time monitoring or alerting with log-based custom metrics.

Architecture

The high-level schema of the system involves client-side service integration to provide metadata. Developers only need to provide the name of the log and actual log payload. Visualization of logs is done on OpenSearch, which is integrated with Elasticsearch and Kibana. Real-time alerting is possible using log-based metrics.

Use-Cases

The JSON logging system has been widely adopted by developers mainly for:

  • Client visibility: Networking metrics and crash metrics to better understand client performance and signals.
  • Performance insight: Information provided by iOS MetricKit to monitor performance.
  • Custom error reporting: Reporting exceptions, soft errors, and assertions for better analysis.
  • Product surface/feature SLA: Reporting product feature health to monitor success/failure rates in real-time.
  • Debugging: Adding logs to help troubleshoot difficult bugs that are hard to reproduce locally or occur on certain devices/OS versions.

Conclusion

The implementation of the JSON logging system has made it easier for developers to log and monitor various aspects of their apps. It has enabled real-time monitoring and alerting, and made it easier to visualize and aggregate logs.