Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/INSTALLER +1 -0
- vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/METADATA +105 -0
- vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/RECORD +85 -0
- vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/REQUESTED +0 -0
- vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/WHEEL +5 -0
- vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/entry_points.txt +2 -0
- vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/top_level.txt +1 -0
- vllm/lib/python3.10/site-packages/opencensus/__init__.py +1 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/__init__.py +23 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/__init__.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag_key.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag_map.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag_value.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/validation.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/propagation/__init__.py +13 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/propagation/__pycache__/__init__.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/propagation/__pycache__/binary_serializer.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/tags/propagation/binary_serializer.py +109 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/__init__.py +17 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/attributes.py +74 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/base_exporter.py +43 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/base_span.py +109 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/blank_span.py +165 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/config_integration.py +38 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/exceptions_status.py +25 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/execution_context.py +89 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/link.py +71 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__init__.py +13 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/__init__.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/b3_format.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/binary_format.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/google_cloud_format.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/text_format.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/trace_context_http_header_format.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/tracestate_string_format.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/b3_format.py +117 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/binary_format.py +168 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/google_cloud_format.py +128 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/text_format.py +85 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/trace_context_http_header_format.py +115 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/propagation/tracestate_string_format.py +43 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/samplers/__init__.py +94 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/span_context.py +168 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/stack_trace.py +189 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/status.py +84 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/trace_options.py +78 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/tracer.py +144 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/tracers/__init__.py +13 -0
- vllm/lib/python3.10/site-packages/opencensus/trace/tracers/__pycache__/context_tracer.cpython-310.pyc +0 -0
vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: anyio
|
| 3 |
+
Version: 4.7.0
|
| 4 |
+
Summary: High level compatibility layer for multiple asynchronous event loop implementations
|
| 5 |
+
Author-email: Alex Grönholm <alex.gronholm@nextday.fi>
|
| 6 |
+
License: MIT
|
| 7 |
+
Project-URL: Documentation, https://anyio.readthedocs.io/en/latest/
|
| 8 |
+
Project-URL: Changelog, https://anyio.readthedocs.io/en/stable/versionhistory.html
|
| 9 |
+
Project-URL: Source code, https://github.com/agronholm/anyio
|
| 10 |
+
Project-URL: Issue tracker, https://github.com/agronholm/anyio/issues
|
| 11 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 12 |
+
Classifier: Intended Audience :: Developers
|
| 13 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 14 |
+
Classifier: Framework :: AnyIO
|
| 15 |
+
Classifier: Typing :: Typed
|
| 16 |
+
Classifier: Programming Language :: Python
|
| 17 |
+
Classifier: Programming Language :: Python :: 3
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 23 |
+
Requires-Python: >=3.9
|
| 24 |
+
Description-Content-Type: text/x-rst
|
| 25 |
+
License-File: LICENSE
|
| 26 |
+
Requires-Dist: exceptiongroup>=1.0.2; python_version < "3.11"
|
| 27 |
+
Requires-Dist: idna>=2.8
|
| 28 |
+
Requires-Dist: sniffio>=1.1
|
| 29 |
+
Requires-Dist: typing_extensions>=4.5; python_version < "3.13"
|
| 30 |
+
Provides-Extra: trio
|
| 31 |
+
Requires-Dist: trio>=0.26.1; extra == "trio"
|
| 32 |
+
Provides-Extra: test
|
| 33 |
+
Requires-Dist: anyio[trio]; extra == "test"
|
| 34 |
+
Requires-Dist: coverage[toml]>=7; extra == "test"
|
| 35 |
+
Requires-Dist: exceptiongroup>=1.2.0; extra == "test"
|
| 36 |
+
Requires-Dist: hypothesis>=4.0; extra == "test"
|
| 37 |
+
Requires-Dist: psutil>=5.9; extra == "test"
|
| 38 |
+
Requires-Dist: pytest>=7.0; extra == "test"
|
| 39 |
+
Requires-Dist: pytest-mock>=3.6.1; extra == "test"
|
| 40 |
+
Requires-Dist: trustme; extra == "test"
|
| 41 |
+
Requires-Dist: truststore>=0.9.1; python_version >= "3.10" and extra == "test"
|
| 42 |
+
Requires-Dist: uvloop>=0.21; (platform_python_implementation == "CPython" and platform_system != "Windows") and extra == "test"
|
| 43 |
+
Provides-Extra: doc
|
| 44 |
+
Requires-Dist: packaging; extra == "doc"
|
| 45 |
+
Requires-Dist: Sphinx~=7.4; extra == "doc"
|
| 46 |
+
Requires-Dist: sphinx_rtd_theme; extra == "doc"
|
| 47 |
+
Requires-Dist: sphinx-autodoc-typehints>=1.2.0; extra == "doc"
|
| 48 |
+
|
| 49 |
+
.. image:: https://github.com/agronholm/anyio/actions/workflows/test.yml/badge.svg
|
| 50 |
+
:target: https://github.com/agronholm/anyio/actions/workflows/test.yml
|
| 51 |
+
:alt: Build Status
|
| 52 |
+
.. image:: https://coveralls.io/repos/github/agronholm/anyio/badge.svg?branch=master
|
| 53 |
+
:target: https://coveralls.io/github/agronholm/anyio?branch=master
|
| 54 |
+
:alt: Code Coverage
|
| 55 |
+
.. image:: https://readthedocs.org/projects/anyio/badge/?version=latest
|
| 56 |
+
:target: https://anyio.readthedocs.io/en/latest/?badge=latest
|
| 57 |
+
:alt: Documentation
|
| 58 |
+
.. image:: https://badges.gitter.im/gitterHQ/gitter.svg
|
| 59 |
+
:target: https://gitter.im/python-trio/AnyIO
|
| 60 |
+
:alt: Gitter chat
|
| 61 |
+
|
| 62 |
+
AnyIO is an asynchronous networking and concurrency library that works on top of either asyncio_ or
|
| 63 |
+
trio_. It implements trio-like `structured concurrency`_ (SC) on top of asyncio and works in harmony
|
| 64 |
+
with the native SC of trio itself.
|
| 65 |
+
|
| 66 |
+
Applications and libraries written against AnyIO's API will run unmodified on either asyncio_ or
|
| 67 |
+
trio_. AnyIO can also be adopted into a library or application incrementally – bit by bit, no full
|
| 68 |
+
refactoring necessary. It will blend in with the native libraries of your chosen backend.
|
| 69 |
+
|
| 70 |
+
Documentation
|
| 71 |
+
-------------
|
| 72 |
+
|
| 73 |
+
View full documentation at: https://anyio.readthedocs.io/
|
| 74 |
+
|
| 75 |
+
Features
|
| 76 |
+
--------
|
| 77 |
+
|
| 78 |
+
AnyIO offers the following functionality:
|
| 79 |
+
|
| 80 |
+
* Task groups (nurseries_ in trio terminology)
|
| 81 |
+
* High-level networking (TCP, UDP and UNIX sockets)
|
| 82 |
+
|
| 83 |
+
* `Happy eyeballs`_ algorithm for TCP connections (more robust than that of asyncio on Python
|
| 84 |
+
3.8)
|
| 85 |
+
* async/await style UDP sockets (unlike asyncio where you still have to use Transports and
|
| 86 |
+
Protocols)
|
| 87 |
+
|
| 88 |
+
* A versatile API for byte streams and object streams
|
| 89 |
+
* Inter-task synchronization and communication (locks, conditions, events, semaphores, object
|
| 90 |
+
streams)
|
| 91 |
+
* Worker threads
|
| 92 |
+
* Subprocesses
|
| 93 |
+
* Asynchronous file I/O (using worker threads)
|
| 94 |
+
* Signal handling
|
| 95 |
+
|
| 96 |
+
AnyIO also comes with its own pytest_ plugin which also supports asynchronous fixtures.
|
| 97 |
+
It even works with the popular Hypothesis_ library.
|
| 98 |
+
|
| 99 |
+
.. _asyncio: https://docs.python.org/3/library/asyncio.html
|
| 100 |
+
.. _trio: https://github.com/python-trio/trio
|
| 101 |
+
.. _structured concurrency: https://en.wikipedia.org/wiki/Structured_concurrency
|
| 102 |
+
.. _nurseries: https://trio.readthedocs.io/en/stable/reference-core.html#nurseries-and-spawning
|
| 103 |
+
.. _Happy eyeballs: https://en.wikipedia.org/wiki/Happy_Eyeballs
|
| 104 |
+
.. _pytest: https://docs.pytest.org/en/latest/
|
| 105 |
+
.. _Hypothesis: https://hypothesis.works/
|
vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
anyio-4.7.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
anyio-4.7.0.dist-info/LICENSE,sha256=U2GsncWPLvX9LpsJxoKXwX8ElQkJu8gCO9uC6s8iwrA,1081
|
| 3 |
+
anyio-4.7.0.dist-info/METADATA,sha256=A-A-n0m-esMw8lYv8a9kqsr84J2aFh8MvqcTq2Xx_so,4653
|
| 4 |
+
anyio-4.7.0.dist-info/RECORD,,
|
| 5 |
+
anyio-4.7.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 6 |
+
anyio-4.7.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
| 7 |
+
anyio-4.7.0.dist-info/entry_points.txt,sha256=_d6Yu6uiaZmNe0CydowirE9Cmg7zUL2g08tQpoS3Qvc,39
|
| 8 |
+
anyio-4.7.0.dist-info/top_level.txt,sha256=QglSMiWX8_5dpoVAEIHdEYzvqFMdSYWmCj6tYw2ITkQ,6
|
| 9 |
+
anyio/__init__.py,sha256=5NCKQNJueCeIJqVbOpAQdho2HIQrQvcnfQjuEhAiZcc,4433
|
| 10 |
+
anyio/__pycache__/__init__.cpython-310.pyc,,
|
| 11 |
+
anyio/__pycache__/from_thread.cpython-310.pyc,,
|
| 12 |
+
anyio/__pycache__/lowlevel.cpython-310.pyc,,
|
| 13 |
+
anyio/__pycache__/pytest_plugin.cpython-310.pyc,,
|
| 14 |
+
anyio/__pycache__/to_process.cpython-310.pyc,,
|
| 15 |
+
anyio/__pycache__/to_thread.cpython-310.pyc,,
|
| 16 |
+
anyio/_backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 17 |
+
anyio/_backends/__pycache__/__init__.cpython-310.pyc,,
|
| 18 |
+
anyio/_backends/__pycache__/_asyncio.cpython-310.pyc,,
|
| 19 |
+
anyio/_backends/__pycache__/_trio.cpython-310.pyc,,
|
| 20 |
+
anyio/_backends/_asyncio.py,sha256=i5Qe4IBdiWRlww0qIUAVsF-K0z30bgZakuMePpNbdro,94051
|
| 21 |
+
anyio/_backends/_trio.py,sha256=7oGxbqeveiesGm2pAnCRBydqy-Gbistn_xfsmKhSLLg,40371
|
| 22 |
+
anyio/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 23 |
+
anyio/_core/__pycache__/__init__.cpython-310.pyc,,
|
| 24 |
+
anyio/_core/__pycache__/_asyncio_selector_thread.cpython-310.pyc,,
|
| 25 |
+
anyio/_core/__pycache__/_eventloop.cpython-310.pyc,,
|
| 26 |
+
anyio/_core/__pycache__/_exceptions.cpython-310.pyc,,
|
| 27 |
+
anyio/_core/__pycache__/_fileio.cpython-310.pyc,,
|
| 28 |
+
anyio/_core/__pycache__/_resources.cpython-310.pyc,,
|
| 29 |
+
anyio/_core/__pycache__/_signals.cpython-310.pyc,,
|
| 30 |
+
anyio/_core/__pycache__/_sockets.cpython-310.pyc,,
|
| 31 |
+
anyio/_core/__pycache__/_streams.cpython-310.pyc,,
|
| 32 |
+
anyio/_core/__pycache__/_subprocesses.cpython-310.pyc,,
|
| 33 |
+
anyio/_core/__pycache__/_synchronization.cpython-310.pyc,,
|
| 34 |
+
anyio/_core/__pycache__/_tasks.cpython-310.pyc,,
|
| 35 |
+
anyio/_core/__pycache__/_testing.cpython-310.pyc,,
|
| 36 |
+
anyio/_core/__pycache__/_typedattr.cpython-310.pyc,,
|
| 37 |
+
anyio/_core/_asyncio_selector_thread.py,sha256=vTdZBWaxRgVcgUaRb5uBwQ_VGgY3qPKF7l91IJ5Mqzo,4773
|
| 38 |
+
anyio/_core/_eventloop.py,sha256=t_tAwBFPjF8jrZGjlJ6bbYy6KA3bjsbZxV9mvh9t1i0,4695
|
| 39 |
+
anyio/_core/_exceptions.py,sha256=bKPr2QbkYG7nIb425L5JePUie9bGc9XfkY0y4JKWvFM,2488
|
| 40 |
+
anyio/_core/_fileio.py,sha256=DqnG_zvQFMqiIFaUeDRC1Ts3LT0FWHkWtGgm-684hvQ,20957
|
| 41 |
+
anyio/_core/_resources.py,sha256=NbmU5O5UX3xEyACnkmYX28Fmwdl-f-ny0tHym26e0w0,435
|
| 42 |
+
anyio/_core/_signals.py,sha256=vulT1M1xdLYtAR-eY5TamIgaf1WTlOwOrMGwswlTTr8,905
|
| 43 |
+
anyio/_core/_sockets.py,sha256=vQ5GnSDLHjEhHhV2yvsdiPs5wmPxxb1kRsv3RM5lbQk,26951
|
| 44 |
+
anyio/_core/_streams.py,sha256=OnaKgoDD-FcMSwLvkoAUGP51sG2ZdRvMpxt9q2w1gYA,1804
|
| 45 |
+
anyio/_core/_subprocesses.py,sha256=WquR6sHrnaZofaeqnL8U4Yv___msVW_WqivleLHK4zI,7760
|
| 46 |
+
anyio/_core/_synchronization.py,sha256=tct5FJFdgYjiEMtUeg5NGG15tf-2Qd7VaWuSgzS5dIU,20347
|
| 47 |
+
anyio/_core/_tasks.py,sha256=pvVEX2Fw159sf0ypAPerukKsZgRRwvFFedVW52nR2Vk,4764
|
| 48 |
+
anyio/_core/_testing.py,sha256=YUGwA5cgFFbUTv4WFd7cv_BSVr4ryTtPp8owQA3JdWE,2118
|
| 49 |
+
anyio/_core/_typedattr.py,sha256=P4ozZikn3-DbpoYcvyghS_FOYAgbmUxeoU8-L_07pZM,2508
|
| 50 |
+
anyio/abc/__init__.py,sha256=c2OQbTCS_fQowviMXanLPh8m29ccwkXmpDr7uyNZYOo,2652
|
| 51 |
+
anyio/abc/__pycache__/__init__.cpython-310.pyc,,
|
| 52 |
+
anyio/abc/__pycache__/_eventloop.cpython-310.pyc,,
|
| 53 |
+
anyio/abc/__pycache__/_resources.cpython-310.pyc,,
|
| 54 |
+
anyio/abc/__pycache__/_sockets.cpython-310.pyc,,
|
| 55 |
+
anyio/abc/__pycache__/_streams.cpython-310.pyc,,
|
| 56 |
+
anyio/abc/__pycache__/_subprocesses.cpython-310.pyc,,
|
| 57 |
+
anyio/abc/__pycache__/_tasks.cpython-310.pyc,,
|
| 58 |
+
anyio/abc/__pycache__/_testing.cpython-310.pyc,,
|
| 59 |
+
anyio/abc/_eventloop.py,sha256=Wd_3C3hLm0ex5z_eHHWGqvLle2OKCSexJSZVnwQNGV4,9658
|
| 60 |
+
anyio/abc/_resources.py,sha256=DrYvkNN1hH6Uvv5_5uKySvDsnknGVDe8FCKfko0VtN8,783
|
| 61 |
+
anyio/abc/_sockets.py,sha256=KhWtJxan8jpBXKwPaFeQzI4iRXdFaOIn0HXtDZnaO7U,6262
|
| 62 |
+
anyio/abc/_streams.py,sha256=GzST5Q2zQmxVzdrAqtbSyHNxkPlIC9AzeZJg_YyPAXw,6598
|
| 63 |
+
anyio/abc/_subprocesses.py,sha256=cumAPJTktOQtw63IqG0lDpyZqu_l1EElvQHMiwJgL08,2067
|
| 64 |
+
anyio/abc/_tasks.py,sha256=yJWbMwowvqjlAX4oJ3l9Is1w-zwynr2lX1Z02AWJqsY,3080
|
| 65 |
+
anyio/abc/_testing.py,sha256=tBJUzkSfOXJw23fe8qSJ03kJlShOYjjaEyFB6k6MYT8,1821
|
| 66 |
+
anyio/from_thread.py,sha256=dbi5TUH45_Sg_jZ8Vv1NJWVohe0WeQ_OaCvXIKveAGg,17478
|
| 67 |
+
anyio/lowlevel.py,sha256=nkgmW--SdxGVp0cmLUYazjkigveRm5HY7-gW8Bpp9oY,4169
|
| 68 |
+
anyio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 69 |
+
anyio/pytest_plugin.py,sha256=vjGhGRHD31OyMgJRFQrMvExhx3Ea8KbyDqYKmiSDdXA,6712
|
| 70 |
+
anyio/streams/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 71 |
+
anyio/streams/__pycache__/__init__.cpython-310.pyc,,
|
| 72 |
+
anyio/streams/__pycache__/buffered.cpython-310.pyc,,
|
| 73 |
+
anyio/streams/__pycache__/file.cpython-310.pyc,,
|
| 74 |
+
anyio/streams/__pycache__/memory.cpython-310.pyc,,
|
| 75 |
+
anyio/streams/__pycache__/stapled.cpython-310.pyc,,
|
| 76 |
+
anyio/streams/__pycache__/text.cpython-310.pyc,,
|
| 77 |
+
anyio/streams/__pycache__/tls.cpython-310.pyc,,
|
| 78 |
+
anyio/streams/buffered.py,sha256=UCldKC168YuLvT7n3HtNPnQ2iWAMSTYQWbZvzLwMwkM,4500
|
| 79 |
+
anyio/streams/file.py,sha256=6uoTNb5KbMoj-6gS3_xrrL8uZN8Q4iIvOS1WtGyFfKw,4383
|
| 80 |
+
anyio/streams/memory.py,sha256=j8AyOExK4-UPaon_Xbhwax25Vqs0DwFg3ZXc-EIiHjY,10550
|
| 81 |
+
anyio/streams/stapled.py,sha256=U09pCrmOw9kkNhe6tKopsm1QIMT1lFTFvtb-A7SIe4k,4302
|
| 82 |
+
anyio/streams/text.py,sha256=6x8w8xlfCZKTUWQoJiMPoMhSSJFUBRKgoBNSBtbd9yg,5094
|
| 83 |
+
anyio/streams/tls.py,sha256=m3AE2LVSpoRHSIwSoSCupiOVL54EvOFoY3CcwTxcZfg,12742
|
| 84 |
+
anyio/to_process.py,sha256=cR4n7TssbbJowE_9cWme49zaeuoBuMzqgZ6cBIs0YIs,9571
|
| 85 |
+
anyio/to_thread.py,sha256=WM2JQ2MbVsd5D5CM08bQiTwzZIvpsGjfH1Fy247KoDQ,2396
|
vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/REQUESTED
ADDED
|
File without changes
|
vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (75.6.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[pytest11]
|
| 2 |
+
anyio = anyio.pytest_plugin
|
vllm/lib/python3.10/site-packages/anyio-4.7.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
anyio
|
vllm/lib/python3.10/site-packages/opencensus/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
vllm/lib/python3.10/site-packages/opencensus/tags/__init__.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from opencensus.common.runtime_context import RuntimeContext
|
| 16 |
+
from opencensus.tags.tag import Tag
|
| 17 |
+
from opencensus.tags.tag_key import TagKey
|
| 18 |
+
from opencensus.tags.tag_map import TagMap
|
| 19 |
+
from opencensus.tags.tag_value import TagValue
|
| 20 |
+
|
| 21 |
+
__all__ = ['Tag', 'TagContext', 'TagKey', 'TagValue', 'TagMap']
|
| 22 |
+
|
| 23 |
+
TagContext = RuntimeContext.register_slot('tag_context', None)
|
vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (550 Bytes). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag.cpython-310.pyc
ADDED
|
Binary file (901 Bytes). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag_key.cpython-310.pyc
ADDED
|
Binary file (935 Bytes). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag_map.cpython-310.pyc
ADDED
|
Binary file (3.31 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/tag_value.cpython-310.pyc
ADDED
|
Binary file (960 Bytes). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/__pycache__/validation.cpython-310.pyc
ADDED
|
Binary file (1.1 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/propagation/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
vllm/lib/python3.10/site-packages/opencensus/tags/propagation/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (177 Bytes). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/propagation/__pycache__/binary_serializer.cpython-310.pyc
ADDED
|
Binary file (2.78 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/tags/propagation/binary_serializer.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
# -*- coding: utf-8 -*-
|
| 16 |
+
|
| 17 |
+
import six
|
| 18 |
+
|
| 19 |
+
import logging
|
| 20 |
+
|
| 21 |
+
from google.protobuf.internal.encoder import _VarintBytes
|
| 22 |
+
|
| 23 |
+
from opencensus.tags import tag_map as tag_map_module
|
| 24 |
+
|
| 25 |
+
# Used for decoding hex bytes to hex string.
|
| 26 |
+
UTF8 = 'utf-8'
|
| 27 |
+
|
| 28 |
+
VERSION_ID = 0
|
| 29 |
+
TAG_FIELD_ID = 0
|
| 30 |
+
TAG_MAP_SERIALIZED_SIZE_LIMIT = 8192
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class BinarySerializer(object):
|
| 34 |
+
def from_byte_array(self, binary):
|
| 35 |
+
if len(binary) <= 0:
|
| 36 |
+
logging.warning("Input byte[] cannot be empty/")
|
| 37 |
+
return tag_map_module.TagMap()
|
| 38 |
+
else:
|
| 39 |
+
buffer = memoryview(binary)
|
| 40 |
+
version_id = buffer[0]
|
| 41 |
+
if six.PY2:
|
| 42 |
+
version_id = ord(version_id)
|
| 43 |
+
if version_id != VERSION_ID:
|
| 44 |
+
raise ValueError("Invalid version id.")
|
| 45 |
+
return self._parse_tags(buffer)
|
| 46 |
+
|
| 47 |
+
def to_byte_array(self, tag_context):
|
| 48 |
+
encoded_bytes = b''
|
| 49 |
+
encoded_bytes += _VarintBytes(VERSION_ID)
|
| 50 |
+
total_chars = 0
|
| 51 |
+
for tag in tag_context:
|
| 52 |
+
tag_key, tag_value = tag
|
| 53 |
+
total_chars += len(tag_key)
|
| 54 |
+
total_chars += len(tag_value)
|
| 55 |
+
encoded_bytes = self._encode_tag(
|
| 56 |
+
tag_key, tag_value, encoded_bytes)
|
| 57 |
+
if total_chars <= TAG_MAP_SERIALIZED_SIZE_LIMIT:
|
| 58 |
+
return encoded_bytes
|
| 59 |
+
else: # pragma: NO COVER
|
| 60 |
+
logging.warning("Size of the tag context exceeds the maximum size")
|
| 61 |
+
|
| 62 |
+
def _parse_tags(self, buffer):
|
| 63 |
+
tag_context = tag_map_module.TagMap()
|
| 64 |
+
limit = len(buffer)
|
| 65 |
+
total_chars = 0
|
| 66 |
+
i = 1
|
| 67 |
+
while i < limit:
|
| 68 |
+
field_id = buffer[i] if six.PY3 else ord(buffer[i])
|
| 69 |
+
if field_id == TAG_FIELD_ID:
|
| 70 |
+
i += 1
|
| 71 |
+
key = self._decode_string(buffer, i)
|
| 72 |
+
i += len(key)
|
| 73 |
+
total_chars += len(key)
|
| 74 |
+
i += 1
|
| 75 |
+
val = self._decode_string(buffer, i)
|
| 76 |
+
i += len(val)
|
| 77 |
+
total_chars += len(val)
|
| 78 |
+
i += 1
|
| 79 |
+
if total_chars > \
|
| 80 |
+
TAG_MAP_SERIALIZED_SIZE_LIMIT: # pragma: NO COVER
|
| 81 |
+
logging.warning("Size of the tag context exceeds maximum")
|
| 82 |
+
break
|
| 83 |
+
else:
|
| 84 |
+
tag_context.insert(str(key), str(val))
|
| 85 |
+
else:
|
| 86 |
+
break
|
| 87 |
+
return tag_context
|
| 88 |
+
|
| 89 |
+
def _encode_tag(self, tag_key, tag_value, encoded_bytes):
|
| 90 |
+
encoded_bytes += _VarintBytes(TAG_FIELD_ID)
|
| 91 |
+
encoded_bytes = self._encode_string(tag_key, encoded_bytes)
|
| 92 |
+
encoded_bytes = self._encode_string(tag_value, encoded_bytes)
|
| 93 |
+
return encoded_bytes
|
| 94 |
+
|
| 95 |
+
def _encode_string(self, input_str, encoded_bytes):
|
| 96 |
+
encoded_bytes += _VarintBytes(len(input_str))
|
| 97 |
+
encoded_bytes += input_str.encode(UTF8)
|
| 98 |
+
return encoded_bytes
|
| 99 |
+
|
| 100 |
+
def _decode_string(self, buffer, pos):
|
| 101 |
+
length = buffer[pos] if six.PY3 else ord(buffer[pos])
|
| 102 |
+
builder = ""
|
| 103 |
+
i = 1
|
| 104 |
+
while i <= length:
|
| 105 |
+
bytes_to_decode = buffer[pos + i] if six.PY3 \
|
| 106 |
+
else ord(buffer[pos + i])
|
| 107 |
+
builder += _VarintBytes(bytes_to_decode).decode()
|
| 108 |
+
i += 1
|
| 109 |
+
return builder
|
vllm/lib/python3.10/site-packages/opencensus/trace/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from opencensus.trace.span import Span
|
| 16 |
+
|
| 17 |
+
__all__ = ['Span']
|
vllm/lib/python3.10/site-packages/opencensus/trace/attributes.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
import six
|
| 15 |
+
|
| 16 |
+
from opencensus.common import utils
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def _format_attribute_value(value):
|
| 20 |
+
if isinstance(value, bool):
|
| 21 |
+
value_type = 'bool_value'
|
| 22 |
+
elif isinstance(value, int):
|
| 23 |
+
value_type = 'int_value'
|
| 24 |
+
elif isinstance(value, six.string_types):
|
| 25 |
+
value_type = 'string_value'
|
| 26 |
+
value = utils.get_truncatable_str(value)
|
| 27 |
+
elif isinstance(value, float):
|
| 28 |
+
value_type = 'double_value'
|
| 29 |
+
else:
|
| 30 |
+
return None
|
| 31 |
+
|
| 32 |
+
return {value_type: value}
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class Attributes(object):
|
| 36 |
+
"""A set of attributes, each in the format [KEY]:[VALUE].
|
| 37 |
+
|
| 38 |
+
:type attributes: dict
|
| 39 |
+
:param attributes: The set of attributes. Each attribute's key can be up
|
| 40 |
+
to 128 bytes long. The value can be a string up to 256
|
| 41 |
+
bytes, an integer, a floating-point number, or the
|
| 42 |
+
Boolean values true and false.
|
| 43 |
+
"""
|
| 44 |
+
def __init__(self, attributes=None):
|
| 45 |
+
self.attributes = attributes or {}
|
| 46 |
+
|
| 47 |
+
def set_attribute(self, key, value):
|
| 48 |
+
"""Set a key value pair."""
|
| 49 |
+
self.attributes[key] = value
|
| 50 |
+
|
| 51 |
+
def delete_attribute(self, key):
|
| 52 |
+
"""Delete an attribute given a key if existed."""
|
| 53 |
+
self.attributes.pop(key, None)
|
| 54 |
+
|
| 55 |
+
def get_attribute(self, key):
|
| 56 |
+
"""Get a attribute value."""
|
| 57 |
+
return self.attributes.get(key, None)
|
| 58 |
+
|
| 59 |
+
def format_attributes_json(self):
|
| 60 |
+
"""Convert the Attributes object to json format."""
|
| 61 |
+
attributes_json = {}
|
| 62 |
+
|
| 63 |
+
for key, value in self.attributes.items():
|
| 64 |
+
key = utils.check_str_length(key)[0]
|
| 65 |
+
value = _format_attribute_value(value)
|
| 66 |
+
|
| 67 |
+
if value is not None:
|
| 68 |
+
attributes_json[key] = value
|
| 69 |
+
|
| 70 |
+
result = {
|
| 71 |
+
'attributeMap': attributes_json
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
return result
|
vllm/lib/python3.10/site-packages/opencensus/trace/base_exporter.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016-17, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""Module containing base class for exporters."""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class Exporter(object):
|
| 19 |
+
"""Base class for opencensus trace request exporters.
|
| 20 |
+
|
| 21 |
+
Subclasses of :class:`Exporter` must override :meth:`export`.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
def emit(self, span_datas):
|
| 25 |
+
"""
|
| 26 |
+
:type span_datas: list of :class:
|
| 27 |
+
`~opencensus.trace.span_data.SpanData`
|
| 28 |
+
:param list of opencensus.trace.span_data.SpanData span_datas:
|
| 29 |
+
SpanData tuples to emit
|
| 30 |
+
"""
|
| 31 |
+
raise NotImplementedError
|
| 32 |
+
|
| 33 |
+
def export(self, span_datas):
|
| 34 |
+
"""Export the trace. Send trace to transport, and transport will call
|
| 35 |
+
exporter.emit() to actually send the trace to the specified tracing
|
| 36 |
+
backend.
|
| 37 |
+
|
| 38 |
+
:type span_datas: list of :class:
|
| 39 |
+
`~opencensus.trace.span_data.SpanData`
|
| 40 |
+
:param list of opencensus.trace.span_data.SpanData span_datas:
|
| 41 |
+
SpanData tuples to export
|
| 42 |
+
"""
|
| 43 |
+
raise NotImplementedError
|
vllm/lib/python3.10/site-packages/opencensus/trace/base_span.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""Module containing base class for Span."""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class BaseSpan(object):
|
| 19 |
+
"""Base class for Opencensus spans.
|
| 20 |
+
Subclasses of :class:`BaseSpan` must implement the below methods.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
@staticmethod
|
| 24 |
+
def on_create(callback):
|
| 25 |
+
raise NotImplementedError
|
| 26 |
+
|
| 27 |
+
@property
|
| 28 |
+
def children(self):
|
| 29 |
+
"""The child spans of the current span."""
|
| 30 |
+
raise NotImplementedError
|
| 31 |
+
|
| 32 |
+
def span(self, name='child_span'):
|
| 33 |
+
"""Create a child span for the current span and append it to the child
|
| 34 |
+
spans list.
|
| 35 |
+
|
| 36 |
+
:type name: str
|
| 37 |
+
:param name: (Optional) The name of the child span.
|
| 38 |
+
|
| 39 |
+
:rtype: :class: `~opencensus.trace.span.Span`
|
| 40 |
+
:returns: A child Span to be added to the current span.
|
| 41 |
+
"""
|
| 42 |
+
raise NotImplementedError
|
| 43 |
+
|
| 44 |
+
def add_attribute(self, attribute_key, attribute_value):
|
| 45 |
+
"""Add attribute to span.
|
| 46 |
+
|
| 47 |
+
:type attribute_key: str
|
| 48 |
+
:param attribute_key: Attribute key.
|
| 49 |
+
|
| 50 |
+
:type attribute_value:str
|
| 51 |
+
:param attribute_value: Attribute value.
|
| 52 |
+
"""
|
| 53 |
+
raise NotImplementedError
|
| 54 |
+
|
| 55 |
+
def add_annotation(self, description, **attrs):
|
| 56 |
+
"""Add an annotation to span.
|
| 57 |
+
|
| 58 |
+
:type description: str
|
| 59 |
+
:param description: A user-supplied message describing the event.
|
| 60 |
+
The maximum length for the description is 256 bytes.
|
| 61 |
+
|
| 62 |
+
:type attrs: kwargs
|
| 63 |
+
:param attrs: keyworded arguments e.g. failed=True, name='Caching'
|
| 64 |
+
"""
|
| 65 |
+
raise NotImplementedError
|
| 66 |
+
|
| 67 |
+
def add_message_event(self, message_event):
|
| 68 |
+
"""Add a message event to this span.
|
| 69 |
+
|
| 70 |
+
:type message_event: :class:`opencensus.trace.time_event.MessageEvent`
|
| 71 |
+
:param message_event: The message event to attach to this span.
|
| 72 |
+
"""
|
| 73 |
+
raise NotImplementedError
|
| 74 |
+
|
| 75 |
+
def add_link(self, link):
|
| 76 |
+
"""Add a Link.
|
| 77 |
+
|
| 78 |
+
:type link: :class: `~opencensus.trace.link.Link`
|
| 79 |
+
:param link: A Link object.
|
| 80 |
+
"""
|
| 81 |
+
raise NotImplementedError
|
| 82 |
+
|
| 83 |
+
def set_status(self, status):
|
| 84 |
+
"""Sets span status.
|
| 85 |
+
|
| 86 |
+
:type code: :class: `~opencensus.trace.status.Status`
|
| 87 |
+
:param code: A Status object.
|
| 88 |
+
"""
|
| 89 |
+
raise NotImplementedError
|
| 90 |
+
|
| 91 |
+
def start(self):
|
| 92 |
+
"""Set the start time for a span."""
|
| 93 |
+
raise NotImplementedError
|
| 94 |
+
|
| 95 |
+
def finish(self):
|
| 96 |
+
"""Set the end time for a span."""
|
| 97 |
+
raise NotImplementedError
|
| 98 |
+
|
| 99 |
+
def __iter__(self):
|
| 100 |
+
"""Iterate through the span tree."""
|
| 101 |
+
raise NotImplementedError
|
| 102 |
+
|
| 103 |
+
def __enter__(self):
|
| 104 |
+
"""Start a span."""
|
| 105 |
+
raise NotImplementedError
|
| 106 |
+
|
| 107 |
+
def __exit__(self, exception_type, exception_value, traceback):
|
| 108 |
+
"""Finish a span."""
|
| 109 |
+
raise NotImplementedError
|
vllm/lib/python3.10/site-packages/opencensus/trace/blank_span.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from opencensus.trace import base_span
|
| 16 |
+
from opencensus.trace.span_context import generate_span_id
|
| 17 |
+
from opencensus.trace.tracers import base
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class BlankSpan(base_span.BaseSpan):
|
| 21 |
+
"""A BlankSpan is an individual timed event which forms a node of the trace
|
| 22 |
+
tree. All operations are no-op.
|
| 23 |
+
|
| 24 |
+
:type name: str
|
| 25 |
+
:param name: The name of the span.
|
| 26 |
+
|
| 27 |
+
:type parent_span: :class:`~opencensus.trace.blank_span.BlankSpan`
|
| 28 |
+
:param parent_span: (Optional) Parent span.
|
| 29 |
+
|
| 30 |
+
:type status: :class: `~opencensus.trace.status.Status`
|
| 31 |
+
:param status: (Optional) An optional final status for this span.
|
| 32 |
+
|
| 33 |
+
:type context_tracer: :class:`~opencensus.trace.tracers.noop_tracer.
|
| 34 |
+
NoopTracer`
|
| 35 |
+
:param context_tracer: The tracer that holds a stack of spans. If this is
|
| 36 |
+
not None, then when exiting a span, use the end_span
|
| 37 |
+
method in the tracer class to finish a span. If no
|
| 38 |
+
tracer is passed in, then just finish the span using
|
| 39 |
+
the finish method in the Span class.
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
def __init__(
|
| 43 |
+
self,
|
| 44 |
+
name=None,
|
| 45 |
+
parent_span=None,
|
| 46 |
+
attributes=None,
|
| 47 |
+
start_time=None,
|
| 48 |
+
end_time=None,
|
| 49 |
+
span_id=None,
|
| 50 |
+
stack_trace=None,
|
| 51 |
+
annotations=None,
|
| 52 |
+
message_events=None,
|
| 53 |
+
links=None,
|
| 54 |
+
status=None,
|
| 55 |
+
same_process_as_parent_span=None,
|
| 56 |
+
context_tracer=None,
|
| 57 |
+
span_kind=None):
|
| 58 |
+
self.name = name
|
| 59 |
+
self.parent_span = parent_span
|
| 60 |
+
self.start_time = start_time
|
| 61 |
+
self.end_time = end_time
|
| 62 |
+
|
| 63 |
+
self.span_id = generate_span_id()
|
| 64 |
+
self.parent_span = base.NullContextManager()
|
| 65 |
+
|
| 66 |
+
self.attributes = {}
|
| 67 |
+
self.stack_trace = stack_trace
|
| 68 |
+
self.annotations = annotations
|
| 69 |
+
self.message_events = message_events
|
| 70 |
+
self.links = []
|
| 71 |
+
self.status = status
|
| 72 |
+
self.same_process_as_parent_span = same_process_as_parent_span
|
| 73 |
+
self._child_spans = []
|
| 74 |
+
self.context_tracer = context_tracer
|
| 75 |
+
self.span_kind = span_kind
|
| 76 |
+
|
| 77 |
+
@staticmethod
|
| 78 |
+
def on_create(callback):
|
| 79 |
+
pass
|
| 80 |
+
|
| 81 |
+
@property
|
| 82 |
+
def children(self):
|
| 83 |
+
"""The child spans of the current BlankSpan."""
|
| 84 |
+
return list()
|
| 85 |
+
|
| 86 |
+
def span(self, name='child_span'):
|
| 87 |
+
"""Create a child span for the current span and append it to the child
|
| 88 |
+
spans list.
|
| 89 |
+
|
| 90 |
+
:type name: str
|
| 91 |
+
:param name: (Optional) The name of the child span.
|
| 92 |
+
|
| 93 |
+
:rtype: :class: `~opencensus.trace.blankspan.BlankSpan`
|
| 94 |
+
:returns: A child Span to be added to the current span.
|
| 95 |
+
"""
|
| 96 |
+
child_span = BlankSpan(name, parent_span=self)
|
| 97 |
+
self._child_spans.append(child_span)
|
| 98 |
+
return child_span
|
| 99 |
+
|
| 100 |
+
def add_attribute(self, attribute_key, attribute_value):
|
| 101 |
+
"""No-op implementation of this method.
|
| 102 |
+
|
| 103 |
+
:type attribute_key: str
|
| 104 |
+
:param attribute_key: Attribute key.
|
| 105 |
+
|
| 106 |
+
:type attribute_value:str
|
| 107 |
+
:param attribute_value: Attribute value.
|
| 108 |
+
"""
|
| 109 |
+
pass
|
| 110 |
+
|
| 111 |
+
def add_annotation(self, description, **attrs):
|
| 112 |
+
"""No-op implementation of this method.
|
| 113 |
+
|
| 114 |
+
:type description: str
|
| 115 |
+
:param description: A user-supplied message describing the event.
|
| 116 |
+
The maximum length for the description is 256 bytes.
|
| 117 |
+
|
| 118 |
+
:type attrs: kwargs
|
| 119 |
+
:param attrs: keyworded arguments e.g. failed=True, name='Caching'
|
| 120 |
+
"""
|
| 121 |
+
pass
|
| 122 |
+
|
| 123 |
+
def add_message_event(self, message_event):
|
| 124 |
+
"""No-op implementation of this method.
|
| 125 |
+
|
| 126 |
+
:type message_event: :class:`opencensus.trace.time_event.MessageEvent`
|
| 127 |
+
:param message_event: The message event to attach to this span.
|
| 128 |
+
"""
|
| 129 |
+
pass
|
| 130 |
+
|
| 131 |
+
def add_link(self, link):
|
| 132 |
+
"""No-op implementation of this method.
|
| 133 |
+
|
| 134 |
+
:type link: :class: `~opencensus.trace.link.Link`
|
| 135 |
+
:param link: A Link object.
|
| 136 |
+
"""
|
| 137 |
+
pass
|
| 138 |
+
|
| 139 |
+
def set_status(self, status):
|
| 140 |
+
"""No-op implementation of this method.
|
| 141 |
+
|
| 142 |
+
:type code: :class: `~opencensus.trace.status.Status`
|
| 143 |
+
:param code: A Status object.
|
| 144 |
+
"""
|
| 145 |
+
pass
|
| 146 |
+
|
| 147 |
+
def start(self):
|
| 148 |
+
"""No-op implementation of this method."""
|
| 149 |
+
pass
|
| 150 |
+
|
| 151 |
+
def finish(self):
|
| 152 |
+
"""No-op implementation of this method."""
|
| 153 |
+
pass
|
| 154 |
+
|
| 155 |
+
def __iter__(self):
|
| 156 |
+
"""Iterate through the span tree."""
|
| 157 |
+
yield self
|
| 158 |
+
|
| 159 |
+
def __enter__(self):
|
| 160 |
+
"""Start a span."""
|
| 161 |
+
return self
|
| 162 |
+
|
| 163 |
+
def __exit__(self, exception_type, exception_value, traceback):
|
| 164 |
+
"""Finish a span."""
|
| 165 |
+
pass
|
vllm/lib/python3.10/site-packages/opencensus/trace/config_integration.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import importlib
|
| 16 |
+
import logging
|
| 17 |
+
|
| 18 |
+
log = logging.getLogger(__name__)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def trace_integrations(integrations, tracer=None):
|
| 22 |
+
"""Enable tracing on the selected integrations.
|
| 23 |
+
:type integrations: list
|
| 24 |
+
:param integrations: The integrations to be traced.
|
| 25 |
+
"""
|
| 26 |
+
integrated = []
|
| 27 |
+
|
| 28 |
+
for item in integrations:
|
| 29 |
+
module_name = 'opencensus.ext.{}.trace'.format(item)
|
| 30 |
+
try:
|
| 31 |
+
module = importlib.import_module(module_name)
|
| 32 |
+
module.trace_integration(tracer=tracer)
|
| 33 |
+
integrated.append(item)
|
| 34 |
+
except Exception as e:
|
| 35 |
+
log.warning('Failed to integrate module: {}'.format(module_name))
|
| 36 |
+
log.warning('{}'.format(e))
|
| 37 |
+
|
| 38 |
+
return integrated
|
vllm/lib/python3.10/site-packages/opencensus/trace/exceptions_status.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from google.rpc import code_pb2
|
| 16 |
+
|
| 17 |
+
from opencensus.trace.status import Status
|
| 18 |
+
|
| 19 |
+
CANCELLED = Status(code_pb2.CANCELLED)
|
| 20 |
+
INVALID_URL = Status(code_pb2.INVALID_ARGUMENT, message='invalid URL')
|
| 21 |
+
TIMEOUT = Status(code_pb2.DEADLINE_EXCEEDED, message='request timed out')
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def unknown(exception):
|
| 25 |
+
return Status.from_exception(exception)
|
vllm/lib/python3.10/site-packages/opencensus/trace/execution_context.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from opencensus.common.runtime_context import RuntimeContext
|
| 16 |
+
from opencensus.trace.tracers import noop_tracer
|
| 17 |
+
|
| 18 |
+
_attrs_slot = RuntimeContext.register_slot('attrs', lambda: {})
|
| 19 |
+
_current_span_slot = RuntimeContext.register_slot('current_span', None)
|
| 20 |
+
_exporter_slot = RuntimeContext.register_slot('is_exporter', False)
|
| 21 |
+
_tracer_slot = RuntimeContext.register_slot('tracer', noop_tracer.NoopTracer())
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def is_exporter():
|
| 25 |
+
return RuntimeContext.is_exporter
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def set_is_exporter(is_exporter):
|
| 29 |
+
RuntimeContext.is_exporter = is_exporter
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def get_opencensus_tracer():
|
| 33 |
+
"""Get the opencensus tracer from runtime context."""
|
| 34 |
+
return RuntimeContext.tracer
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def set_opencensus_tracer(tracer):
|
| 38 |
+
"""Add the tracer to runtime context."""
|
| 39 |
+
RuntimeContext.tracer = tracer
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def set_opencensus_attr(attr_key, attr_value):
|
| 43 |
+
attrs = RuntimeContext.attrs.copy()
|
| 44 |
+
attrs[attr_key] = attr_value
|
| 45 |
+
RuntimeContext.attrs = attrs
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def set_opencensus_attrs(attrs):
|
| 49 |
+
RuntimeContext.attrs = attrs
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def get_opencensus_attr(attr_key):
|
| 53 |
+
return RuntimeContext.attrs.get(attr_key)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def get_opencensus_attrs():
|
| 57 |
+
return RuntimeContext.attrs
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def get_current_span():
|
| 61 |
+
return RuntimeContext.current_span
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def set_current_span(current_span):
|
| 65 |
+
RuntimeContext.current_span = current_span
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def get_opencensus_full_context():
|
| 69 |
+
attrs = RuntimeContext.attrs
|
| 70 |
+
current_span = RuntimeContext.current_span
|
| 71 |
+
tracer = RuntimeContext.tracer
|
| 72 |
+
return tracer, current_span, attrs
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def set_opencensus_full_context(tracer, span, attrs):
|
| 76 |
+
set_opencensus_tracer(tracer)
|
| 77 |
+
set_current_span(span)
|
| 78 |
+
set_opencensus_attrs(attrs or {})
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def clean():
|
| 82 |
+
_attrs_slot.clear()
|
| 83 |
+
_current_span_slot.clear()
|
| 84 |
+
_tracer_slot.clear()
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def clear():
|
| 88 |
+
"""Clear the context, used in test."""
|
| 89 |
+
clean()
|
vllm/lib/python3.10/site-packages/opencensus/trace/link.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class Type(object):
|
| 17 |
+
"""The relationship of the current span relative to the linked span: child,
|
| 18 |
+
parent, or unspecified.
|
| 19 |
+
|
| 20 |
+
Attributes:
|
| 21 |
+
TYPE_UNSPECIFIED (int): The relationship of the two spans is unknown.
|
| 22 |
+
CHILD_LINKED_SPAN (int): The linked span is a child of the current span.
|
| 23 |
+
PARENT_LINKED_SPAN (int): The linked span is a parent of the current
|
| 24 |
+
span.
|
| 25 |
+
"""
|
| 26 |
+
TYPE_UNSPECIFIED = 0
|
| 27 |
+
CHILD_LINKED_SPAN = 1
|
| 28 |
+
PARENT_LINKED_SPAN = 2
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class Link(object):
|
| 32 |
+
"""A pointer from the current span to another span in the same trace or in
|
| 33 |
+
a different trace. For example, this can be used in batching operations,
|
| 34 |
+
where a single batch handler processes multiple requests from different
|
| 35 |
+
traces or when the handler receives a request from a different project.
|
| 36 |
+
|
| 37 |
+
:type trace_id: str
|
| 38 |
+
:param trace_id: The [TRACE_ID] for a trace within a project.
|
| 39 |
+
|
| 40 |
+
:type span_id: str
|
| 41 |
+
:param span_id: The [SPAN_ID] for a span within a trace.
|
| 42 |
+
|
| 43 |
+
:type type: Enum of :class:`~opencensus.trace.link.Type`
|
| 44 |
+
:param type: The relationship of the current span relative to the linked
|
| 45 |
+
span.
|
| 46 |
+
|
| 47 |
+
:type attributes: :class:`~opencensus.trace.attributes.Attributes`
|
| 48 |
+
:param attributes: A set of attributes on the link. You have have up to 32
|
| 49 |
+
attributes per link.
|
| 50 |
+
"""
|
| 51 |
+
def __init__(self, trace_id, span_id, type=None, attributes=None):
|
| 52 |
+
self.trace_id = trace_id
|
| 53 |
+
self.span_id = span_id
|
| 54 |
+
|
| 55 |
+
if type is None:
|
| 56 |
+
type = Type.TYPE_UNSPECIFIED
|
| 57 |
+
|
| 58 |
+
self.type = type
|
| 59 |
+
self.attributes = attributes
|
| 60 |
+
|
| 61 |
+
def format_link_json(self):
|
| 62 |
+
"""Convert a Link object to json format."""
|
| 63 |
+
link_json = {}
|
| 64 |
+
link_json['trace_id'] = self.trace_id
|
| 65 |
+
link_json['span_id'] = self.span_id
|
| 66 |
+
link_json['type'] = self.type
|
| 67 |
+
|
| 68 |
+
if self.attributes is not None:
|
| 69 |
+
link_json['attributes'] = self.attributes
|
| 70 |
+
|
| 71 |
+
return link_json
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (178 Bytes). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/b3_format.cpython-310.pyc
ADDED
|
Binary file (2.35 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/binary_format.cpython-310.pyc
ADDED
|
Binary file (3.98 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/google_cloud_format.cpython-310.pyc
ADDED
|
Binary file (3.78 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/text_format.cpython-310.pyc
ADDED
|
Binary file (2.44 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/trace_context_http_header_format.cpython-310.pyc
ADDED
|
Binary file (2.71 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/__pycache__/tracestate_string_format.cpython-310.pyc
ADDED
|
Binary file (1.4 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/b3_format.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
from opencensus.trace.span_context import INVALID_SPAN_ID, SpanContext
|
| 17 |
+
from opencensus.trace.trace_options import TraceOptions
|
| 18 |
+
|
| 19 |
+
_STATE_HEADER_KEY = 'b3'
|
| 20 |
+
_TRACE_ID_KEY = 'x-b3-traceid'
|
| 21 |
+
_SPAN_ID_KEY = 'x-b3-spanid'
|
| 22 |
+
_SAMPLED_KEY = 'x-b3-sampled'
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class B3FormatPropagator(object):
|
| 26 |
+
"""Propagator for the B3 HTTP header format.
|
| 27 |
+
|
| 28 |
+
See: https://github.com/openzipkin/b3-propagation
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
def from_headers(self, headers):
|
| 32 |
+
"""Generate a SpanContext object from B3 propagation headers.
|
| 33 |
+
|
| 34 |
+
:type headers: dict
|
| 35 |
+
:param headers: HTTP request headers.
|
| 36 |
+
|
| 37 |
+
:rtype: :class:`~opencensus.trace.span_context.SpanContext`
|
| 38 |
+
:returns: SpanContext generated from B3 propagation headers.
|
| 39 |
+
"""
|
| 40 |
+
if headers is None:
|
| 41 |
+
return SpanContext(from_header=False)
|
| 42 |
+
|
| 43 |
+
trace_id, span_id, sampled = None, None, None
|
| 44 |
+
|
| 45 |
+
state = headers.get(_STATE_HEADER_KEY)
|
| 46 |
+
if state:
|
| 47 |
+
fields = state.split('-', 4)
|
| 48 |
+
|
| 49 |
+
if len(fields) == 1:
|
| 50 |
+
sampled = fields[0]
|
| 51 |
+
elif len(fields) == 2:
|
| 52 |
+
trace_id, span_id = fields
|
| 53 |
+
elif len(fields) == 3:
|
| 54 |
+
trace_id, span_id, sampled = fields
|
| 55 |
+
elif len(fields) == 4:
|
| 56 |
+
trace_id, span_id, sampled, _parent_span_id = fields
|
| 57 |
+
else:
|
| 58 |
+
return SpanContext(from_header=False)
|
| 59 |
+
else:
|
| 60 |
+
trace_id = headers.get(_TRACE_ID_KEY)
|
| 61 |
+
span_id = headers.get(_SPAN_ID_KEY)
|
| 62 |
+
sampled = headers.get(_SAMPLED_KEY)
|
| 63 |
+
|
| 64 |
+
if sampled is not None:
|
| 65 |
+
# The specification encodes an enabled tracing decision as "1".
|
| 66 |
+
# In the wild pre-standard implementations might still send "true".
|
| 67 |
+
# "d" is set in the single header case when debugging is enabled.
|
| 68 |
+
sampled = sampled.lower() in ('1', 'd', 'true')
|
| 69 |
+
else:
|
| 70 |
+
# If there's no incoming sampling decision, it was deferred to us.
|
| 71 |
+
# Even though we set it to False here, we might still sample
|
| 72 |
+
# depending on the tracer configuration.
|
| 73 |
+
sampled = False
|
| 74 |
+
|
| 75 |
+
trace_options = TraceOptions()
|
| 76 |
+
trace_options.set_enabled(sampled)
|
| 77 |
+
|
| 78 |
+
# TraceId and SpanId headers both have to exist
|
| 79 |
+
if not trace_id or not span_id:
|
| 80 |
+
return SpanContext(trace_options=trace_options)
|
| 81 |
+
|
| 82 |
+
# Convert 64-bit trace ids to 128-bit
|
| 83 |
+
if len(trace_id) == 16:
|
| 84 |
+
trace_id = '0'*16 + trace_id
|
| 85 |
+
|
| 86 |
+
span_context = SpanContext(
|
| 87 |
+
trace_id=trace_id,
|
| 88 |
+
span_id=span_id,
|
| 89 |
+
trace_options=trace_options,
|
| 90 |
+
from_header=True
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
return span_context
|
| 94 |
+
|
| 95 |
+
def to_headers(self, span_context):
|
| 96 |
+
"""Convert a SpanContext object to B3 propagation headers.
|
| 97 |
+
|
| 98 |
+
:type span_context:
|
| 99 |
+
:class:`~opencensus.trace.span_context.SpanContext`
|
| 100 |
+
:param span_context: SpanContext object.
|
| 101 |
+
|
| 102 |
+
:rtype: dict
|
| 103 |
+
:returns: B3 propagation headers.
|
| 104 |
+
"""
|
| 105 |
+
|
| 106 |
+
if not span_context.span_id:
|
| 107 |
+
span_id = INVALID_SPAN_ID
|
| 108 |
+
else:
|
| 109 |
+
span_id = span_context.span_id
|
| 110 |
+
|
| 111 |
+
sampled = span_context.trace_options.enabled
|
| 112 |
+
|
| 113 |
+
return {
|
| 114 |
+
_TRACE_ID_KEY: span_context.trace_id,
|
| 115 |
+
_SPAN_ID_KEY: span_id,
|
| 116 |
+
_SAMPLED_KEY: '1' if sampled else '0'
|
| 117 |
+
}
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/binary_format.py
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import binascii
|
| 16 |
+
import collections
|
| 17 |
+
import logging
|
| 18 |
+
import struct
|
| 19 |
+
|
| 20 |
+
from opencensus.trace import span_context as span_context_module
|
| 21 |
+
from opencensus.trace.trace_options import TraceOptions
|
| 22 |
+
|
| 23 |
+
# Used for decoding hex bytes to hex string.
|
| 24 |
+
UTF8 = 'utf-8'
|
| 25 |
+
|
| 26 |
+
VERSION_ID = 0
|
| 27 |
+
TRACE_ID_FIELD_ID = 0
|
| 28 |
+
SPAN_ID_FIELD_ID = 1
|
| 29 |
+
TRACE_OPTION_FIELD_ID = 2
|
| 30 |
+
|
| 31 |
+
# Sizes are number of bytes.
|
| 32 |
+
ID_SIZE = 1
|
| 33 |
+
TRACE_ID_SIZE = 16
|
| 34 |
+
SPAN_ID_SIZE = 8
|
| 35 |
+
TRACE_OPTION_SIZE = 1
|
| 36 |
+
|
| 37 |
+
FORMAT_LENGTH = 4 * ID_SIZE + TRACE_ID_SIZE + SPAN_ID_SIZE + TRACE_OPTION_SIZE
|
| 38 |
+
|
| 39 |
+
# See: https://docs.python.org/3/library/struct.html#format-characters
|
| 40 |
+
BIG_ENDIAN = '>'
|
| 41 |
+
CHAR_ARRAY_FORMAT = 's'
|
| 42 |
+
UNSIGNED_CHAR = 'B'
|
| 43 |
+
UNSIGNED_LONG_LONG = 'Q'
|
| 44 |
+
|
| 45 |
+
# Adding big endian indicator at the beginning to avoid auto padding. This is
|
| 46 |
+
# for ensuring the length of binary is not changed when propagating.
|
| 47 |
+
BINARY_FORMAT = '{big_endian}{version_id}' \
|
| 48 |
+
'{trace_id_field_id}{trace_id}' \
|
| 49 |
+
'{span_id_field_id}{span_id}' \
|
| 50 |
+
'{trace_option_field_id}{trace_option}'\
|
| 51 |
+
.format(
|
| 52 |
+
big_endian=BIG_ENDIAN,
|
| 53 |
+
version_id=UNSIGNED_CHAR,
|
| 54 |
+
trace_id_field_id=UNSIGNED_CHAR,
|
| 55 |
+
trace_id='{}{}'.format(TRACE_ID_SIZE, CHAR_ARRAY_FORMAT),
|
| 56 |
+
span_id_field_id=UNSIGNED_CHAR,
|
| 57 |
+
span_id='{}{}'.format(SPAN_ID_SIZE, CHAR_ARRAY_FORMAT),
|
| 58 |
+
trace_option_field_id=UNSIGNED_CHAR,
|
| 59 |
+
trace_option=UNSIGNED_CHAR)
|
| 60 |
+
|
| 61 |
+
Header = collections.namedtuple(
|
| 62 |
+
'Header',
|
| 63 |
+
'version_id '
|
| 64 |
+
'trace_id_field_id '
|
| 65 |
+
'trace_id '
|
| 66 |
+
'span_id_field_id '
|
| 67 |
+
'span_id '
|
| 68 |
+
'trace_option_field_id '
|
| 69 |
+
'trace_option')
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class BinaryFormatPropagator(object):
|
| 73 |
+
"""This propagator contains the method for serializing and deserializing
|
| 74 |
+
SpanContext using a binary format.
|
| 75 |
+
|
| 76 |
+
See: https://github.com/census-instrumentation/opencensus-specs/blob/
|
| 77 |
+
master/encodings/BinaryEncoding.md
|
| 78 |
+
|
| 79 |
+
Example:
|
| 80 |
+
[SpanContext]
|
| 81 |
+
trace_id: hex string with length 32.
|
| 82 |
+
e.g. 'a0b72ca15c1a4bd18962d0ac59dc90b9'
|
| 83 |
+
span_id: hex string with length 16.
|
| 84 |
+
e.g. 'a0b72ca15c1a4bd1'
|
| 85 |
+
enabled (trace option): bool.
|
| 86 |
+
e.g. True
|
| 87 |
+
[Binary Format]
|
| 88 |
+
trace_id: Bytes with length 16.
|
| 89 |
+
e.g. b'\xa0\xb7,\xa1\\\x1aK\xd1\x89b\xd0\xacY\xdc\x90\xb9'
|
| 90 |
+
span_id: Bytes with length 8.
|
| 91 |
+
e.g. b'\x00\xf0g\xaa\x0b\xa9\x02\xb7'
|
| 92 |
+
trace_option: Byte with length 1.
|
| 93 |
+
e.g. b'\x01'
|
| 94 |
+
"""
|
| 95 |
+
def from_header(self, binary):
|
| 96 |
+
"""Generate a SpanContext object using the trace context header.
|
| 97 |
+
The value of enabled parsed from header is int. Need to convert to
|
| 98 |
+
bool.
|
| 99 |
+
|
| 100 |
+
:type binary: bytes
|
| 101 |
+
:param binary: Trace context header which was extracted from the
|
| 102 |
+
request headers.
|
| 103 |
+
|
| 104 |
+
:rtype: :class:`~opencensus.trace.span_context.SpanContext`
|
| 105 |
+
:returns: SpanContext generated from the trace context header.
|
| 106 |
+
"""
|
| 107 |
+
# If no binary provided, generate a new SpanContext
|
| 108 |
+
if binary is None:
|
| 109 |
+
return span_context_module.SpanContext(from_header=False)
|
| 110 |
+
|
| 111 |
+
# If cannot parse, return a new SpanContext and ignore the context
|
| 112 |
+
# from binary.
|
| 113 |
+
try:
|
| 114 |
+
data = Header._make(struct.unpack(BINARY_FORMAT, binary))
|
| 115 |
+
except struct.error:
|
| 116 |
+
logging.warning(
|
| 117 |
+
'Cannot parse the incoming binary data {}, '
|
| 118 |
+
'wrong format. Total bytes length should be {}.'.format(
|
| 119 |
+
binary, FORMAT_LENGTH
|
| 120 |
+
)
|
| 121 |
+
)
|
| 122 |
+
return span_context_module.SpanContext(from_header=False)
|
| 123 |
+
|
| 124 |
+
# data.trace_id is in bytes with length 16, hexlify it to hex bytes
|
| 125 |
+
# with length 32, then decode it to hex string using utf-8.
|
| 126 |
+
trace_id = str(binascii.hexlify(data.trace_id).decode(UTF8))
|
| 127 |
+
span_id = str(binascii.hexlify(data.span_id).decode(UTF8))
|
| 128 |
+
trace_options = TraceOptions(data.trace_option)
|
| 129 |
+
|
| 130 |
+
span_context = span_context_module.SpanContext(
|
| 131 |
+
trace_id=trace_id,
|
| 132 |
+
span_id=span_id,
|
| 133 |
+
trace_options=trace_options,
|
| 134 |
+
from_header=True)
|
| 135 |
+
|
| 136 |
+
return span_context
|
| 137 |
+
|
| 138 |
+
def to_header(self, span_context):
|
| 139 |
+
"""Convert a SpanContext object to header in binary format.
|
| 140 |
+
|
| 141 |
+
:type span_context:
|
| 142 |
+
:class:`~opencensus.trace.span_context.SpanContext`
|
| 143 |
+
:param span_context: SpanContext object.
|
| 144 |
+
|
| 145 |
+
:rtype: bytes
|
| 146 |
+
:returns: A trace context header in binary format.
|
| 147 |
+
"""
|
| 148 |
+
trace_id = span_context.trace_id
|
| 149 |
+
span_id = span_context.span_id
|
| 150 |
+
trace_options = int(span_context.trace_options.trace_options_byte)
|
| 151 |
+
|
| 152 |
+
# If there is no span_id in this context, set it to 0, which is
|
| 153 |
+
# considered invalid and won't be set as the downstream parent span_id.
|
| 154 |
+
if span_id is None:
|
| 155 |
+
span_id = span_context_module.INVALID_SPAN_ID
|
| 156 |
+
|
| 157 |
+
# Convert trace_id to bytes with length 16, treat span_id as 64 bit
|
| 158 |
+
# integer which is unsigned long long type and convert it to bytes with
|
| 159 |
+
# length 8, trace_option is integer with length 1.
|
| 160 |
+
return struct.pack(
|
| 161 |
+
BINARY_FORMAT,
|
| 162 |
+
VERSION_ID,
|
| 163 |
+
TRACE_ID_FIELD_ID,
|
| 164 |
+
binascii.unhexlify(trace_id),
|
| 165 |
+
SPAN_ID_FIELD_ID,
|
| 166 |
+
binascii.unhexlify(span_id),
|
| 167 |
+
TRACE_OPTION_FIELD_ID,
|
| 168 |
+
trace_options)
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/google_cloud_format.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import logging
|
| 16 |
+
import re
|
| 17 |
+
|
| 18 |
+
from opencensus.trace.span_context import SpanContext
|
| 19 |
+
from opencensus.trace.trace_options import TraceOptions
|
| 20 |
+
|
| 21 |
+
_TRACE_CONTEXT_HEADER_NAME = 'X-Cloud-Trace-Context'
|
| 22 |
+
_TRACE_CONTEXT_HEADER_FORMAT = r'([0-9a-f]{32})(\/([\d]{0,20}))?(;o=(\d+))?'
|
| 23 |
+
_TRACE_CONTEXT_HEADER_RE = re.compile(_TRACE_CONTEXT_HEADER_FORMAT)
|
| 24 |
+
_TRACE_ID_DELIMETER = '/'
|
| 25 |
+
_SPAN_ID_DELIMETER = ';'
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class GoogleCloudFormatPropagator(object):
|
| 29 |
+
"""This class is for converting the trace header in google cloud format
|
| 30 |
+
and generate a SpanContext, or converting a SpanContext to a google cloud
|
| 31 |
+
format header. Later we will add implementation for supporting other
|
| 32 |
+
format like binary format and zipkin, opencensus format.
|
| 33 |
+
"""
|
| 34 |
+
def from_header(self, header):
|
| 35 |
+
"""Generate a SpanContext object using the trace context header.
|
| 36 |
+
The value of enabled parsed from header is int. Need to convert to
|
| 37 |
+
bool.
|
| 38 |
+
|
| 39 |
+
:type header: str
|
| 40 |
+
:param header: Trace context header which was extracted from the HTTP
|
| 41 |
+
request headers.
|
| 42 |
+
|
| 43 |
+
:rtype: :class:`~opencensus.trace.span_context.SpanContext`
|
| 44 |
+
:returns: SpanContext generated from the trace context header.
|
| 45 |
+
"""
|
| 46 |
+
if header is None:
|
| 47 |
+
return SpanContext()
|
| 48 |
+
|
| 49 |
+
try:
|
| 50 |
+
match = re.search(_TRACE_CONTEXT_HEADER_RE, header)
|
| 51 |
+
except TypeError:
|
| 52 |
+
logging.warning(
|
| 53 |
+
'Header should be str, got %s. Cannot parse the header.',
|
| 54 |
+
header.__class__.__name__)
|
| 55 |
+
raise
|
| 56 |
+
|
| 57 |
+
if match:
|
| 58 |
+
trace_id = match.group(1)
|
| 59 |
+
span_id = match.group(3)
|
| 60 |
+
trace_options = match.group(5)
|
| 61 |
+
|
| 62 |
+
if trace_options is None:
|
| 63 |
+
trace_options = 1
|
| 64 |
+
|
| 65 |
+
if span_id:
|
| 66 |
+
span_id = '{:016x}'.format(int(span_id))
|
| 67 |
+
|
| 68 |
+
span_context = SpanContext(
|
| 69 |
+
trace_id=trace_id,
|
| 70 |
+
span_id=span_id,
|
| 71 |
+
trace_options=TraceOptions(trace_options),
|
| 72 |
+
from_header=True)
|
| 73 |
+
return span_context
|
| 74 |
+
else:
|
| 75 |
+
logging.warning(
|
| 76 |
+
'Cannot parse the header %s, generate a new context instead.',
|
| 77 |
+
header)
|
| 78 |
+
return SpanContext()
|
| 79 |
+
|
| 80 |
+
def from_headers(self, headers):
|
| 81 |
+
"""Generate a SpanContext object using the trace context header.
|
| 82 |
+
|
| 83 |
+
:type headers: dict
|
| 84 |
+
:param headers: HTTP request headers.
|
| 85 |
+
|
| 86 |
+
:rtype: :class:`~opencensus.trace.span_context.SpanContext`
|
| 87 |
+
:returns: SpanContext generated from the trace context header.
|
| 88 |
+
"""
|
| 89 |
+
if headers is None:
|
| 90 |
+
return SpanContext()
|
| 91 |
+
header = headers.get(_TRACE_CONTEXT_HEADER_NAME)
|
| 92 |
+
if header is None:
|
| 93 |
+
return SpanContext()
|
| 94 |
+
return self.from_header(header)
|
| 95 |
+
|
| 96 |
+
def to_header(self, span_context):
|
| 97 |
+
"""Convert a SpanContext object to header string.
|
| 98 |
+
|
| 99 |
+
:type span_context:
|
| 100 |
+
:class:`~opencensus.trace.span_context.SpanContext`
|
| 101 |
+
:param span_context: SpanContext object.
|
| 102 |
+
|
| 103 |
+
:rtype: str
|
| 104 |
+
:returns: A trace context header string in google cloud format.
|
| 105 |
+
"""
|
| 106 |
+
trace_id = span_context.trace_id
|
| 107 |
+
span_id = span_context.span_id
|
| 108 |
+
trace_options = span_context.trace_options.trace_options_byte
|
| 109 |
+
|
| 110 |
+
header = '{}/{};o={}'.format(
|
| 111 |
+
trace_id,
|
| 112 |
+
int(span_id, 16),
|
| 113 |
+
int(trace_options))
|
| 114 |
+
return header
|
| 115 |
+
|
| 116 |
+
def to_headers(self, span_context):
|
| 117 |
+
"""Convert a SpanContext object to HTTP request headers.
|
| 118 |
+
|
| 119 |
+
:type span_context:
|
| 120 |
+
:class:`~opencensus.trace.span_context.SpanContext`
|
| 121 |
+
:param span_context: SpanContext object.
|
| 122 |
+
|
| 123 |
+
:rtype: dict
|
| 124 |
+
:returns: Trace context headers in google cloud format.
|
| 125 |
+
"""
|
| 126 |
+
return {
|
| 127 |
+
_TRACE_CONTEXT_HEADER_NAME: self.to_header(span_context),
|
| 128 |
+
}
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/text_format.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from opencensus.trace.span_context import SpanContext
|
| 16 |
+
from opencensus.trace.trace_options import TraceOptions
|
| 17 |
+
|
| 18 |
+
_OPENCENSUS_TRACE_PREFIX = 'opencensus-trace'
|
| 19 |
+
_TRACE_ID_KEY = '{}-traceid'.format(_OPENCENSUS_TRACE_PREFIX)
|
| 20 |
+
_SPAN_ID_KEY = '{}-spanid'.format(_OPENCENSUS_TRACE_PREFIX)
|
| 21 |
+
_TRACE_OPTIONS_KEY = '{}-traceoptions'.format(_OPENCENSUS_TRACE_PREFIX)
|
| 22 |
+
|
| 23 |
+
DEFAULT_TRACE_OPTIONS = '1'
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class TextFormatPropagator(object):
|
| 27 |
+
"""This class provides the basic utilities for extracting the trace
|
| 28 |
+
information from a carrier which is a dict to form a SpanContext. And
|
| 29 |
+
generating a dict using the provided SpanContext.
|
| 30 |
+
"""
|
| 31 |
+
def from_carrier(self, carrier):
|
| 32 |
+
"""Generate a SpanContext object using the information in the carrier.
|
| 33 |
+
|
| 34 |
+
:type carrier: dict
|
| 35 |
+
:param carrier: The carrier which has the trace_id, span_id, options
|
| 36 |
+
information for creating a SpanContext.
|
| 37 |
+
|
| 38 |
+
:rtype: :class:`~opencensus.trace.span_context.SpanContext`
|
| 39 |
+
:returns: SpanContext generated from the carrier.
|
| 40 |
+
"""
|
| 41 |
+
trace_id = None
|
| 42 |
+
span_id = None
|
| 43 |
+
trace_options = None
|
| 44 |
+
|
| 45 |
+
for key in carrier:
|
| 46 |
+
key = key.lower()
|
| 47 |
+
if key == _TRACE_ID_KEY:
|
| 48 |
+
trace_id = carrier[key]
|
| 49 |
+
if key == _SPAN_ID_KEY:
|
| 50 |
+
span_id = carrier[key]
|
| 51 |
+
if key == _TRACE_OPTIONS_KEY:
|
| 52 |
+
trace_options = bool(carrier[key])
|
| 53 |
+
|
| 54 |
+
if trace_options is None:
|
| 55 |
+
trace_options = DEFAULT_TRACE_OPTIONS
|
| 56 |
+
|
| 57 |
+
return SpanContext(
|
| 58 |
+
trace_id=trace_id,
|
| 59 |
+
span_id=span_id,
|
| 60 |
+
trace_options=TraceOptions(trace_options),
|
| 61 |
+
from_header=True)
|
| 62 |
+
|
| 63 |
+
def to_carrier(self, span_context, carrier):
|
| 64 |
+
"""Inject the SpanContext fields to carrier dict.
|
| 65 |
+
|
| 66 |
+
:type span_context:
|
| 67 |
+
:class:`~opencensus.trace.span_context.SpanContext`
|
| 68 |
+
:param span_context: SpanContext object.
|
| 69 |
+
|
| 70 |
+
:type carrier: dict
|
| 71 |
+
:param carrier: The carrier which holds the trace_id, span_id, options
|
| 72 |
+
information from a SpanContext.
|
| 73 |
+
|
| 74 |
+
:rtype: dict
|
| 75 |
+
:returns: The carrier which holds the span context information.
|
| 76 |
+
"""
|
| 77 |
+
carrier[_TRACE_ID_KEY] = str(span_context.trace_id)
|
| 78 |
+
|
| 79 |
+
if span_context.span_id is not None:
|
| 80 |
+
carrier[_SPAN_ID_KEY] = str(span_context.span_id)
|
| 81 |
+
|
| 82 |
+
carrier[_TRACE_OPTIONS_KEY] = str(
|
| 83 |
+
span_context.trace_options.trace_options_byte)
|
| 84 |
+
|
| 85 |
+
return carrier
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/trace_context_http_header_format.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import re
|
| 16 |
+
|
| 17 |
+
from opencensus.trace.propagation.tracestate_string_format import (
|
| 18 |
+
TracestateStringFormatter,
|
| 19 |
+
)
|
| 20 |
+
from opencensus.trace.span_context import SpanContext
|
| 21 |
+
from opencensus.trace.trace_options import TraceOptions
|
| 22 |
+
|
| 23 |
+
_TRACEPARENT_HEADER_NAME = 'traceparent'
|
| 24 |
+
_TRACESTATE_HEADER_NAME = 'tracestate'
|
| 25 |
+
_TRACEPARENT_HEADER_FORMAT = \
|
| 26 |
+
'^[ \t]*([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})' + \
|
| 27 |
+
'(-.*)?[ \t]*$'
|
| 28 |
+
_TRACEPARENT_HEADER_FORMAT_RE = re.compile(_TRACEPARENT_HEADER_FORMAT)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class TraceContextPropagator(object):
|
| 32 |
+
"""Propagator for processing the trace context HTTP header format."""
|
| 33 |
+
|
| 34 |
+
def from_headers(self, headers):
|
| 35 |
+
"""Generate a SpanContext object using the W3C Distributed Tracing headers.
|
| 36 |
+
|
| 37 |
+
:type headers: dict
|
| 38 |
+
:param headers: HTTP request headers.
|
| 39 |
+
|
| 40 |
+
:rtype: :class:`~opencensus.trace.span_context.SpanContext`
|
| 41 |
+
:returns: SpanContext generated from the trace context header.
|
| 42 |
+
"""
|
| 43 |
+
if headers is None:
|
| 44 |
+
return SpanContext()
|
| 45 |
+
|
| 46 |
+
header = headers.get(_TRACEPARENT_HEADER_NAME)
|
| 47 |
+
if header is None:
|
| 48 |
+
return SpanContext()
|
| 49 |
+
|
| 50 |
+
match = re.search(_TRACEPARENT_HEADER_FORMAT_RE, header)
|
| 51 |
+
if not match:
|
| 52 |
+
return SpanContext()
|
| 53 |
+
|
| 54 |
+
version = match.group(1)
|
| 55 |
+
trace_id = match.group(2)
|
| 56 |
+
span_id = match.group(3)
|
| 57 |
+
trace_options = match.group(4)
|
| 58 |
+
|
| 59 |
+
if trace_id == '0' * 32 or span_id == '0' * 16:
|
| 60 |
+
return SpanContext()
|
| 61 |
+
|
| 62 |
+
if version == '00':
|
| 63 |
+
if match.group(5):
|
| 64 |
+
return SpanContext()
|
| 65 |
+
if version == 'ff':
|
| 66 |
+
return SpanContext()
|
| 67 |
+
|
| 68 |
+
span_context = SpanContext(
|
| 69 |
+
trace_id=trace_id,
|
| 70 |
+
span_id=span_id,
|
| 71 |
+
trace_options=TraceOptions(trace_options),
|
| 72 |
+
from_header=True)
|
| 73 |
+
|
| 74 |
+
header = headers.get(_TRACESTATE_HEADER_NAME)
|
| 75 |
+
if header is None:
|
| 76 |
+
return span_context
|
| 77 |
+
try:
|
| 78 |
+
tracestate = TracestateStringFormatter().from_string(header)
|
| 79 |
+
if tracestate.is_valid():
|
| 80 |
+
span_context.tracestate = \
|
| 81 |
+
TracestateStringFormatter().from_string(header)
|
| 82 |
+
except ValueError:
|
| 83 |
+
pass
|
| 84 |
+
return span_context
|
| 85 |
+
|
| 86 |
+
def to_headers(self, span_context):
|
| 87 |
+
"""Convert a SpanContext object to W3C Distributed Tracing headers,
|
| 88 |
+
using version 0.
|
| 89 |
+
|
| 90 |
+
:type span_context:
|
| 91 |
+
:class:`~opencensus.trace.span_context.SpanContext`
|
| 92 |
+
:param span_context: SpanContext object.
|
| 93 |
+
|
| 94 |
+
:rtype: dict
|
| 95 |
+
:returns: W3C Distributed Tracing headers.
|
| 96 |
+
"""
|
| 97 |
+
trace_id = span_context.trace_id
|
| 98 |
+
span_id = span_context.span_id
|
| 99 |
+
trace_options = span_context.trace_options.enabled
|
| 100 |
+
|
| 101 |
+
# Convert the trace options
|
| 102 |
+
trace_options = '01' if trace_options else '00'
|
| 103 |
+
|
| 104 |
+
headers = {
|
| 105 |
+
_TRACEPARENT_HEADER_NAME: '00-{}-{}-{}'.format(
|
| 106 |
+
trace_id,
|
| 107 |
+
span_id,
|
| 108 |
+
trace_options
|
| 109 |
+
),
|
| 110 |
+
}
|
| 111 |
+
tracestate = span_context.tracestate
|
| 112 |
+
if tracestate:
|
| 113 |
+
headers[_TRACESTATE_HEADER_NAME] = \
|
| 114 |
+
TracestateStringFormatter().to_string(tracestate)
|
| 115 |
+
return headers
|
vllm/lib/python3.10/site-packages/opencensus/trace/propagation/tracestate_string_format.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import re
|
| 16 |
+
|
| 17 |
+
from opencensus.trace.tracestate import _KEY_FORMAT, _VALUE_FORMAT, Tracestate
|
| 18 |
+
|
| 19 |
+
_DELIMITER_FORMAT = '[ \t]*,[ \t]*'
|
| 20 |
+
_MEMBER_FORMAT = '(%s)(=)(%s)' % (_KEY_FORMAT, _VALUE_FORMAT)
|
| 21 |
+
|
| 22 |
+
_DELIMITER_FORMAT_RE = re.compile(_DELIMITER_FORMAT)
|
| 23 |
+
_MEMBER_FORMAT_RE = re.compile(_MEMBER_FORMAT)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class TracestateStringFormatter(object):
|
| 27 |
+
def from_string(self, string):
|
| 28 |
+
tracestate = Tracestate()
|
| 29 |
+
for member in re.split(_DELIMITER_FORMAT_RE, string):
|
| 30 |
+
match = _MEMBER_FORMAT_RE.match(member)
|
| 31 |
+
if not match:
|
| 32 |
+
raise ValueError('illegal key-value format %r' % (member))
|
| 33 |
+
key, eq, value = match.groups()
|
| 34 |
+
if key in tracestate:
|
| 35 |
+
raise ValueError('conflict key {!r}'.format(key))
|
| 36 |
+
tracestate[key] = value
|
| 37 |
+
return tracestate
|
| 38 |
+
|
| 39 |
+
def to_string(self, tracestate):
|
| 40 |
+
return ','.join(map(
|
| 41 |
+
lambda key: key + '=' + tracestate[key],
|
| 42 |
+
tracestate
|
| 43 |
+
))
|
vllm/lib/python3.10/site-packages/opencensus/trace/samplers/__init__.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
DEFAULT_SAMPLING_RATE = 1e-4
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class Sampler(object):
|
| 20 |
+
"""Base class for opencensus trace request samplers.
|
| 21 |
+
|
| 22 |
+
Subclasses must override :meth:`should_sample`.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
def should_sample(self, span_context):
|
| 26 |
+
"""Whether to sample this request.
|
| 27 |
+
|
| 28 |
+
:type span_context: :class:`opencensus.trace.span_context.SpanContext`
|
| 29 |
+
:param span_context: The span context.
|
| 30 |
+
|
| 31 |
+
:rtype: bool
|
| 32 |
+
:returns: Whether to sample the request according to the context.
|
| 33 |
+
"""
|
| 34 |
+
raise NotImplementedError
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class AlwaysOnSampler(Sampler):
|
| 38 |
+
"""Sampler that samples every request, regardless of trace options."""
|
| 39 |
+
|
| 40 |
+
def should_sample(self, span_context):
|
| 41 |
+
return True
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class AlwaysOffSampler(Sampler):
|
| 45 |
+
"""Sampler that doesn't sample any request, regardless of trace options."""
|
| 46 |
+
|
| 47 |
+
def should_sample(self, span_context):
|
| 48 |
+
return False
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class ProbabilitySampler(Sampler):
|
| 52 |
+
"""Sample a request at a fixed rate.
|
| 53 |
+
|
| 54 |
+
:type rate: float
|
| 55 |
+
:param rate: The rate of sampling.
|
| 56 |
+
"""
|
| 57 |
+
def __init__(self, rate=None):
|
| 58 |
+
if rate is None:
|
| 59 |
+
rate = DEFAULT_SAMPLING_RATE
|
| 60 |
+
|
| 61 |
+
if not 0 <= rate <= 1:
|
| 62 |
+
raise ValueError('Rate must between 0 and 1.')
|
| 63 |
+
|
| 64 |
+
self.rate = rate
|
| 65 |
+
|
| 66 |
+
def should_sample(self, span_context):
|
| 67 |
+
"""Make the sampling decision based on the lower 8 bytes of the trace
|
| 68 |
+
ID. If the value is less than the bound, return True, else False.
|
| 69 |
+
|
| 70 |
+
:type span_context: :class:`opencensus.trace.span_context.SpanContext`
|
| 71 |
+
:param span_context: The span context.
|
| 72 |
+
|
| 73 |
+
:rtype: bool
|
| 74 |
+
:returns: Whether to sample the request according to the context.
|
| 75 |
+
"""
|
| 76 |
+
if span_context.trace_options.get_enabled():
|
| 77 |
+
return True
|
| 78 |
+
|
| 79 |
+
lower_long = get_lower_long_from_trace_id(span_context.trace_id)
|
| 80 |
+
bound = self.rate * 0xffffffffffffffff
|
| 81 |
+
return lower_long <= bound
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def get_lower_long_from_trace_id(trace_id):
|
| 85 |
+
"""Returns the lower 8 bytes of the trace ID as a long value, assuming
|
| 86 |
+
little endian order.
|
| 87 |
+
|
| 88 |
+
:rtype: long
|
| 89 |
+
:returns: Lower 8 bytes of trace ID
|
| 90 |
+
"""
|
| 91 |
+
lower_bytes = trace_id[16:]
|
| 92 |
+
lower_long = int(lower_bytes, 16)
|
| 93 |
+
|
| 94 |
+
return lower_long
|
vllm/lib/python3.10/site-packages/opencensus/trace/span_context.py
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""SpanContext encapsulates the current context within the request's trace."""
|
| 16 |
+
|
| 17 |
+
import six
|
| 18 |
+
|
| 19 |
+
import logging
|
| 20 |
+
import random
|
| 21 |
+
import re
|
| 22 |
+
|
| 23 |
+
from opencensus.trace import trace_options as trace_options_module
|
| 24 |
+
|
| 25 |
+
_INVALID_TRACE_ID = '0' * 32
|
| 26 |
+
INVALID_SPAN_ID = '0' * 16
|
| 27 |
+
|
| 28 |
+
TRACE_ID_PATTERN = re.compile('[0-9a-f]{32}?')
|
| 29 |
+
SPAN_ID_PATTERN = re.compile('[0-9a-f]{16}?')
|
| 30 |
+
|
| 31 |
+
# Default options, don't force sampling
|
| 32 |
+
DEFAULT_OPTIONS = '0'
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class SpanContext(object):
|
| 36 |
+
"""SpanContext includes 3 fields: traceId, spanId, and an trace_options flag
|
| 37 |
+
which indicates whether or not the request is being traced. It contains the
|
| 38 |
+
current context to be propagated to the child spans.
|
| 39 |
+
|
| 40 |
+
:type trace_id: str
|
| 41 |
+
:param trace_id: (Optional) Trace_id is a 32 digits uuid for the trace.
|
| 42 |
+
If not given, will generate one automatically.
|
| 43 |
+
|
| 44 |
+
:type span_id: str
|
| 45 |
+
:param span_id: (Optional) Identifier for the span, unique within a trace.
|
| 46 |
+
|
| 47 |
+
:type trace_options: :class: `~opencensus.trace.trace_options.TraceOptions`
|
| 48 |
+
:param trace_options: (Optional) TraceOptions indicates 8 trace options.
|
| 49 |
+
|
| 50 |
+
:type from_header: bool
|
| 51 |
+
:param from_header: (Optional) Indicates whether the trace context is
|
| 52 |
+
generated from request header.
|
| 53 |
+
"""
|
| 54 |
+
def __init__(
|
| 55 |
+
self,
|
| 56 |
+
trace_id=None,
|
| 57 |
+
span_id=None,
|
| 58 |
+
trace_options=None,
|
| 59 |
+
tracestate=None,
|
| 60 |
+
from_header=False):
|
| 61 |
+
if trace_id is None:
|
| 62 |
+
trace_id = generate_trace_id()
|
| 63 |
+
|
| 64 |
+
if trace_options is None:
|
| 65 |
+
trace_options = trace_options_module.TraceOptions(DEFAULT_OPTIONS)
|
| 66 |
+
|
| 67 |
+
self.from_header = from_header
|
| 68 |
+
self.trace_id = self._check_trace_id(trace_id)
|
| 69 |
+
self.span_id = self._check_span_id(span_id)
|
| 70 |
+
self.trace_options = trace_options
|
| 71 |
+
self.tracestate = tracestate
|
| 72 |
+
|
| 73 |
+
def __repr__(self):
|
| 74 |
+
"""Returns a string form of the SpanContext.
|
| 75 |
+
|
| 76 |
+
:rtype: str
|
| 77 |
+
:returns: String form of the SpanContext.
|
| 78 |
+
"""
|
| 79 |
+
fmt = '{}(trace_id={}, span_id={}, trace_options={}, tracestate={})'
|
| 80 |
+
return fmt.format(
|
| 81 |
+
type(self).__name__,
|
| 82 |
+
self.trace_id,
|
| 83 |
+
self.span_id,
|
| 84 |
+
self.trace_options,
|
| 85 |
+
self.tracestate,
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
def _check_span_id(self, span_id):
|
| 89 |
+
"""Check the format of the span_id to ensure it is 16-character hex
|
| 90 |
+
value representing a 64-bit number. If span_id is invalid, logs a
|
| 91 |
+
warning message and returns None
|
| 92 |
+
|
| 93 |
+
:type span_id: str
|
| 94 |
+
:param span_id: Identifier for the span, unique within a span.
|
| 95 |
+
|
| 96 |
+
:rtype: str
|
| 97 |
+
:returns: Span_id for the current span.
|
| 98 |
+
"""
|
| 99 |
+
if span_id is None:
|
| 100 |
+
return None
|
| 101 |
+
assert isinstance(span_id, six.string_types)
|
| 102 |
+
|
| 103 |
+
if span_id is INVALID_SPAN_ID:
|
| 104 |
+
logging.warning(
|
| 105 |
+
'Span_id %s is invalid (cannot be all zero)', span_id)
|
| 106 |
+
self.from_header = False
|
| 107 |
+
return None
|
| 108 |
+
|
| 109 |
+
match = SPAN_ID_PATTERN.match(span_id)
|
| 110 |
+
|
| 111 |
+
if match:
|
| 112 |
+
return span_id
|
| 113 |
+
else:
|
| 114 |
+
logging.warning(
|
| 115 |
+
'Span_id %s does not the match the '
|
| 116 |
+
'required format', span_id)
|
| 117 |
+
self.from_header = False
|
| 118 |
+
return None
|
| 119 |
+
|
| 120 |
+
def _check_trace_id(self, trace_id):
|
| 121 |
+
"""Check the format of the trace_id to ensure it is 32-character hex
|
| 122 |
+
value representing a 128-bit number. If trace_id is invalid, returns a
|
| 123 |
+
randomly generated trace id
|
| 124 |
+
|
| 125 |
+
:type trace_id: str
|
| 126 |
+
:param trace_id:
|
| 127 |
+
|
| 128 |
+
:rtype: str
|
| 129 |
+
:returns: Trace_id for the current context.
|
| 130 |
+
"""
|
| 131 |
+
assert isinstance(trace_id, six.string_types)
|
| 132 |
+
|
| 133 |
+
if trace_id is _INVALID_TRACE_ID:
|
| 134 |
+
logging.warning(
|
| 135 |
+
'Trace_id %s is invalid (cannot be all zero), '
|
| 136 |
+
'generating a new one.', trace_id)
|
| 137 |
+
self.from_header = False
|
| 138 |
+
return generate_trace_id()
|
| 139 |
+
|
| 140 |
+
match = TRACE_ID_PATTERN.match(trace_id)
|
| 141 |
+
|
| 142 |
+
if match:
|
| 143 |
+
return trace_id
|
| 144 |
+
else:
|
| 145 |
+
logging.warning(
|
| 146 |
+
'Trace_id %s does not the match the required format,'
|
| 147 |
+
'generating a new one instead.', trace_id)
|
| 148 |
+
self.from_header = False
|
| 149 |
+
return generate_trace_id()
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def generate_span_id():
|
| 153 |
+
"""Return the random generated span ID for a span. Must be a 16 character
|
| 154 |
+
hexadecimal encoded string
|
| 155 |
+
|
| 156 |
+
:rtype: str
|
| 157 |
+
:returns: 16 digit randomly generated hex trace id.
|
| 158 |
+
"""
|
| 159 |
+
return '{:016x}'.format(random.getrandbits(64))
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def generate_trace_id():
|
| 163 |
+
"""Generate a random 32 char hex trace_id.
|
| 164 |
+
|
| 165 |
+
:rtype: str
|
| 166 |
+
:returns: 32 digit randomly generated hex trace id.
|
| 167 |
+
"""
|
| 168 |
+
return '{:032x}'.format(random.getrandbits(128))
|
vllm/lib/python3.10/site-packages/opencensus/trace/stack_trace.py
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import hashlib
|
| 16 |
+
import os
|
| 17 |
+
import random
|
| 18 |
+
import traceback
|
| 19 |
+
|
| 20 |
+
from opencensus.common.utils import get_truncatable_str
|
| 21 |
+
|
| 22 |
+
MAX_FRAMES = 128
|
| 23 |
+
|
| 24 |
+
BUILD_ID = os.environ.get('BUILD_ID', 'unknown')
|
| 25 |
+
SOURCE_VERSION = os.environ.get('SOURCE_VERSION', 'unknown')
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class StackFrame(object):
|
| 29 |
+
"""Represents a single stack frame in a stack trace.
|
| 30 |
+
|
| 31 |
+
:type func_name: str
|
| 32 |
+
:param func_name: The fully-qualified name that uniquely identifies the
|
| 33 |
+
function or method that is active in this frame (up to
|
| 34 |
+
1024 bytes).
|
| 35 |
+
|
| 36 |
+
:type original_func_name: str
|
| 37 |
+
:param original_func_name: An un-mangled function name, if functionName is
|
| 38 |
+
mangled. The name can be fully-qualified
|
| 39 |
+
(up to 1024 bytes).
|
| 40 |
+
|
| 41 |
+
:type file_name: str
|
| 42 |
+
:param file_name: The name of the source file where the function call
|
| 43 |
+
appears (up to 256 bytes).
|
| 44 |
+
|
| 45 |
+
:type line_num: int
|
| 46 |
+
:param line_num: The line number in fileName where the function call
|
| 47 |
+
appears.
|
| 48 |
+
|
| 49 |
+
:type col_num: int
|
| 50 |
+
:param col_num: The column number where the function call appears, if
|
| 51 |
+
available. This is important in JavaScript because of its
|
| 52 |
+
anonymous functions.
|
| 53 |
+
|
| 54 |
+
:type load_module: str
|
| 55 |
+
:param load_module: For example: main binary, kernel modules, and dynamic
|
| 56 |
+
libraries such as libc.so, sharedlib.so
|
| 57 |
+
(up to 256 bytes).
|
| 58 |
+
|
| 59 |
+
:type build_id: str
|
| 60 |
+
:param build_id: A unique identifier for the module, usually a hash of its
|
| 61 |
+
contents (up to 128 bytes).
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
:type source_version: str
|
| 65 |
+
:param source_version: The version of the deployed source code
|
| 66 |
+
(up to 128 bytes).
|
| 67 |
+
"""
|
| 68 |
+
def __init__(self,
|
| 69 |
+
func_name,
|
| 70 |
+
original_func_name,
|
| 71 |
+
file_name,
|
| 72 |
+
line_num,
|
| 73 |
+
col_num,
|
| 74 |
+
load_module,
|
| 75 |
+
build_id,
|
| 76 |
+
source_version):
|
| 77 |
+
self.func_name = func_name
|
| 78 |
+
self.original_func_name = original_func_name
|
| 79 |
+
self.file_name = file_name
|
| 80 |
+
self.line_num = line_num
|
| 81 |
+
self.col_num = col_num
|
| 82 |
+
self.load_module = load_module
|
| 83 |
+
self.build_id = build_id
|
| 84 |
+
self.source_version = source_version
|
| 85 |
+
|
| 86 |
+
def format_stack_frame_json(self):
|
| 87 |
+
"""Convert StackFrame object to json format."""
|
| 88 |
+
stack_frame_json = {}
|
| 89 |
+
stack_frame_json['function_name'] = get_truncatable_str(
|
| 90 |
+
self.func_name)
|
| 91 |
+
stack_frame_json['original_function_name'] = get_truncatable_str(
|
| 92 |
+
self.original_func_name)
|
| 93 |
+
stack_frame_json['file_name'] = get_truncatable_str(self.file_name)
|
| 94 |
+
stack_frame_json['line_number'] = self.line_num
|
| 95 |
+
stack_frame_json['column_number'] = self.col_num
|
| 96 |
+
stack_frame_json['load_module'] = {
|
| 97 |
+
'module': get_truncatable_str(self.load_module),
|
| 98 |
+
'build_id': get_truncatable_str(self.build_id),
|
| 99 |
+
}
|
| 100 |
+
stack_frame_json['source_version'] = get_truncatable_str(
|
| 101 |
+
self.source_version)
|
| 102 |
+
|
| 103 |
+
return stack_frame_json
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class StackTrace(object):
|
| 107 |
+
"""A call stack appearing in a trace.
|
| 108 |
+
|
| 109 |
+
:type stack_frames: list
|
| 110 |
+
:param stack_frames: Stack frames in this stack trace. A maximum of 128
|
| 111 |
+
frames are allowed.
|
| 112 |
+
|
| 113 |
+
:type stack_trace_hash_id: str
|
| 114 |
+
:param stack_trace_hash_id: The hash ID is used to conserve network
|
| 115 |
+
bandwidth for duplicate stack traces within a
|
| 116 |
+
single trace.
|
| 117 |
+
"""
|
| 118 |
+
def __init__(self, stack_frames=None, stack_trace_hash_id=None):
|
| 119 |
+
if stack_frames is None:
|
| 120 |
+
stack_frames = []
|
| 121 |
+
if len(stack_frames) > MAX_FRAMES:
|
| 122 |
+
self.dropped_frames_count = len(stack_frames) - MAX_FRAMES
|
| 123 |
+
stack_frames = stack_frames[-MAX_FRAMES:]
|
| 124 |
+
else:
|
| 125 |
+
self.dropped_frames_count = 0
|
| 126 |
+
|
| 127 |
+
if stack_trace_hash_id is None:
|
| 128 |
+
stack_trace_hash_id = generate_hash_id()
|
| 129 |
+
|
| 130 |
+
self.stack_frames = stack_frames
|
| 131 |
+
self.stack_trace_hash_id = stack_trace_hash_id
|
| 132 |
+
|
| 133 |
+
@classmethod
|
| 134 |
+
def from_traceback(cls, tb):
|
| 135 |
+
"""Initializes a StackTrace from a python traceback instance"""
|
| 136 |
+
stack_trace = cls(
|
| 137 |
+
stack_trace_hash_id=generate_hash_id_from_traceback(tb)
|
| 138 |
+
)
|
| 139 |
+
# use the add_stack_frame so that json formatting is applied
|
| 140 |
+
for tb_frame_info in traceback.extract_tb(tb):
|
| 141 |
+
filename, line_num, fn_name, _ = tb_frame_info
|
| 142 |
+
stack_trace.add_stack_frame(
|
| 143 |
+
StackFrame(
|
| 144 |
+
func_name=fn_name,
|
| 145 |
+
original_func_name=fn_name,
|
| 146 |
+
file_name=filename,
|
| 147 |
+
line_num=line_num,
|
| 148 |
+
col_num=0, # I don't think this is available in python
|
| 149 |
+
load_module=filename,
|
| 150 |
+
build_id=BUILD_ID,
|
| 151 |
+
source_version=SOURCE_VERSION
|
| 152 |
+
)
|
| 153 |
+
)
|
| 154 |
+
return stack_trace
|
| 155 |
+
|
| 156 |
+
def add_stack_frame(self, stack_frame):
|
| 157 |
+
"""Add StackFrame to frames list."""
|
| 158 |
+
if len(self.stack_frames) >= MAX_FRAMES:
|
| 159 |
+
self.dropped_frames_count += 1
|
| 160 |
+
else:
|
| 161 |
+
self.stack_frames.append(stack_frame.format_stack_frame_json())
|
| 162 |
+
|
| 163 |
+
def format_stack_trace_json(self):
|
| 164 |
+
"""Convert a StackTrace object to json format."""
|
| 165 |
+
stack_trace_json = {}
|
| 166 |
+
|
| 167 |
+
if self.stack_frames:
|
| 168 |
+
stack_trace_json['stack_frames'] = {
|
| 169 |
+
'frame': self.stack_frames,
|
| 170 |
+
'dropped_frames_count': self.dropped_frames_count
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
stack_trace_json['stack_trace_hash_id'] = self.stack_trace_hash_id
|
| 174 |
+
|
| 175 |
+
return stack_trace_json
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def generate_hash_id():
|
| 179 |
+
"""Generate a hash id."""
|
| 180 |
+
return random.getrandbits(64)
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def generate_hash_id_from_traceback(tb):
|
| 184 |
+
m = hashlib.md5() # nosec
|
| 185 |
+
for tb_line in traceback.format_tb(tb):
|
| 186 |
+
m.update(tb_line.encode('utf-8'))
|
| 187 |
+
# truncate the hash for easier compatibility with StackDriver,
|
| 188 |
+
# should still be unique enough to avoid collisions
|
| 189 |
+
return int(m.hexdigest()[:12], 16)
|
vllm/lib/python3.10/site-packages/opencensus/trace/status.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from google.rpc import code_pb2
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class Status(object):
|
| 19 |
+
"""The Status type defines a logical error model that is suitable for
|
| 20 |
+
different programming environments, including REST APIs and RPC APIs.
|
| 21 |
+
It is used by gRPC.
|
| 22 |
+
|
| 23 |
+
:type code: int
|
| 24 |
+
:param code: An enum value of :class: `~google.rpc.Code`.
|
| 25 |
+
|
| 26 |
+
:type message: str
|
| 27 |
+
:param message: A developer-facing error message, should be in English.
|
| 28 |
+
|
| 29 |
+
:type details: list
|
| 30 |
+
:param details: A list of messages that carry the error details.
|
| 31 |
+
There is a common set of message types for APIs to use.
|
| 32 |
+
e.g. [
|
| 33 |
+
{
|
| 34 |
+
"@type": string,
|
| 35 |
+
field1: ...,
|
| 36 |
+
...
|
| 37 |
+
},
|
| 38 |
+
]
|
| 39 |
+
See: https://cloud.google.com/trace/docs/reference/v2/
|
| 40 |
+
rest/v2/Status#FIELDS.details
|
| 41 |
+
"""
|
| 42 |
+
def __init__(self, code, message=None, details=None):
|
| 43 |
+
self.code = code
|
| 44 |
+
self.message = message
|
| 45 |
+
self.details = details
|
| 46 |
+
|
| 47 |
+
@property
|
| 48 |
+
def canonical_code(self):
|
| 49 |
+
return self.code
|
| 50 |
+
|
| 51 |
+
@property
|
| 52 |
+
def description(self):
|
| 53 |
+
return self.message
|
| 54 |
+
|
| 55 |
+
@property
|
| 56 |
+
def is_ok(self):
|
| 57 |
+
return self.canonical_code == code_pb2.OK
|
| 58 |
+
|
| 59 |
+
def format_status_json(self):
|
| 60 |
+
"""Convert a Status object to json format."""
|
| 61 |
+
status_json = {}
|
| 62 |
+
|
| 63 |
+
status_json['code'] = self.canonical_code
|
| 64 |
+
|
| 65 |
+
if self.description is not None:
|
| 66 |
+
status_json['message'] = self.description
|
| 67 |
+
|
| 68 |
+
if self.details is not None:
|
| 69 |
+
status_json['details'] = self.details
|
| 70 |
+
|
| 71 |
+
return status_json
|
| 72 |
+
|
| 73 |
+
@classmethod
|
| 74 |
+
def from_exception(cls, exc):
|
| 75 |
+
return cls(
|
| 76 |
+
code=code_pb2.UNKNOWN,
|
| 77 |
+
message=str(exc)
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
@classmethod
|
| 81 |
+
def as_ok(cls):
|
| 82 |
+
return cls(
|
| 83 |
+
code=code_pb2.OK,
|
| 84 |
+
)
|
vllm/lib/python3.10/site-packages/opencensus/trace/trace_options.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
import logging
|
| 16 |
+
|
| 17 |
+
# Enabled field is the least significant bit of trace options.
|
| 18 |
+
_ENABLED_BITMASK = 1 << 0
|
| 19 |
+
|
| 20 |
+
# Default trace options
|
| 21 |
+
DEFAULT = '1'
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class TraceOptions(object):
|
| 25 |
+
"""A class that represents global trace options.
|
| 26 |
+
|
| 27 |
+
:type trace_options_byte: str
|
| 28 |
+
:param trace_options_byte: 1 byte bitmap for trace options.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
def __init__(self, trace_options_byte=None):
|
| 32 |
+
if trace_options_byte is None:
|
| 33 |
+
trace_options_byte = DEFAULT
|
| 34 |
+
|
| 35 |
+
self.trace_options_byte = self.check_trace_options(trace_options_byte)
|
| 36 |
+
self.enabled = self.get_enabled()
|
| 37 |
+
|
| 38 |
+
def check_trace_options(self, trace_options_byte):
|
| 39 |
+
trace_options_int = int(trace_options_byte)
|
| 40 |
+
|
| 41 |
+
if trace_options_int < 0 or trace_options_int > 255:
|
| 42 |
+
logging.warning("Trace options invalid, should be 1 byte.")
|
| 43 |
+
trace_options_byte = DEFAULT
|
| 44 |
+
|
| 45 |
+
return trace_options_byte
|
| 46 |
+
|
| 47 |
+
def __repr__(self):
|
| 48 |
+
fmt = '{}(enabled={})'
|
| 49 |
+
return fmt.format(
|
| 50 |
+
type(self).__name__,
|
| 51 |
+
self.get_enabled(),
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
def get_enabled(self):
|
| 55 |
+
"""Get the last bit from the trace options which is the enabled field.
|
| 56 |
+
|
| 57 |
+
:type trace_options: byte
|
| 58 |
+
:param trace_options: 1 byte field which indicates 8 trace options,
|
| 59 |
+
currently only have the enabled option. 1 means
|
| 60 |
+
enabled, 0 means not enabled.
|
| 61 |
+
|
| 62 |
+
:rtype: bool
|
| 63 |
+
:returns: Enabled tracing or not.
|
| 64 |
+
"""
|
| 65 |
+
enabled = bool(int(self.trace_options_byte) & _ENABLED_BITMASK)
|
| 66 |
+
|
| 67 |
+
return enabled
|
| 68 |
+
|
| 69 |
+
def set_enabled(self, enabled):
|
| 70 |
+
"""Update the last bit of the trace options byte str.
|
| 71 |
+
|
| 72 |
+
:type enabled: bool
|
| 73 |
+
:param enabled: Whether enable tracing in this span context or not.
|
| 74 |
+
"""
|
| 75 |
+
enabled_bit = '1' if enabled else '0'
|
| 76 |
+
self.trace_options_byte = str(
|
| 77 |
+
self.trace_options_byte)[:-1] + enabled_bit
|
| 78 |
+
self.enabled = self.get_enabled()
|
vllm/lib/python3.10/site-packages/opencensus/trace/tracer.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
from opencensus.trace import execution_context, print_exporter, samplers
|
| 16 |
+
from opencensus.trace.propagation import trace_context_http_header_format
|
| 17 |
+
from opencensus.trace.span_context import SpanContext
|
| 18 |
+
from opencensus.trace.tracers import context_tracer, noop_tracer
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class Tracer(object):
|
| 22 |
+
"""The Tracer is for tracing a request for web applications.
|
| 23 |
+
|
| 24 |
+
:type span_context: :class:`~opencensus.trace.span_context.SpanContext`
|
| 25 |
+
:param span_context: SpanContext encapsulates the current context within
|
| 26 |
+
the request's trace.
|
| 27 |
+
|
| 28 |
+
:type sampler: :class:`~opencensus.trace.samplers.base.Sampler`
|
| 29 |
+
:param sampler: Instances of Sampler objects. Defaults to
|
| 30 |
+
:class:`.ProbabilitySampler`. Other options include
|
| 31 |
+
:class:`.AlwaysOnSampler` and :class:`.AlwaysOffSampler`.
|
| 32 |
+
|
| 33 |
+
:type exporter: :class:`~opencensus.trace.base_exporter.exporter`
|
| 34 |
+
:param exporter: Instances of exporter objects. Default to
|
| 35 |
+
:class:`.Printexporter`. The rest options are
|
| 36 |
+
:class:`.Fileexporter`, :class:`.Printexporter`,
|
| 37 |
+
:class:`.Loggingexporter`, :class:`.Zipkinexporter`,
|
| 38 |
+
:class:`.GoogleCloudexporter`
|
| 39 |
+
"""
|
| 40 |
+
def __init__(
|
| 41 |
+
self,
|
| 42 |
+
span_context=None,
|
| 43 |
+
sampler=None,
|
| 44 |
+
exporter=None,
|
| 45 |
+
propagator=None):
|
| 46 |
+
if span_context is None:
|
| 47 |
+
span_context = SpanContext()
|
| 48 |
+
|
| 49 |
+
if sampler is None:
|
| 50 |
+
sampler = samplers.ProbabilitySampler()
|
| 51 |
+
|
| 52 |
+
if exporter is None:
|
| 53 |
+
exporter = print_exporter.PrintExporter()
|
| 54 |
+
|
| 55 |
+
if propagator is None:
|
| 56 |
+
propagator = \
|
| 57 |
+
trace_context_http_header_format.TraceContextPropagator()
|
| 58 |
+
|
| 59 |
+
self.span_context = span_context
|
| 60 |
+
self.sampler = sampler
|
| 61 |
+
self.exporter = exporter
|
| 62 |
+
self.propagator = propagator
|
| 63 |
+
self.tracer = self.get_tracer()
|
| 64 |
+
self.store_tracer()
|
| 65 |
+
|
| 66 |
+
def should_sample(self):
|
| 67 |
+
"""Determine whether to sample this request or not.
|
| 68 |
+
If the context enables tracing, return True.
|
| 69 |
+
Else follow the decision of the sampler.
|
| 70 |
+
|
| 71 |
+
:rtype: bool
|
| 72 |
+
:returns: Whether to trace the request or not.
|
| 73 |
+
"""
|
| 74 |
+
return self.sampler.should_sample(self.span_context)
|
| 75 |
+
|
| 76 |
+
def get_tracer(self):
|
| 77 |
+
"""Return a tracer according to the sampling decision."""
|
| 78 |
+
sampled = self.should_sample()
|
| 79 |
+
|
| 80 |
+
if sampled:
|
| 81 |
+
self.span_context.trace_options.set_enabled(True)
|
| 82 |
+
return context_tracer.ContextTracer(
|
| 83 |
+
exporter=self.exporter,
|
| 84 |
+
span_context=self.span_context)
|
| 85 |
+
return noop_tracer.NoopTracer()
|
| 86 |
+
|
| 87 |
+
def store_tracer(self):
|
| 88 |
+
"""Add the current tracer to thread_local"""
|
| 89 |
+
execution_context.set_opencensus_tracer(self)
|
| 90 |
+
|
| 91 |
+
def finish(self):
|
| 92 |
+
"""End all spans."""
|
| 93 |
+
self.tracer.finish()
|
| 94 |
+
|
| 95 |
+
def span(self, name='span'):
|
| 96 |
+
"""Create a new span with the trace using the context information.
|
| 97 |
+
|
| 98 |
+
:type name: str
|
| 99 |
+
:param name: The name of the span.
|
| 100 |
+
|
| 101 |
+
:rtype: :class:`~opencensus.trace.span.Span`
|
| 102 |
+
:returns: The Span object.
|
| 103 |
+
"""
|
| 104 |
+
return self.tracer.span(name)
|
| 105 |
+
|
| 106 |
+
def start_span(self, name='span'):
|
| 107 |
+
return self.tracer.start_span(name)
|
| 108 |
+
|
| 109 |
+
def end_span(self):
|
| 110 |
+
"""End a span. Update the span_id in SpanContext to the current span's
|
| 111 |
+
parent span id; Update the current span; Send the span to exporter.
|
| 112 |
+
"""
|
| 113 |
+
self.tracer.end_span()
|
| 114 |
+
|
| 115 |
+
def current_span(self):
|
| 116 |
+
"""Return the current span."""
|
| 117 |
+
return self.tracer.current_span()
|
| 118 |
+
|
| 119 |
+
def add_attribute_to_current_span(self, attribute_key, attribute_value):
|
| 120 |
+
"""Add attribute to current span.
|
| 121 |
+
|
| 122 |
+
:type attribute_key: str
|
| 123 |
+
:param attribute_key: Attribute key.
|
| 124 |
+
|
| 125 |
+
:type attribute_value:str
|
| 126 |
+
:param attribute_value: Attribute value.
|
| 127 |
+
"""
|
| 128 |
+
self.tracer.add_attribute_to_current_span(
|
| 129 |
+
attribute_key, attribute_value)
|
| 130 |
+
|
| 131 |
+
def trace_decorator(self):
|
| 132 |
+
"""Decorator to trace a function."""
|
| 133 |
+
|
| 134 |
+
def decorator(func):
|
| 135 |
+
|
| 136 |
+
def wrapper(*args, **kwargs):
|
| 137 |
+
self.tracer.start_span(name=func.__name__)
|
| 138 |
+
return_value = func(*args, **kwargs)
|
| 139 |
+
self.tracer.end_span()
|
| 140 |
+
return return_value
|
| 141 |
+
|
| 142 |
+
return wrapper
|
| 143 |
+
|
| 144 |
+
return decorator
|
vllm/lib/python3.10/site-packages/opencensus/trace/tracers/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017, OpenCensus Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
vllm/lib/python3.10/site-packages/opencensus/trace/tracers/__pycache__/context_tracer.cpython-310.pyc
ADDED
|
Binary file (4.94 kB). View file
|
|
|