Skip to content

Commit 2a50ef7

Browse files
committed
rename instrumentation.py to instrumentor.py
1 parent af5b462 commit 2a50ef7

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

instrumentation-genai/opentelemetry-instrumentation-mcp/src/opentelemetry/instrumentation/mcp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from .instrumentation import McpInstrumentor
15+
from .instrumentor import McpInstrumentor
1616
from .version import __version__
1717

1818
__all__ = ["McpInstrumentor", "__version__"]

instrumentation-genai/opentelemetry-instrumentation-mcp/src/opentelemetry/instrumentation/mcp/instrumentation.py renamed to instrumentation-genai/opentelemetry-instrumentation-mcp/src/opentelemetry/instrumentation/mcp/instrumentor.py

File renamed without changes.

instrumentation-genai/opentelemetry-instrumentation-mcp/tests/test_instrumentor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ def setUp(self):
6868
self.instrumentor = McpInstrumentor()
6969

7070
@patch(
71-
"opentelemetry.instrumentation.mcp.instrumentation.register_post_import_hook"
71+
"opentelemetry.instrumentation.mcp.instrumentor.register_post_import_hook"
7272
)
7373
def test_instrument_registers_hooks(self, mock_register: MagicMock):
7474
"""Test that _instrument registers all required hooks."""
7575
self.instrumentor._instrument()
7676
self.assertEqual(mock_register.call_count, 4)
7777

