Giter Site home page Giter Site logo

insurancezebra / alooma-python-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yotamr/python-sdk

0.0 2.0 0.0 90 KB

The official Alooma Python SDK. Allows integration of Alooma into any Python application

License: Apache License 2.0

Python 100.00%

alooma-python-sdk's Introduction

Overview

The 'Python SDK' module (hereafter: The PySDK) provides a lightweight, efficient, reliable input point to Alooma. The module provides a library of methods to record events and report them to Alooma from any Python application.

Design

The module contains two main classes, the PythonSDK and the Sender.

  • PythonSDK

    • Enqueues events to be reported to the Alooma pipeline. Events are queued into a concurrent queue, from which they are later pulled by the Sender module to be sent to your dedicated Alooma server.
  • Sender

    • Dequeues messages and sends them to your dedicated Alooma server.
    • Runs as a daemon in the background.

When initialized, the PySDK instantiates a Sender. The Sender starts a separate thread on which a TCP connection is opened. Any disconnection, send error, or other event does not interfere with other code nor crash the service. The module handles errors automatically. Upon disconnection, the module attempts to renew the socket and connection.

Quick Integration

To integrate the PySDK into your code, please follow these few simple steps:

  1. Run pip install alooma_pysdk to install the SDK. Alternatively, the source can be downloaded directly from our GitHub repository.

  2. Import the module by adding the following line in your Python file:

import alooma_pysdk
  1. Initialize a PySDK instance by adding the following line in your Python file:

sdk = alooma_pysdk.PythonSDK(servers='') ```

  • token - A arbitrary unique identifier for this input.
  • servers - A list of the IPs / Hostnames of your dedicated Alooma servers, supplied by Alooma. To get a server definition, please contact [email protected]
  • There are many more useful parameters that can be supplied to this function. Here are some key ones (refer to the in-file merthod documentation for more):
    • port - The remote port to connect to. Can be left blank, unless specifically instructed otherwise by Alooma support
    • input_label - This will give the PySDK a distinct name in the system, which can be used to identify events that were received from this specific SDK integration. This appears as the name of the input node in your Alooma plumbing screen, and defaults to "Python SDK"
    • event_type - A string or callable which receives each event and returns a string. The event type for each event is placed in a _metadata.event_type field, which determines the type of the event in the Alooma Mapper screen
    • callback_func - A callback function can be provided to be called whenever a log message is emitted from the PySDK
  1. To report an event to Alooma simply add this one-liner to your code:

     sdk.report(event_dict)

    Alternatively, to report multiple events in one function call, use:

    sdk.report_many([event_dict, event_dict, ...])

In both cases, each event must be a valid Python dictionary or a string. If not, it will be discarded and the callback function, if provided, will be called with an appropriate message.

You are now ready to report events to your Alooma pipeline!

alooma-python-sdk's People

Contributors

dani29 avatar david0673 avatar ofri avatar ramiamar avatar urishalit avatar yonatankiron avatar yuvalbar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.