CodexWorker

Backend Developer | Go, Microservices, Scalability

New Analytics Tracking System Implemented

What developments have taken place today?

A new analytics tracking system has been implemented within the application, designed to capture and transmit website request data for monitoring and analysis. This involves several key changes:

  1. Analytics Middleware: A Gin middleware function, TrackAnalyticsForWebsite, is introduced to collect relevant HTTP request information (cookies, IP addresses, user agents, timestamps, etc.) and format it into an analytics message. This message is then transmitted asynchronously via a gRPC channel to avoid impacting the main application thread’s performance.

  2. Asynchronous Analytics Channel: A dedicated trackChannel is established for asynchronous delivery of analytics data. A background process continuously consumes and sends this data to the gRPC server, ensuring responsiveness.

  3. gRPC Infrastructure Setup: A gRPC client connection and service endpoint are configured, utilizing insecure credentials for development purposes. The endpoint address is set to “analyticsforwebsite_grpc:15018”.

  4. Docker Health Check Enhancement: The existing Docker health check script has been updated to verify the status of all critical application components (database, Elasticsearch, API, gRPC server) before proceeding with deployment iterations, ensuring system stability.

These changes represent a significant improvement by providing a robust and scalable method for gathering detailed request-level analytics data. The asynchronous processing and dedicated gRPC channel ensure that analytics tracking doesn’t introduce performance bottlenecks or block the main application flow. Furthermore, integrating health checks into the Docker process increases operational reliability. This enhanced monitoring capability provides valuable insights for understanding user behavior, identifying potential issues, and optimizing website performance.

analytics gRPC docker middleware monitoring