-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable node span events system tests (#2539)
* enable node span events system tests
- Loading branch information
1 parent
2084568
commit 61074b3
Showing
2 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -838,7 +838,7 @@ def test_otel_span_extended_reserved_attributes_overrides_analytics_event( | |
@missing_feature(context.library == "php", reason="Not implemented") | ||
@missing_feature(context.library == "java", reason="Not implemented") | ||
@missing_feature(context.library == "ruby", reason="Not implemented") | ||
@missing_feature(context.library == "nodejs", reason="Not implemented") | ||
@missing_feature(context.library < "nodejs@5.17.0", reason="Implemented in v5.17.0 & v4.41.0") | ||
@missing_feature(context.library == "dotnet", reason="Not implemented") | ||
@missing_feature(context.library < "[email protected]", reason="Not implemented") | ||
def test_otel_add_event_meta_serialization(self, test_agent, test_library): | ||
|
@@ -874,7 +874,7 @@ def test_otel_add_event_meta_serialization(self, test_agent, test_library): | |
|
||
event2 = events[1] | ||
assert event2.get("name") == "second_event" | ||
assert event2.get("time_unix_nano") == event2_timestamp_ns | ||
assert event2.get("time_unix_nano") // 10000 == event2_timestamp_ns // 10000 # reduce the precision tested | ||
assert event2["attributes"].get("string_val") == "value" | ||
|
||
event3 = events[2] | ||
|
@@ -891,7 +891,7 @@ def test_otel_add_event_meta_serialization(self, test_agent, test_library): | |
@missing_feature(context.library == "php", reason="Not implemented") | ||
@missing_feature(context.library == "java", reason="Not implemented") | ||
@missing_feature(context.library == "ruby", reason="Not implemented") | ||
@missing_feature(context.library == "nodejs", reason="Not implemented") | ||
@missing_feature(context.library < "nodejs@5.17.0", reason="Implemented in v5.17.0 & v4.41.0") | ||
@missing_feature(context.library < "[email protected]", reason="Not implemented") | ||
def test_otel_record_exception_does_not_set_error(self, test_agent, test_library): | ||
""" | ||
|
@@ -910,7 +910,7 @@ def test_otel_record_exception_does_not_set_error(self, test_agent, test_library | |
@missing_feature(context.library == "php", reason="Not implemented") | ||
@missing_feature(context.library == "java", reason="Not implemented") | ||
@missing_feature(context.library == "ruby", reason="Not implemented") | ||
@missing_feature(context.library == "nodejs", reason="Not implemented") | ||
@missing_feature(context.library < "nodejs@5.17.0", reason="Implemented in v5.17.0 & v4.41.0") | ||
@missing_feature(context.library == "dotnet", reason="Not implemented") | ||
@missing_feature(context.library < "[email protected]", reason="Not implemented") | ||
def test_otel_record_exception_meta_serialization(self, test_agent, test_library): | ||
|
@@ -933,29 +933,64 @@ def test_otel_record_exception_meta_serialization(self, test_agent, test_library | |
|
||
events = json.loads(root_span.get("meta", {}).get("events")) | ||
assert len(events) == 3 | ||
event1 = events[0] | ||
assert ( | ||
event1.get("name").lower() == "exception" or "error" | ||
) # node uses error objects instead of exception objects | ||
assert event1.get("time_unix_nano") > 0 | ||
|
||
event2 = events[1] | ||
assert event2.get("name") == "non_exception_event" | ||
assert event2.get("time_unix_nano") > event1.get("time_unix_nano") | ||
|
||
event3 = events[2] | ||
assert event3.get("name") == "exception" or "error" | ||
assert event3.get("time_unix_nano") > event2.get("time_unix_nano") | ||
|
||
assert root_span["error"] == 1 | ||
assert "error.type" in root_span["meta"] | ||
assert "error.stack" in root_span["meta"] | ||
|
||
@missing_feature(context.library == "golang", reason="Not implemented") | ||
@missing_feature(context.library == "php", reason="Not implemented") | ||
@missing_feature(context.library == "java", reason="Not implemented") | ||
@missing_feature(context.library == "ruby", reason="Not implemented") | ||
@missing_feature(context.library == "nodejs", reason="Otel Node.js API does not support attributes") | ||
@missing_feature(context.library == "dotnet", reason="Not implemented") | ||
@missing_feature(context.library < "[email protected]", reason="Not implemented") | ||
def test_otel_record_exception_attributes_serialization(self, test_agent, test_library): | ||
""" | ||
Tests the Span.RecordException API (requires Span.AddEvent API support) | ||
and its serialization into the Datadog error tags and the 'events' tag | ||
""" | ||
with test_library: | ||
with test_library.otel_start_span("operation") as span: | ||
span.set_status(OTEL_ERROR_CODE, "error_desc") | ||
span.record_exception( | ||
message="woof1", attributes={"string_val": "value", "exception.stacktrace": "stacktrace1"} | ||
) | ||
span.add_event(name="non_exception_event", attributes={"exception.stacktrace": "non-error"}) | ||
span.record_exception(message="woof3", attributes={"exception.message": "message override"}) | ||
span.end_span() | ||
|
||
root_span = get_span(test_agent) | ||
assert "events" in root_span["meta"] | ||
|
||
events = json.loads(root_span.get("meta", {}).get("events")) | ||
assert len(events) == 3 | ||
event1 = events[0] | ||
assert event1.get("name") == "exception" | ||
assert event1["attributes"].get("string_val") == "value" | ||
assert event1["attributes"].get("exception.message") == "woof1" | ||
assert event1["attributes"].get("exception.stacktrace") == "stacktrace1" | ||
assert event1.get("time_unix_nano") > 0 | ||
|
||
event2 = events[1] | ||
assert event2.get("name") == "non_exception_event" | ||
assert event2["attributes"].get("exception.stacktrace") == "non-error" | ||
assert event2.get("time_unix_nano") > event1.get("time_unix_nano") | ||
|
||
event3 = events[2] | ||
assert event3.get("name") == "exception" | ||
assert event3["attributes"].get("exception.message") == "message override" | ||
assert event3.get("time_unix_nano") > event2.get("time_unix_nano") | ||
|
||
assert root_span["error"] == 1 | ||
error_message = root_span["meta"].get("error.message") or root_span["meta"].get("error.msg") | ||
assert error_message == "message override" | ||
assert "error.type" in root_span["meta"] | ||
assert "error.stack" in root_span["meta"] | ||
|
||
|
||
def run_operation_name_test(expected_operation_name: str, span_kind: int, attributes: dict, test_library, test_agent): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters