1gRPC Python Observability 2========================= 3 4Package for gRPC Python Observability. 5 6More details can be found in `OpenTelemetry Metrics gRFC <https://github.com/grpc/proposal/blob/master/A66-otel-stats.md#opentelemetry-metrics>`_. 7 8How gRPC Python Observability Works 9----------------------------------- 10 11gRPC Python is a wrapper layer built upon the gRPC Core (written in C/C++). Most of telemetry data 12is collected at core layer and then exported to Python layer. To optimize performance and reduce 13the overhead of acquiring the GIL too frequently, telemetry data is initially cached at the Core layer 14and then exported to the Python layer in batches. 15 16Note that while this approach enhances efficiency, it will introduce a slight delay between the 17time the data is collected and the time it becomes available through Python exporters. 18 19 20 21Installation 22------------ 23 24Currently gRPC Python Observability is **only available for Linux**. 25 26Installing From PyPI 27~~~~~~~~~~~~~~~~~~~~ 28 29:: 30 31 $ pip install grpcio-observability 32 33 34Installing From Source 35~~~~~~~~~~~~~~~~~~~~~~ 36 37Building from source requires that you have the Python headers (usually a 38package named :code:`python-dev`) and Cython installed. It further requires a 39GCC-like compiler to go smoothly; you can probably get it to work without 40GCC-like stuff, but you may end up having a bad time. 41 42:: 43 44 $ export REPO_ROOT=grpc # REPO_ROOT can be any directory of your choice 45 $ git clone -b RELEASE_TAG_HERE https://github.com/grpc/grpc $REPO_ROOT 46 $ cd $REPO_ROOT 47 $ git submodule update --init 48 49 $ cd src/python/grpcio_observability 50 $ python -m make_grpcio_observability 51 52 # For the next command do `sudo pip install` if you get permission-denied errors 53 $ GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install . 54 55 56Dependencies 57------------ 58gRPC Python Observability Depends on the following packages: 59 60:: 61 62 grpcio 63 opentelemetry-api 64 65 66Usage 67----- 68 69You can find example usage in `Python example folder <https://github.com/grpc/grpc/tree/master/examples/python/observability>`_. 70 71We also provide several environment variables to help you optimize gRPC python observability for your particular use. 72 731. GRPC_PYTHON_CENSUS_EXPORT_BATCH_INTERVAL 74 * This controls how frequently telemetry data collected within gRPC Core is sent to Python layer. 75 * Default value is 0.5 (Seconds). 76 772. GRPC_PYTHON_CENSUS_MAX_EXPORT_BUFFER_SIZE 78 * This controls the maximum number of telemetry data items that can be held in the buffer within gRPC Core before they are sent to Python. 79 * Default value is 10,000. 80 813. GRPC_PYTHON_CENSUS_EXPORT_THRESHOLD 82 * This setting acts as a trigger: When the buffer in gRPC Core reaches a certain percentage of its capacity, the telemetry data is sent to Python. 83 * Default value is 0.7 (Which means buffer will start export when it's 70% full). 84 854. GRPC_PYTHON_CENSUS_EXPORT_THREAD_TIMEOUT 86 * This controls the maximum time allowed for the exporting thread (responsible for sending data to Python) to complete. 87 * Main thread will terminate the exporting thread after this timeout. 88 * Default value is 10 (Seconds). 89