Skip to content

Commit

Permalink
Changes based on comment
Browse files Browse the repository at this point in the history
  • Loading branch information
XuanWang-Amos committed Jan 19, 2024
1 parent 47f9f91 commit 4991dfe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
7 changes: 7 additions & 0 deletions doc/python/sphinx/grpc_observability.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
gRPC Python Observability
====================

Module Contents
---------------

.. automodule:: grpc_observability
14 changes: 7 additions & 7 deletions src/python/grpcio_observability/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ More details can be found in `OpenTelemetry Metrics gRFC <https://github.com/grp
How gRPC Python Observability Works
-------------------------

gRPC Python is a wrapper layer built upon the gRPC Core (written in C/C++). Most of census data
gRPC Python is a wrapper layer built upon the gRPC Core (written in C/C++). Most of telemetry data
is collected at core layer and then exported to Python layer. To optimize performance and reduce
the overhead of acquiring GIL too frequently, census data is initially cached at the Core layer
the overhead of acquiring the GIL too frequently, telemetry data is initially cached at the Core layer
and then exported to the Python layer in batches.

Note that while this approach enhances efficiency, it will introduce a slight delay between the
Expand All @@ -23,7 +23,7 @@ Python >= 3.7
Installation
------------

Currently gRPC Python Observability is :code:`only available for Linux`.
Currently gRPC Python Observability is **only available for Linux**.

Installing From PyPI
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -71,18 +71,18 @@ Usage

You can find example usage in `Python example folder <https://github.com/grpc/grpc/tree/master/examples/python/observability>`_.

We also provides couple of environment variables to help you optimize gRPC python observability for your particular use.
We also provide several environment variables to help you optimize gRPC python observability for your particular use.

1. GRPC_PYTHON_CENSUS_EXPORT_BATCH_INTERVAL
* This controls how frequently census data collected within gRPC Core is sent to Python layer.
* This controls how frequently telemetry data collected within gRPC Core is sent to Python layer.
* Default value is 0.5 (Seconds).

2. GRPC_PYTHON_CENSUS_MAX_EXPORT_BUFFER_SIZE
* This controls the maximum number of census data items that can be held in the buffer within gRPC Core before they are sent to Python.
* 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.
* Default value is 10,000.

3. GRPC_PYTHON_CENSUS_EXPORT_THRESHOLD
* This setting acts as a trigger: When the buffer in gRPC Core reaches a certain percentage of its capacity, the census data is sent to Python.
* 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.
* Default value is 0.7 (Which means buffer will start export when it's 70% full).

4. GRPC_PYTHON_CENSUS_EXPORT_THREAD_TIMEOUT
Expand Down
2 changes: 1 addition & 1 deletion tools/run_tests/artifacts/artifact_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def build_jobspec(self, inner_jobs=None):

if self.platform == "macos":
environ["ARCHFLAGS"] = "-arch arm64 -arch x86_64"
environ["GRPC_UNIVERSAL2_REPAIR"] = "true"
environ["GRPC_BUILD_MAC"] = "true"

if self.platform == "linux_extra":
# Crosscompilation build for armv7 (e.g. Raspberry Pi)
Expand Down
4 changes: 2 additions & 2 deletions tools/run_tests/artifacts/build_artifact_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ fix_faulty_universal2_wheel() {
# This is necessary due to https://github.com/pypa/wheel/issues/406.
# wheel incorrectly generates a universal2 artifact that only contains
# x86_64 libraries.
if [ "$GRPC_UNIVERSAL2_REPAIR" != "" ]; then
if [ "$GRPC_BUILD_MAC" != "" ]; then
for WHEEL in dist/*.whl tools/distrib/python/grpcio_tools/dist/*.whl; do
fix_faulty_universal2_wheel "$WHEEL"
done
Expand Down Expand Up @@ -284,7 +284,7 @@ then

# Build grpcio_observability source distribution
# Skips MacOS since grpcio_observability does not support MacOS.
if [ "$GRPC_UNIVERSAL2_REPAIR" == "" ]; then
if [ "$GRPC_BUILD_MAC" == "" ]; then
"${PYTHON}" src/python/grpcio_observability/make_grpcio_observability.py
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_observability/setup.py \
sdist bdist_wheel
Expand Down

0 comments on commit 4991dfe

Please sign in to comment.