MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / instrument_one

Function instrument_one

agentops/instrumentation/__init__.py:496–520  ·  view source on GitHub ↗

Instrument a single package using the provided loader. Returns the instrumentor instance if successful, None otherwise.

(loader: InstrumentorLoader)

Source from the content-addressed store, hash-verified

494
495
496def instrument_one(loader: InstrumentorLoader) -> Optional[BaseInstrumentor]:
497 """
498 Instrument a single package using the provided loader.
499 Returns the instrumentor instance if successful, None otherwise.
500 """
501 if not loader.should_activate:
502 # This log is important for users to know why something wasn't instrumented.
503 logger.debug(
504 f"AgentOps: Package '{loader.package_name or loader.module_name}' not found or version is less than minimum required ('{loader.min_version}'). Skipping instrumentation."
505 )
506 return None
507
508 instrumentor = loader.get_instance()
509 try:
510 # Use the provider directly from the global tracer instance
511 instrumentor.instrument(tracer_provider=tracer.provider)
512 logger.debug(
513 f"AgentOps: Successfully instrumented '{loader.class_name}' for package '{loader.package_name or loader.module_name}'."
514 )
515 except Exception as e:
516 logger.error(
517 f"Failed to instrument {loader.class_name} for {loader.package_name or loader.module_name}: {e}",
518 exc_info=True,
519 )
520 return instrumentor
521
522
523def instrument_all():

Callers 1

_perform_instrumentationFunction · 0.85

Calls 1

get_instanceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…