mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 21:23:55 +08:00
aiohttp instrumentation: Remove span_name
from docs (#857)
This commit is contained in:
@ -51,6 +51,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `opentelemetry-instrumentation-aiohttp-client` aiohttp: Correct url filter input type
|
||||
([#843](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/864))
|
||||
|
||||
- `opentelemetry-instrumentation-aiohttp-client` aiohttp: Remove `span_name` from docs
|
||||
([#857](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/857))
|
||||
|
||||
|
||||
## [1.8.0-0.27b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.8.0-0.27b0) - 2021-12-17
|
||||
|
||||
|
@ -23,10 +23,7 @@ Explicitly instrumenting a single client session:
|
||||
.. code:: python
|
||||
|
||||
import aiohttp
|
||||
from opentelemetry.instrumentation.aiohttp_client import (
|
||||
create_trace_config,
|
||||
url_path_span_name
|
||||
)
|
||||
from opentelemetry.instrumentation.aiohttp_client import create_trace_config
|
||||
import yarl
|
||||
|
||||
def strip_query_params(url: yarl.URL) -> str:
|
||||
@ -35,8 +32,6 @@ Explicitly instrumenting a single client session:
|
||||
async with aiohttp.ClientSession(trace_configs=[create_trace_config(
|
||||
# Remove all query params from the URL attribute on the span.
|
||||
url_filter=strip_query_params,
|
||||
# Use the URL's path as the span name.
|
||||
span_name=url_path_span_name
|
||||
)]) as session:
|
||||
async with session.get(url) as response:
|
||||
await response.text()
|
||||
@ -127,21 +122,6 @@ _ResponseHookT = typing.Optional[
|
||||
]
|
||||
|
||||
|
||||
def url_path_span_name(params: aiohttp.TraceRequestStartParams) -> str:
|
||||
"""Extract a span name from the request URL path.
|
||||
|
||||
A simple callable to extract the path portion of the requested URL
|
||||
for use as the span name.
|
||||
|
||||
:param aiohttp.TraceRequestStartParams params: Parameters describing
|
||||
the traced request.
|
||||
|
||||
:return: The URL path.
|
||||
:rtype: str
|
||||
"""
|
||||
return params.url.path
|
||||
|
||||
|
||||
def create_trace_config(
|
||||
url_filter: _UrlFilterT = None,
|
||||
request_hook: _RequestHookT = None,
|
||||
|
@ -71,20 +71,6 @@ class TestAioHttpIntegration(TestBase):
|
||||
spans,
|
||||
)
|
||||
|
||||
def test_url_path_span_name(self):
|
||||
for url, expected in (
|
||||
(
|
||||
yarl.URL("http://hostname.local:1234/some/path?query=params"),
|
||||
"/some/path",
|
||||
),
|
||||
(yarl.URL("http://hostname.local:1234"), "/"),
|
||||
):
|
||||
with self.subTest(url=url):
|
||||
params = aiohttp.TraceRequestStartParams("METHOD", url, {})
|
||||
actual = aiohttp_client.url_path_span_name(params)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertIsInstance(actual, str)
|
||||
|
||||
@staticmethod
|
||||
def _http_request(
|
||||
trace_config,
|
||||
|
Reference in New Issue
Block a user