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
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ def _get_span_name(span):
def _get_resource(span):
"""Get resource name for span"""
if "http.method" in span.attributes:
route = span.attributes.get(
"http.route", span.attributes.get("http.path")
)
route = span.attributes.get("http.route")
return (
span.attributes["http.method"] + " " + route
if route
Expand Down
6 changes: 3 additions & 3 deletions ext/opentelemetry-ext-datadog/tests/test_datadog_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def test_export(self):
def test_resources(self):
test_attributes = [
{},
{"http.method": "GET", "http.route": "/foo"},
{"http.method": "GET", "http.path": "/foo"},
{"http.method": "GET", "http.route": "/foo/<int:id>"},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to add a test case with both http.route and http.target (a common scenario) and ensure that the precedence is correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with the conservative approach you suggested, not backing off to http.target, being that it would create a cardinality issue.

{"http.method": "GET", "http.target": "/foo/200"},
]

for index, test in enumerate(test_attributes):
Expand All @@ -235,7 +235,7 @@ def test_resources(self):
self.assertEqual(len(datadog_spans), 3)

actual = [span["resource"] for span in datadog_spans]
expected = ["0", "GET /foo", "GET /foo"]
expected = ["0", "GET /foo/<int:id>", "GET"]

self.assertEqual(actual, expected)

Expand Down