Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aiohttp instrumentation: Remove span_name from docs #857

Merged
merged 9 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
.. 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:
Expand All @@ -35,8 +32,6 @@ def strip_query_params(url: yarl.URL) -> str:
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()
Expand Down Expand Up @@ -127,21 +122,6 @@ def response_hook(span: Span, params: typing.Union[
]


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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,6 @@ def assert_spans(self, spans):
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,
Expand Down