Skip to content

Commit db24eda

Browse files
committed
Add span processor coverage suite
1 parent 43f4d69 commit db24eda

File tree

2 files changed

+485
-0
lines changed

2 files changed

+485
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
from pathlib import Path
5+
6+
TESTS_ROOT = Path(__file__).resolve().parent
7+
stub_path = TESTS_ROOT / "stubs"
8+
if str(stub_path) not in sys.path:
9+
sys.path.insert(0, str(stub_path))
10+
11+
from agents.tracing import ( # noqa: E402
12+
get_trace_provider,
13+
set_trace_processors,
14+
)
15+
16+
from opentelemetry.instrumentation.openai_agents import ( # noqa: E402
17+
OpenAIAgentsInstrumentor,
18+
)
19+
from opentelemetry.instrumentation.openai_agents.package import ( # noqa: E402
20+
_instruments,
21+
)
22+
from opentelemetry.sdk.trace import TracerProvider # noqa: E402
23+
24+
25+
def test_double_instrument_is_noop():
26+
set_trace_processors([])
27+
provider = TracerProvider()
28+
instrumentor = OpenAIAgentsInstrumentor()
29+
30+
instrumentor.instrument(tracer_provider=provider)
31+
trace_provider = get_trace_provider()
32+
assert len(trace_provider._multi_processor._processors) == 1
33+
34+
instrumentor.instrument(tracer_provider=provider)
35+
assert len(trace_provider._multi_processor._processors) == 1
36+
37+
instrumentor.uninstrument()
38+
instrumentor.uninstrument()
39+
set_trace_processors([])
40+
41+
42+
def test_instrumentation_dependencies_exposed():
43+
instrumentor = OpenAIAgentsInstrumentor()
44+
assert instrumentor.instrumentation_dependencies() == _instruments

0 commit comments

Comments
 (0)