mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 13:12:39 +08:00
fix missing dep in docs build (#557)
This commit is contained in:
@ -8,6 +8,7 @@ sphinx-autodoc-typehints
|
|||||||
-e "git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions"
|
-e "git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions"
|
||||||
-e "git+https://github.com/open-telemetry/opentelemetry-python-contrib.git#egg=opentelemetry-instrumentation&subdirectory=opentelemetry-instrumentation"
|
-e "git+https://github.com/open-telemetry/opentelemetry-python-contrib.git#egg=opentelemetry-instrumentation&subdirectory=opentelemetry-instrumentation"
|
||||||
-e "git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk"
|
-e "git+https://github.com/open-telemetry/opentelemetry-python.git#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk"
|
||||||
|
-e "git+https://github.com/open-telemetry/opentelemetry-python-contrib.git#egg=opentelemetry-util-http&subdirectory=util/opentelemetry-util-http"
|
||||||
|
|
||||||
# Required by opentelemetry-instrumentation
|
# Required by opentelemetry-instrumentation
|
||||||
fastapi>=0.65.2
|
fastapi>=0.65.2
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import typing
|
import typing
|
||||||
|
|
||||||
import wrapt
|
import wrapt
|
||||||
from aiopg.utils import _ContextManager, _PoolAcquireContextManager
|
from aiopg.utils import ( # pylint: disable=no-name-in-module
|
||||||
|
_ContextManager,
|
||||||
|
_PoolAcquireContextManager,
|
||||||
|
)
|
||||||
|
|
||||||
from opentelemetry.instrumentation.dbapi import (
|
from opentelemetry.instrumentation.dbapi import (
|
||||||
CursorTracer,
|
CursorTracer,
|
||||||
@ -61,7 +64,9 @@ def get_traced_connection_proxy(
|
|||||||
|
|
||||||
def cursor(self, *args, **kwargs):
|
def cursor(self, *args, **kwargs):
|
||||||
coro = self._cursor(*args, **kwargs)
|
coro = self._cursor(*args, **kwargs)
|
||||||
return _ContextManager(coro)
|
return _ContextManager( # pylint: disable=no-value-for-parameter
|
||||||
|
coro
|
||||||
|
)
|
||||||
|
|
||||||
async def _cursor(self, *args, **kwargs):
|
async def _cursor(self, *args, **kwargs):
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
@ -34,7 +34,10 @@ import typing
|
|||||||
|
|
||||||
import aiopg
|
import aiopg
|
||||||
import wrapt
|
import wrapt
|
||||||
from aiopg.utils import _ContextManager, _PoolContextManager
|
from aiopg.utils import ( # pylint: disable=no-name-in-module
|
||||||
|
_ContextManager,
|
||||||
|
_PoolContextManager,
|
||||||
|
)
|
||||||
|
|
||||||
from opentelemetry.instrumentation.aiopg.aiopg_integration import (
|
from opentelemetry.instrumentation.aiopg.aiopg_integration import (
|
||||||
AiopgIntegration,
|
AiopgIntegration,
|
||||||
@ -108,7 +111,7 @@ def wrap_connect(
|
|||||||
version=version,
|
version=version,
|
||||||
tracer_provider=tracer_provider,
|
tracer_provider=tracer_provider,
|
||||||
)
|
)
|
||||||
return _ContextManager(
|
return _ContextManager( # pylint: disable=no-value-for-parameter
|
||||||
db_integration.wrapped_connection(wrapped, args, kwargs)
|
db_integration.wrapped_connection(wrapped, args, kwargs)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,10 @@ from unittest import mock
|
|||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import aiopg
|
import aiopg
|
||||||
from aiopg.utils import _ContextManager, _PoolAcquireContextManager
|
from aiopg.utils import ( # pylint: disable=no-name-in-module
|
||||||
|
_ContextManager,
|
||||||
|
_PoolAcquireContextManager,
|
||||||
|
)
|
||||||
|
|
||||||
import opentelemetry.instrumentation.aiopg
|
import opentelemetry.instrumentation.aiopg
|
||||||
from opentelemetry import trace as trace_api
|
from opentelemetry import trace as trace_api
|
||||||
@ -525,7 +528,7 @@ class MockConnection:
|
|||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
def cursor(self):
|
def cursor(self):
|
||||||
coro = self._cursor()
|
coro = self._cursor()
|
||||||
return _ContextManager(coro)
|
return _ContextManager(coro) # pylint: disable=no-value-for-parameter
|
||||||
|
|
||||||
async def _cursor(self):
|
async def _cursor(self):
|
||||||
return MockCursor()
|
return MockCursor()
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import unittest.mock as mock
|
from unittest import mock
|
||||||
|
|
||||||
import opentelemetry.instrumentation.asgi as otel_asgi
|
import opentelemetry.instrumentation.asgi as otel_asgi
|
||||||
from opentelemetry import trace as trace_api
|
from opentelemetry import trace as trace_api
|
||||||
|
@ -79,6 +79,7 @@ class TestServer(test_server_pb2_grpc.GRPCTestServerServicer):
|
|||||||
|
|
||||||
|
|
||||||
def create_test_server(port):
|
def create_test_server(port):
|
||||||
|
# pylint: disable=consider-using-with
|
||||||
server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
|
server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
|
||||||
|
|
||||||
test_server_pb2_grpc.add_GRPCTestServerServicer_to_server(
|
test_server_pb2_grpc.add_GRPCTestServerServicer_to_server(
|
||||||
|
@ -82,9 +82,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
|
|
||||||
grpc_server_instrumentor = GrpcInstrumentorServer()
|
grpc_server_instrumentor = GrpcInstrumentorServer()
|
||||||
grpc_server_instrumentor.instrument()
|
grpc_server_instrumentor.instrument()
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor, options=(("grpc.so_reuseport", 0),),
|
||||||
options=(("grpc.so_reuseport", 0),),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
@ -134,9 +134,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
grpc_server_instrumentor = GrpcInstrumentorServer()
|
grpc_server_instrumentor = GrpcInstrumentorServer()
|
||||||
grpc_server_instrumentor.instrument()
|
grpc_server_instrumentor.instrument()
|
||||||
grpc_server_instrumentor.uninstrument()
|
grpc_server_instrumentor.uninstrument()
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor, options=(("grpc.so_reuseport", 0),),
|
||||||
options=(("grpc.so_reuseport", 0),),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
@ -160,8 +160,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
# Intercept gRPC calls...
|
# Intercept gRPC calls...
|
||||||
interceptor = server_interceptor()
|
interceptor = server_interceptor()
|
||||||
|
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
@ -227,8 +228,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
interceptor = server_interceptor()
|
interceptor = server_interceptor()
|
||||||
|
|
||||||
# setup the server
|
# setup the server
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
@ -287,9 +289,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
# Intercept gRPC calls...
|
# Intercept gRPC calls...
|
||||||
interceptor = server_interceptor()
|
interceptor = server_interceptor()
|
||||||
|
|
||||||
# setup the server
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
@ -355,9 +357,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
# Intercept gRPC calls...
|
# Intercept gRPC calls...
|
||||||
interceptor = server_interceptor()
|
interceptor = server_interceptor()
|
||||||
|
|
||||||
# setup the server
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
@ -422,8 +424,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
active_span_in_handler = trace.get_current_span()
|
active_span_in_handler = trace.get_current_span()
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
@ -457,8 +460,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
active_spans_in_handler.append(trace.get_current_span())
|
active_spans_in_handler.append(trace.get_current_span())
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
@ -520,8 +524,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
active_spans_in_handler.append(trace.get_current_span())
|
active_spans_in_handler.append(trace.get_current_span())
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=2) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=2),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
@ -584,8 +589,9 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
|||||||
def handler(request, context):
|
def handler(request, context):
|
||||||
context.abort(grpc.StatusCode.FAILED_PRECONDITION, failure_message)
|
context.abort(grpc.StatusCode.FAILED_PRECONDITION, failure_message)
|
||||||
|
|
||||||
|
with futures.ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
server = grpc.server(
|
server = grpc.server(
|
||||||
futures.ThreadPoolExecutor(max_workers=1),
|
executor,
|
||||||
options=(("grpc.so_reuseport", 0),),
|
options=(("grpc.so_reuseport", 0),),
|
||||||
interceptors=[interceptor],
|
interceptors=[interceptor],
|
||||||
)
|
)
|
||||||
|
@ -22,11 +22,10 @@ Usage
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import opentelemetry.instrumentation.requests
|
from opentelemetry.instrumentation.requests import RequestsInstrumentor
|
||||||
|
|
||||||
# You can optionally pass a custom TracerProvider to
|
# You can optionally pass a custom TracerProvider to
|
||||||
# RequestsInstrumentor.instrument()
|
RequestsInstrumentor.instrument()
|
||||||
opentelemetry.instrumentation.requests.RequestsInstrumentor().instrument()
|
|
||||||
response = requests.get(url="https://www.example.org/")
|
response = requests.get(url="https://www.example.org/")
|
||||||
|
|
||||||
API
|
API
|
||||||
|
@ -42,6 +42,7 @@ from .tornado_test_app import (
|
|||||||
|
|
||||||
|
|
||||||
class TornadoTest(AsyncHTTPTestCase, TestBase):
|
class TornadoTest(AsyncHTTPTestCase, TestBase):
|
||||||
|
# pylint:disable=no-self-use
|
||||||
def get_app(self):
|
def get_app(self):
|
||||||
tracer = trace.get_tracer(__name__)
|
tracer = trace.get_tracer(__name__)
|
||||||
app = make_app(tracer)
|
app = make_app(tracer)
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import unittest.mock as mock
|
|
||||||
import wsgiref.util as wsgiref_util
|
import wsgiref.util as wsgiref_util
|
||||||
|
from unittest import mock
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
import opentelemetry.instrumentation.wsgi as otel_wsgi
|
import opentelemetry.instrumentation.wsgi as otel_wsgi
|
||||||
|
@ -26,7 +26,7 @@ https://w3c.github.io/trace-context/#trace-context-http-response-headers-format
|
|||||||
import typing
|
import typing
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
import opentelemetry.trace as trace
|
from opentelemetry import trace
|
||||||
from opentelemetry.context.context import Context
|
from opentelemetry.context.context import Context
|
||||||
from opentelemetry.propagators import textmap
|
from opentelemetry.propagators import textmap
|
||||||
from opentelemetry.trace import format_span_id, format_trace_id
|
from opentelemetry.trace import format_span_id, format_trace_id
|
||||||
|
@ -631,9 +631,9 @@ def update_dependencies(targets, version, packages):
|
|||||||
if str(pkg) == "all":
|
if str(pkg) == "all":
|
||||||
continue
|
continue
|
||||||
print(pkg)
|
print(pkg)
|
||||||
package_name = str(pkg).split("/")[-1]
|
package_name = str(pkg).split("/", maxsplit=1)[-1]
|
||||||
# Windows uses backslashes
|
# Windows uses backslashes
|
||||||
package_name = str(pkg).split("\\")[-1]
|
package_name = str(pkg).split("\\", maxsplit=1)[-1]
|
||||||
print(package_name)
|
print(package_name)
|
||||||
|
|
||||||
update_files(
|
update_files(
|
||||||
|
@ -35,11 +35,10 @@ _prefix = "opentelemetry-instrumentation-"
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
setuppy_tmpl = Template(
|
with open(
|
||||||
open(
|
|
||||||
os.path.join(root_path, _template_dir, _template_name), "r"
|
os.path.join(root_path, _template_dir, _template_name), "r"
|
||||||
).read()
|
) as template:
|
||||||
)
|
setuppy_tmpl = Template(template.read())
|
||||||
base_instrumentation_path = os.path.join(root_path, "instrumentation")
|
base_instrumentation_path = os.path.join(root_path, "instrumentation")
|
||||||
|
|
||||||
for instrumentation in os.listdir(base_instrumentation_path):
|
for instrumentation in os.listdir(base_instrumentation_path):
|
||||||
|
@ -51,7 +51,7 @@ API
|
|||||||
import logging
|
import logging
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
import opentelemetry.trace as trace
|
from opentelemetry import trace
|
||||||
from opentelemetry.context import Context
|
from opentelemetry.context import Context
|
||||||
from opentelemetry.propagators.textmap import (
|
from opentelemetry.propagators.textmap import (
|
||||||
CarrierT,
|
CarrierT,
|
||||||
|
Reference in New Issue
Block a user