MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / assert_http_attributes

Function assert_http_attributes

tests/test_open_telemetry.py:6956–6962  ·  view source on GitHub ↗

Checks that `span` is of a `method` request to `path`, and that its route is `path` with a placeholder for each ID.

(span: ReadableSpan, method: str, path: str)

Source from the content-addressed store, hash-verified

6954
6955
6956def assert_http_attributes(span: ReadableSpan, method: str, path: str) -> None:
6957 """Checks that `span` is of a `method` request to `path`, and that its route is `path` with a placeholder for each ID."""
6958 assert attributes(span)["http.request.method"] == method
6959 assert attributes(span)["url.path"] == path
6960 route = str(attributes(span)["http.route"])
6961 assert re.fullmatch(re.sub(r"\\\{\w+\\\}", "[^/]+", re.escape(route)), path), route
6962 assert route.count("{") == sum(part not in route.split("/") for part in path.split("/")), route
6963
6964
6965# One method of each resource: what calls it, the request it makes, the body of its response, and its span's name and IDs.

Calls 1

attributesFunction · 0.70

Tested by

no test coverage detected