Skip to main content

Vnstock Analytics Interface

Project description

VNAI

System resource management and performance optimization toolkit.

Installation

pip install vnai

Usage

from vnai import beam, flow, scope

# Your code here

Analytics & Telemetry Pipeline

Module: vnai/flow/relay.py

This module is responsible for collecting, buffering, and securely transmitting system analytics and telemetry data for VNAI.

Key Features & Logic

  • Singleton Class: Conduit

    • Ensures only one analytics pipeline runs per process.
    • Buffers analytics events (function calls, API requests, rate limits) in memory.
  • Data Buffering

    • Data is grouped into three categories: function_calls, api_requests, rate_limits.
    • Buffer size and sync interval are configurable (default: 50 events or 5 minutes).
    • Periodic and event-driven dispatch logic ensures timely delivery without overloading the endpoint.
  • Segment Detection

    • Each payload includes a top-level key segment to distinguish between free and paid users.
    • The segment is determined by the license status (ContentManager().is_paid_user).
  • Endpoint & Headers

    • All analytics data is POSTed to: https://hq.vnstocks.com/analytics
    • Requires HTTP header: x-api-key: 1yI8KgarntQr0ptriseHhb4kdomkenyNI8VPiyk5aoU
    • Content-Type is always application/json.
  • Payload Structure

    • Example:
      {
        "segment": "free", // or "paid"
        "analytics_data": { ... },
        "metadata": { ... }
      }
      
    • analytics_data contains buffered events; metadata includes timestamp, machine_id, trigger reason, and environment info.
  • Retry & Failure Handling

    • If a POST fails, the payload is queued in failed_queue (max 10 entries).
    • Retries are attempted on subsequent dispatches.
  • Configuration

    • Use from vnai.flow.relay import configure to (re)configure the endpoint if needed (default is always hq.vnstocks.com/analytics).
  • Usage Example

    from vnai.flow import relay
    relay.track_function_call('my_func', 'user', 0.05)
    relay.sync_now()  # Manually trigger immediate send
    

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vnai-2.2.2.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vnai-2.2.2-py3-none-any.whl (42.5 kB view details)

Uploaded Python 3

File details

Details for the file vnai-2.2.2.tar.gz.

File metadata

  • Download URL: vnai-2.2.2.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for vnai-2.2.2.tar.gz
Algorithm Hash digest
SHA256 a97fb9c419a332735e51231d2d04ecad1d73e3bb6009922200f22632ee95cefe
MD5 0b4be1894772f93f1a4789a8c82c1a64
BLAKE2b-256 8fc953399b664699dc1ac2d5788e50ac4653fe048e3db902eb64a339e7bbfb69

See more details on using hashes here.

File details

Details for the file vnai-2.2.2-py3-none-any.whl.

File metadata

  • Download URL: vnai-2.2.2-py3-none-any.whl
  • Upload date:
  • Size: 42.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for vnai-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3122beeb0aeee13afdb97709d3551af5b4ae4080407507540149667745e14ca5
MD5 7f8fc5646e543fa8e1d25c95c9315a96
BLAKE2b-256 ed880ea0040696f05b6a4a9fbed7eabbc11b4b594a96e935f07ca3dbbaf4a94c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page