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.1.tar.gz (37.5 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.1-py3-none-any.whl (42.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vnai-2.2.1.tar.gz
  • Upload date:
  • Size: 37.5 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.1.tar.gz
Algorithm Hash digest
SHA256 7b56b6d2c89ce4869043715d4638268fc5631da799f15b267fd90c220cdd83a9
MD5 306f62c542f19b5e33a629890e3136b7
BLAKE2b-256 d317e0debef226324164a4e87478ce3f64c7214675957278bef7685308807578

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vnai-2.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bca309bd12eef1ab95f4a58a25487751cb1e005ff6d9f0965ba0e884db8dc09f
MD5 9a2c3c9f71046617c1bf1db31c3145e0
BLAKE2b-256 7c7d20527b90ecf90decba84a1d83d8b886a92968b17c9858222777ee33793de

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