Skip to content

Commit 9e53810

Browse files
Update tags to be a single tag with matching rules
1 parent fe703a9 commit 9e53810

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

ddtrace/appsec/ai_guard/_api_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ def evaluate(self, messages: List[Message], options: Optional[Options] = None) -
240240
)
241241

242242
span.set_tag(AI_GUARD.ACTION_TAG, action)
243-
for tag in tags:
244-
span.set_tag(AI_GUARD.TAG + ".tag." + tag, "true")
243+
if len(tags) > 0:
244+
span.set_tag(AI_GUARD.TAG + ".matching_rules", json.dumps(tags))
245245
if reason:
246246
span.set_tag(AI_GUARD.REASON_TAG, reason)
247247
else:

tests/appsec/ai_guard/api/test_api_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
from itertools import product
23
from unittest.mock import Mock
34
from unittest.mock import patch
@@ -114,8 +115,8 @@ def test_evaluate_method(
114115
expected_tags.update({"ai_guard.tool_name": "calc"})
115116
if action != "ALLOW" and blocking:
116117
expected_tags.update({"ai_guard.blocked": "true"})
117-
for tag in tags:
118-
expected_tags.update({"ai_guard.tag." + tag: "true"})
118+
if len(tags) > 0:
119+
expected_tags.update({"ai_guard.matching_rules": json.dumps(tags)})
119120
assert_ai_guard_span(
120121
tracer,
121122
messages,

0 commit comments

Comments
 (0)