Metadata-Version: 2.1
Name: SQLAlchemy-Zipkin
Version: 0.2.0
Summary: An zipkin extension for sqlalchemy library based on py_zipkin.
Home-page: https://github.com/mklein0/sqlalchemy-zipkin
Author: Marcos Klein
Author-email: mklein0@gmail.com
License: MIT
Description: #################
        SQLAlchemy-Zipkin
        #################
        
        An zipkin extension for SQLAlchemy library based on py\_zipkin.
        
        
        ************
        Installation
        ************
        
        .. code-block:: bash
        
          pip install SQLAlchemy-Zipkin
        
        
        *****
        Usage
        *****
        
        .. code-block:: python
        
          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
        ****************
        
        .. code-block:: python
        
          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
        
Platform: any
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Description-Content-Type: text/x-rst
