Client SDK Python

footprint-sdk-python is a Python library that helps you interact with Footprint Ingestor Server. This Developer Preview is provided to receive feedback from other teams on SDK changes prior to the final release. As such users should expect the SDK to release minor version releases that break backwards compatability. The release notes for the breaking change will include information about the breaking change, and how you can migrate to the latest version.

Installation

Requirements: This library requires Python 3.8 or above.

git config --global url."git@git.teko.vn:".insteadOf  "https://git.teko.vn/"

pip install git+ssh://git@git.teko.vn/footprint/footprint.git
pip install git+ssh://git@git.teko.vn/footprint/footprint-dto.git --no-binary protobuf

For only user using pipfile

If you are using pipfile in your project, add following packages into pipfile:

footprint = {git = "ssh://git@git.teko.vn/footprint/footprint.git"}
footprint-dto = {git = "ssh://git@git.teko.vn/footprint/footprint.git"}

Then export environment variable "PIP_NO_BINARY=protobuf" or install by PIP_NO_BINARY=protobuf pipenv install

Getting started

Define your protobuf type

Submit a MR to the footprint-proto repository that defines the the protobuf type of the messages that you would like to log to our system (an example can be seen here). Once the MR is merged, we would publish the generated code to the footprint-dto repository from which you can import the relevang golang packages.

Please note that we only support 1 single event/log type per proto file and thus assume that the first type defined in the proto is the event that you’d like to log to our system.

Code Example

The example below illustrates how we could interact with Ingestor Server through this Python SDK.

import footprintdto.example.v1.pageview_pb2 as pageview_pb2

from footprint.sdk import Client, GrpcClientConfig

# create a new Client instance. By default, it will log every send request to stdout.
# you can configure the sdk to use different transportation by passing `grpc_client_config` or `http_client_config` to the constructor.
client = Client(grpc_client_config=GrpcClientConfig(address="localhost:8080"))

try:
    # check liveness
    client_is_alive = client.liveness()
    if client_is_alive:
        print("Check liveness completed with response:", client_is_alive)
    else:
        print("Check liveness failed!")
except Exception:
        print("method not supported")

try:
    # check readiness
    client_is_ready = client.readiness()
    if client_is_ready:
        print("Check readiness completed with response:", client_is_ready)
    else:
        print("Check readiness failed!")
except Exception:
        print("method not supported")

pv = pageview_pb2.PageView()
pv.location = "somewhere"

# send message synchronously
response = client.send_log(pv, timeout=10, retry=5)
if response:
    print("Send request completed with response:", response.__dict__)

# send messages asynchronously
task = client.async_send_log(pv, timeout=5, retry=3)
task.join()

# close the client instance
client.close()

Support

If you have any question regarding this SDK, feel free contact the footprint/tracking team via #footprint-support Slack channel.

Report Issues

If you encounter a bug with the Footprint SDK for Python we would like to hear about it. Search the [existing issues][issues] and see if others are also experiencing the issue before opening a new issue. Please include the version of Footprint SDK for Python, Python version, and the OS you’re using. Please also include reproduction steps when appropriate.

The GitLab issues are intended for bug reports and feature requests. For help and questions with using Footprint SDK for Python.