Skip to content

Commit aa04eb5

Browse files
juanjuxemmettbutler
authored andcommitted
docs(asm): add docstring to the event tracking SDK functions (#4940)
Signed-off-by: Juanjo Alvarez <[email protected]> ## Description <!-- Briefly describe the change and why it was required. --> <!-- If this is a breaking change, explain why it is necessary. Breaking changes must append `!` after the type/scope. See https://ddtrace.readthedocs.io/en/stable/contributing.html for more details. --> ## Checklist - [ ] Followed the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) when writing a release note. - [ ] Add additional sections for `feat` and `fix` pull requests. - [ ] [Library documentation](https://github.com/DataDog/dd-trace-py/tree/1.x/docs) and/or [Datadog's documentation site](https://github.com/DataDog/documentation/) is updated. Link to doc PR in description. <!-- Copy and paste the relevant snippet based on the type of pull request --> <!-- START feat --> ## Motivation <!-- Expand on why the change is required, include relevant context for reviewers --> ## Design <!-- Include benefits from the change as well as possible drawbacks and trade-offs --> ## Testing strategy <!-- Describe the automated tests and/or the steps for manual testing. <!-- END feat --> <!-- START fix --> ## Relevant issue(s) <!-- Link the pull request to any issues related to the fix. Use keywords for links to automate closing the issues once the pull request is merged. --> ## Testing strategy <!-- Describe any added regression tests and/or the manual testing performed. --> <!-- END fix --> ## Reviewer Checklist - [ ] Title is accurate. - [ ] Description motivates each change. - [ ] No unnecessary changes were introduced in this PR. - [ ] Avoid breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Release note has been added and follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines), or else `changelog/no-changelog` label added. - [ ] All relevant GitHub issues are correctly linked. - [ ] Change contains telemetry where appropriate (logs, metrics, etc.). - [ ] Telemetry is meaningful, actionable and does not have the potential to leak sensitive data. Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 395aa87 commit aa04eb5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

ddtrace/appsec/trace_utils.py

+25
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ def track_user_login_success_event(
5151
propagate=False,
5252
):
5353
# type: (Tracer, str, Optional[dict], Optional[str], Optional[str], Optional[str], Optional[str], Optional[str], bool) -> None # noqa: E501
54+
"""
55+
Add a new login success tracking event. The parameters after metadata (name, email,
56+
scope, role, session_id, propagate) will be passed to the `set_user` function that will be called
57+
by this one, see:
58+
https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
59+
https://docs.datadoghq.com/security_platform/application_security/setup_and_configure/?tab=set_tag&code-lang=python
60+
61+
:param tracer: tracer instance to use
62+
:param user_id: a string with the UserId
63+
:param metadata: a dictionary with additional metadata information to be stored with the event
64+
"""
5465

5566
span = _track_user_login_common(tracer, user_id, True, metadata)
5667
if not span:
@@ -62,6 +73,13 @@ def track_user_login_success_event(
6273

6374
def track_user_login_failure_event(tracer, user_id, exists, metadata=None):
6475
# type: (Tracer, str, bool, Optional[dict]) -> None
76+
"""
77+
Add a new login failure tracking event.
78+
:param tracer: tracer instance to use
79+
:param user_id: a string with the UserId if exists=True or the username if not
80+
:param exists: a boolean indicating if the user exists in the system
81+
:param metadata: a dictionary with additional metadata information to be stored with the event
82+
"""
6583

6684
span = _track_user_login_common(tracer, user_id, False, metadata)
6785
if not span:
@@ -74,6 +92,13 @@ def track_user_login_failure_event(tracer, user_id, exists, metadata=None):
7492

7593
def track_custom_event(tracer, event_name, metadata):
7694
# type: (Tracer, str, dict) -> None
95+
"""
96+
Add a new custom tracking event.
97+
98+
:param tracer: tracer instance to use
99+
:param event_name: the name of the custom event
100+
:param metadata: a dictionary with additional metadata information to be stored with the event
101+
"""
77102

78103
if not event_name:
79104
log.warning("Empty event name given to track_custom_event. Skipping setting tags.")

0 commit comments

Comments
 (0)