Skip to content

Commit

Permalink
chore(crashtracker): add required backend tags (#10199)
Browse files Browse the repository at this point in the history
This adds two new tags to the crashtracker. These tags will not be
required in an upcoming version of libdatadog, but that version doesn't
exist yet, so here we are.

There's no need to document anything in a changelog since this feature
isn't customer-impacting. It just makes it easier for us to build
dashboards on the backend. :)

[PROF-10357]

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit a657198)
  • Loading branch information
sanchda authored and github-actions[bot] committed Aug 14, 2024
1 parent 4879718 commit 7ef0693
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 @@ -23,3 +23,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 @@ -155,6 +155,8 @@ Datadog::Crashtracker::get_tags()
{ ExportTagKey::runtime, runtime },
{ 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 7ef0693

Please sign in to comment.