Skip to content
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
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ packages = [
"solarwinds_apm",
"solarwinds_apm.api",
"solarwinds_apm.oboe",
"solarwinds_apm.semconv",
"solarwinds_apm.semconv.trace",
"solarwinds_apm.trace",
]

Expand Down
10 changes: 9 additions & 1 deletion solarwinds_apm/oboe/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from opentelemetry.semconv.attributes.server_attributes import SERVER_ADDRESS
from opentelemetry.semconv.attributes.url_attributes import (
URL_PATH,
URL_QUERY,
URL_SCHEME,
)
from opentelemetry.trace import Link, SpanKind, TraceState, get_current_span
Expand Down Expand Up @@ -83,8 +84,15 @@ def http_span_metadata(kind: SpanKind, attributes: Attributes):
SERVER_ADDRESS, attributes.get(NET_HOST_NAME, "localhost")
)
)
path = str(attributes.get(URL_PATH, attributes.get(HTTP_TARGET, "")))
path = attributes.get(URL_PATH)
query = attributes.get(URL_QUERY)
if path is None and query is None:
path = attributes.get(HTTP_TARGET, "")
path = str(path or "")
query = str(query or "")
url = f"{scheme}://{hostname}{path}"
if query:
url += f"?{query}"
return {
"http": True,
"method": method,
Expand Down
Empty file.
52 changes: 0 additions & 52 deletions solarwinds_apm/semconv/trace/__init__.py

This file was deleted.

30 changes: 30 additions & 0 deletions tests/unit/test_oboe/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from opentelemetry.semconv.attributes.server_attributes import SERVER_ADDRESS
from opentelemetry.semconv.attributes.url_attributes import (
URL_PATH,
URL_QUERY,
URL_SCHEME,
)
from opentelemetry.trace import SpanKind
Expand Down Expand Up @@ -145,6 +146,35 @@ def test_handles_http_server_spans_properly(self):
"url": "https://solarwinds.com",
}

def test_handles_http_server_span_with_query_only(self):
span = {
"kind": SpanKind.SERVER,
"attributes": {
HTTP_REQUEST_METHOD: "GET",
URL_SCHEME: "https",
SERVER_ADDRESS: "solarwinds.com",
URL_QUERY: "page=2",
},
}
output = http_span_metadata(span["kind"], span["attributes"])
assert output["path"] == ""
assert output["url"] == "https://solarwinds.com?page=2"

def test_handles_http_server_span_with_path_and_query(self):
span = {
"kind": SpanKind.SERVER,
"attributes": {
HTTP_REQUEST_METHOD: "GET",
URL_SCHEME: "https",
SERVER_ADDRESS: "solarwinds.com",
URL_PATH: "/search",
URL_QUERY: "page=2",
},
}
output = http_span_metadata(span["kind"], span["attributes"])
assert output["path"] == "/search"
assert output["url"] == "https://solarwinds.com/search?page=2"

def test_handles_legacy_http_server_spans_properly(self):
span = {
"kind": SpanKind.SERVER,
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/test_semconv/__init__.py

This file was deleted.

70 changes: 0 additions & 70 deletions tests/unit/test_semconv/test_trace.py

This file was deleted.

Loading