Skip to main content

An zipkin extension for sqlalchemy library based on py_zipkin.

Project description

An zipkin extension for SQLAlchemy library based on py_zipkin.

Installation

pip install SQLAlchemy-Zipkin

Usage

import requests
import sqlalchemy_zipkin


PREAMBLE = sqlalchemy_zipkin.ZIPKIN_THRIFT_PREAMBLE


def http_transport(encoded_span):
    # type: (bytes) -> None

    # The collector expects a thrift-encoded list of spans. Instead of
    # decoding and re-encoding the already thrift-encoded message, we can just
    # add header bytes that specify that what follows is a list of length 1.
    url = 'http://zipkin:9411/api/v1/spans'

    body = PREAMBLE + encoded_span
    requests.post(
        url,
        data=body,
        headers={'Content-Type': 'application/x-thrift'},
    )


 sqla_instance = sqlalchemy_zipkin.SqlAlchemyZipkinInstrumentation(
     http_transport, sample_rate=50.0)
 sqla_instance.start()

Usage with Kafka

import functools
import sqlalchemy_zipkin
from kafka import KafkaProducer


def kafka_transport(stream_name, encoded_span):
    # type: (string) -> None
    # type: (bytes) -> None

    try:
        # If you use zipnkin kafka docker compose use port 19092
        producer = KafkaProducer(bootstrap_servers='localhost:9092')
        future = producer.send(stream_name, message)
    except Exception as e:
        print(str(e))


 sqla_instance = sqlalchemy_zipkin.SqlAlchemyZipkinInstrumentation(
     functools.partial(kafka_transport, 'zipkin'), sample_rate=50.0)
 sqla_instance.start()

0.2.0

  • Update py_zipkin dependency

  • Add note about using kafka collectors.

  • Prepare for PyPi release.

0.1.0

  • Initial version

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

SQLAlchemy-Zipkin-0.2.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

SQLAlchemy_Zipkin-0.2.0-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file SQLAlchemy-Zipkin-0.2.0.tar.gz.

File metadata

  • Download URL: SQLAlchemy-Zipkin-0.2.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for SQLAlchemy-Zipkin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a744c64f250af67bcace05992504475f854a3b6ac98b6c8e14d5564be3439b22
MD5 e407bec87c8fed87e03932056baf6dd8
BLAKE2b-256 3b870c1b123ac2b5304e79c84e4962bd700bca266d0fbf987601bcf88e5fc002

See more details on using hashes here.

File details

Details for the file SQLAlchemy_Zipkin-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: SQLAlchemy_Zipkin-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for SQLAlchemy_Zipkin-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 922f97a0671ef01cbc7561b31b8a3133662ab60afe01c25180654afa384a7af1
MD5 d2ce01fa9723d35e55e4dd045ba4ff36
BLAKE2b-256 851938dcb794b17976fe543d2ad332bb98030465d954eb71b25e33b2383e9373

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