Skip to content

Commit 0d64bcb

Browse files
committed
up
1 parent eb28082 commit 0d64bcb

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

tests/opentelemetry-test-utils/tests/test_weaver_live_check.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ def test_sdk_resource_with_service_name(self):
5858
weaver.end_and_check()
5959

6060
def test_custom_policy_violation_raises(self):
61-
"""A policy that forbids service.name causes end_and_check to raise."""
61+
"""A policy that fails on never.use.this.attribute."""
6262
with WeaverLiveCheck(policies_dir=_TESTDATA_DIR) as weaver:
6363
provider = _make_provider(weaver.otlp_endpoint)
6464
with provider.get_tracer("test-tracer").start_as_current_span(
6565
"test-span"
66-
):
67-
pass
66+
) as span:
67+
span.set_attribute("never.use.this.attribute", "bad value")
68+
6869
provider.force_flush()
6970

7071
with self.assertRaises(AssertionError) as cm:
7172
weaver.end_and_check()
7273

73-
self.assertIn("service.name", str(cm.exception))
74+
self.assertIn("never.use.this.attribute", str(cm.exception))

tests/opentelemetry-test-utils/tests/testdata/forbid_service_name.rego

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package live_check_advice
2+
3+
import rego.v1
4+
5+
deny contains result if {
6+
input.sample.attribute.name == "never.use.this.attribute"
7+
result := {
8+
"type": "advice",
9+
"advice_type": "test_check",
10+
"advice_level": "violation",
11+
"message": "never.use.this.attribute is forbidden by this bogus policy",
12+
}
13+
}

0 commit comments

Comments
 (0)