Skip to content

Commit

Permalink
chore(crashtracker): add required backend tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchda committed Aug 13, 2024
1 parent d028d80 commit 5c436eb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ constexpr std::string_view g_language_name = "python";

// Name of the library
constexpr std::string_view g_library_name = "dd-trace-py";

// These are default settings for crashtracker tags. These will be moved internally to crashtracker in the near future.
constexpr std::string_view g_crashtracker_is_crash = "true";
constexpr std::string_view g_crashtracker_severity = "crash";
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ namespace Datadog {
X(runtime_id, "runtime-id") \
X(profiler_version, "profiler_version") \
X(library_version, "library_version") \
X(profile_seq, "profile_seq")
X(profile_seq, "profile_seq") \
X(is_crash, "is_crash") \
X(severity, "severity")

// Here there are two columns because the Datadog backend expects these labels
// to have spaces in the names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ Datadog::Crashtracker::get_tags()
{ ExportTagKey::runtime_id, runtime_id },
{ ExportTagKey::runtime_version, runtime_version },
{ ExportTagKey::library_version, library_version },
{ ExportTagKey::is_crash, g_crashtracker_is_crash },
{ ExportTagKey::severity, g_crashtracker_severity },
};

// Add system tags
Expand Down
39 changes: 39 additions & 0 deletions tests/internal/crashtracker/test_crashtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,45 @@ def test_crashtracker_auto_disabled(run_python_code_in_subprocess):
assert not conn


@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Linux only")
@pytest.mark.subprocess()
def test_crashtracker_tags_required():
# Tests tag ingestion in the core API
import ctypes
import os

import tests.internal.crashtracker.utils as utils

port, sock = utils.crashtracker_receiver_bind()
assert port
assert sock

pid = os.fork()
if pid == 0:
assert utils.start_crashtracker(port)
stdout_msg, stderr_msg = utils.read_files(["stdout.log", "stderr.log"])
assert not stdout_msg
assert not stderr_msg

ctypes.string_at(0)
exit(-1)

conn = utils.listen_get_conn(sock)
assert conn
data = utils.conn_to_bytes(conn)
conn.close()
assert b"string_at" in data

# Now check for the tags
tags = {
"is_crash": "true",
"severity": "crash",
}
for k, v in tags.items():
assert k.encode() in data, k
assert v.encode() in data, v


@pytest.mark.skipif(not sys.platform.startswith("linux"), reason="Linux only")
def test_crashtracker_user_tags_envvar(run_python_code_in_subprocess):
# Setup the listening socket before we open ddtrace
Expand Down

0 comments on commit 5c436eb

Please sign in to comment.