7878
@patch(
79-
"opentelemetry.instrumentation.mcp.instrumentation.register_post_import_hook"
79+
"opentelemetry.instrumentation.mcp.instrumentor.register_post_import_hook"
8080
)
8181
def test_instrument_registers_session_hooks(
8282
self, mock_register: MagicMock
@@ -92,7 +92,7 @@ def test_instrument_registers_session_hooks(
9292
self.assertEqual(len(session_calls), 2)
9393

9494
@patch(
95-
"opentelemetry.instrumentation.mcp.instrumentation.register_post_import_hook"
95+
"opentelemetry.instrumentation.mcp.instrumentor.register_post_import_hook"
9696
)
9797
def test_instrument_registers_server_hooks(self, mock_register: MagicMock):
9898
"""Test that _instrument registers server hooks."""
@@ -112,21 +112,21 @@ class TestMcpInstrumentorUninstrument(unittest.TestCase):
112112
def setUp(self):
113113
self.instrumentor = McpInstrumentor()
114114

115-
@patch("opentelemetry.instrumentation.mcp.instrumentation.unwrap")
115+
@patch("opentelemetry.instrumentation.mcp.instrumentor.unwrap")
116116
def test_uninstrument_unwraps_all(self, mock_unwrap: MagicMock):
117117
"""Test that _uninstrument unwraps all hooks."""
118118
self.instrumentor._uninstrument()
119119
self.assertEqual(mock_unwrap.call_count, 4)
120120

121-
@patch("opentelemetry.instrumentation.mcp.instrumentation.unwrap")
121+
@patch("opentelemetry.instrumentation.mcp.instrumentor.unwrap")
122122
def test_uninstrument_unwraps_send_request(self, mock_unwrap: MagicMock):
123123
"""Test that _uninstrument unwraps send_request."""
124124
self.instrumentor._uninstrument()
125125
mock_unwrap.assert_any_call(
126126
"mcp.shared.session", "BaseSession.send_request"
127127
)
128128

129-
@patch("opentelemetry.instrumentation.mcp.instrumentation.unwrap")
129+
@patch("opentelemetry.instrumentation.mcp.instrumentor.unwrap")
130130
def test_uninstrument_unwraps_send_notification(
131131
self, mock_unwrap: MagicMock
132132
):
@@ -136,15 +136,15 @@ def test_uninstrument_unwraps_send_notification(
136136
"mcp.shared.session", "BaseSession.send_notification"
137137
)
138138

139-
@patch("opentelemetry.instrumentation.mcp.instrumentation.unwrap")
139+
@patch("opentelemetry.instrumentation.mcp.instrumentor.unwrap")
140140
def test_uninstrument_unwraps_handle_request(self, mock_unwrap: MagicMock):
141141
"""Test that _uninstrument unwraps handle_request."""
142142
self.instrumentor._uninstrument()
143143
mock_unwrap.assert_any_call(
144144
"mcp.server.lowlevel.server", "Server._handle_request"
145145
)
146146

147-
@patch("opentelemetry.instrumentation.mcp.instrumentation.unwrap")
147+
@patch("opentelemetry.instrumentation.mcp.instrumentor.unwrap")
148148
def test_uninstrument_unwraps_handle_notification(
149149
self, mock_unwrap: MagicMock
150150
):

instrumentation-genai/opentelemetry-instrumentation-mcp/tests/test_server_wrapper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
8282
self.assertEqual(result, {"result": "success"})
8383

8484
@patch(
85-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
85+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
8686
)
8787
def test_wrap_server_handle_request_with_request(
8888
self, mock_generate_attrs: MagicMock
@@ -126,7 +126,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
126126
self.assertEqual(result, {"result": "success"})
127127

128128
@patch(
129-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
129+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
130130
)
131131
def test_wrap_server_handle_notification_with_notification(
132132
self, mock_generate_attrs: MagicMock
@@ -170,7 +170,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
170170
self.assertEqual(result, {"result": "success"})
171171

172172
@patch(
173-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
173+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
174174
)
175175
def test_wrap_server_message_handler_with_request_id(
176176
self, mock_generate_attrs: MagicMock
@@ -206,7 +206,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
206206
self.assertEqual(call_kwargs["kind"], SpanKind.SERVER)
207207

208208
@patch(
209-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
209+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
210210
)
211211
def test_wrap_server_message_handler_without_request_id(
212212
self, mock_generate_attrs: MagicMock
@@ -240,7 +240,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
240240
mock_span_ctx.assert_called_once()
241241

242242
@patch(
243-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
243+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
244244
)
245245
def test_wrap_server_message_handler_extracts_trace_context(
246246
self, mock_generate_attrs: MagicMock
@@ -282,7 +282,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
282282
self.assertIn("carrier", call_kwargs)
283283

284284
@patch(
285-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
285+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
286286
)
287287
def test_wrap_server_message_handler_success_status(
288288
self, mock_generate_attrs: MagicMock
@@ -317,7 +317,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
317317
mock_span.set_status.assert_called_once()
318318

319319
@patch(
320-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
320+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
321321
)
322322
def test_wrap_server_message_handler_error_status(
323323
self, mock_generate_attrs: MagicMock

instrumentation-genai/opentelemetry-instrumentation-mcp/tests/test_session_wrapper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
126126
self.assertEqual(result, {"result": "success"})
127127

128128
@patch(
129-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
129+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
130130
)
131131
def test_wrap_session_send_client_request(
132132
self, mock_generate_attrs: MagicMock
@@ -159,7 +159,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> dict[str, str]:
159159
self.assertEqual(call_kwargs["kind"], SpanKind.CLIENT)
160160

161161
@patch(
162-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
162+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
163163
)
164164
def test_wrap_session_send_client_notification(
165165
self, mock_generate_attrs: MagicMock
@@ -190,7 +190,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
190190
self.assertEqual(call_kwargs["kind"], SpanKind.CLIENT)
191191

192192
@patch(
193-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
193+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
194194
)
195195
def test_wrap_session_send_server_request(
196196
self, mock_generate_attrs: MagicMock
@@ -221,7 +221,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
221221
self.assertEqual(call_kwargs["kind"], SpanKind.SERVER)
222222

223223
@patch(
224-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
224+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
225225
)
226226
def test_wrap_session_send_injects_trace_context(
227227
self, mock_generate_attrs: MagicMock
@@ -254,7 +254,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
254254
)
255255

256256
@patch(
257-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
257+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
258258
)
259259
def test_wrap_session_send_success_status(
260260
self, mock_generate_attrs: MagicMock
@@ -285,7 +285,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
285285
mock_span.set_status.assert_called_once()
286286

287287
@patch(
288-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
288+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
289289
)
290290
def test_wrap_session_send_error_status(
291291
self, mock_generate_attrs: MagicMock
@@ -317,7 +317,7 @@ async def mock_wrapped(*args: Any, **kwargs: Any) -> Any:
317317
mock_span.record_exception.assert_called_once()
318318

319319
@patch(
320-
"opentelemetry.instrumentation.mcp.instrumentation.McpInstrumentor._generate_mcp_message_attrs"
320+
"opentelemetry.instrumentation.mcp.instrumentor.McpInstrumentor._generate_mcp_message_attrs"
321321
)
322322
def test_wrap_session_send_preserves_existing_params(
323323
self, mock_generate_attrs: MagicMock

0 commit comments

Comments
 (0)