diff --git a/agentops/instrumentation/__init__.py b/agentops/instrumentation/__init__.py index 2df5c7a9a..cde3b9375 100644 --- a/agentops/instrumentation/__init__.py +++ b/agentops/instrumentation/__init__.py @@ -144,15 +144,9 @@ def _is_installed_package(module_obj: ModuleType, package_name_key: str) -> bool package_name_key in UTILITY_INSTRUMENTORS and UTILITY_INSTRUMENTORS[package_name_key].get("package_name") == "python" ): - logger.debug( - f"_is_installed_package: Module '{package_name_key}' is a Python standard library module. Considering it an installed package." - ) return True if not hasattr(module_obj, "__file__") or not module_obj.__file__: - logger.debug( - f"_is_installed_package: Module '{package_name_key}' has no __file__, assuming it might be an SDK namespace package. Returning True." - ) return True module_path = os.path.normcase(os.path.realpath(os.path.abspath(module_obj.__file__))) @@ -171,13 +165,9 @@ def _is_installed_package(module_obj: ModuleType, package_name_key: str) -> bool for sp_dir in normalized_site_packages_dirs: if module_path.startswith(sp_dir): - logger.debug( - f"_is_installed_package: Module '{package_name_key}' is a library, instrumenting '{package_name_key}'." - ) return True # Priority 2: If not in site-packages, it's highly likely a local module or not an SDK we target. - logger.debug(f"_is_installed_package: Module '{package_name_key}' is a local module, skipping instrumentation.") return False @@ -232,9 +222,7 @@ def _uninstrument_providers(): new_active_instrumentors.append(instrumentor) if uninstrumented_any or not new_active_instrumentors and _active_instrumentors: - logger.debug( - f"_uninstrument_providers: Processed. Previous active: {len(_active_instrumentors)}, New active after filtering providers: {len(new_active_instrumentors)}" - ) + pass _active_instrumentors = new_active_instrumentors @@ -247,12 +235,10 @@ def _should_instrument_package(package_name: str) -> bool: # If already instrumented by AgentOps (using our refined check), skip. if _is_package_instrumented(package_name): - logger.debug(f"_should_instrument_package: '{package_name}' already instrumented by AgentOps. Skipping.") return False # Utility instrumentors should always be instrumented regardless of agentic library state if package_name in UTILITY_INSTRUMENTORS: - logger.debug(f"_should_instrument_package: '{package_name}' is a utility instrumentor. Always allowing.") return True # Only apply agentic/provider logic if it's NOT a utility instrumentor @@ -260,9 +246,6 @@ def _should_instrument_package(package_name: str) -> bool: is_target_provider = package_name in PROVIDERS if not is_target_agentic and not is_target_provider: - logger.debug( - f"_should_instrument_package: '{package_name}' is not a targeted provider or agentic library. Skipping." - ) return False if _has_agentic_library: @@ -286,14 +269,8 @@ def _should_instrument_package(package_name: str) -> bool: _uninstrument_providers() return True if is_target_provider: - logger.debug( - f"_should_instrument_package: '{package_name}' is a provider, no agentic library active. Allowing." - ) return True - logger.debug( - f"_should_instrument_package: Defaulting to False for '{package_name}' (state: _has_agentic_library={_has_agentic_library})" - ) return False @@ -310,9 +287,6 @@ def _perform_instrumentation(package_name: str): and package_name not in AGENTIC_LIBRARIES and package_name not in UTILITY_INSTRUMENTORS ): - logger.debug( - f"_perform_instrumentation: Package '{package_name}' not found in PROVIDERS, AGENTIC_LIBRARIES, or UTILITY_INSTRUMENTORS. Skipping." - ) return config = PROVIDERS.get(package_name) or AGENTIC_LIBRARIES.get(package_name) or UTILITY_INSTRUMENTORS[package_name] @@ -342,9 +316,7 @@ def _perform_instrumentation(package_name: str): and existing_inst._agentops_instrumented_package_key == package_name ): is_newly_added = False - logger.debug( - f"_perform_instrumentation: Instrumentor for '{package_name}' already in _active_instrumentors. Not adding again." - ) + break if is_newly_added: _active_instrumentors.append(instrumentor_instance) @@ -356,9 +328,7 @@ def _perform_instrumentation(package_name: str): # _uninstrument_providers() was already called in _should_instrument_package for the first agentic library. _has_agentic_library = True else: - logger.debug( - f"_perform_instrumentation: instrument_one for '{package_name}' returned None. Not added to active instrumentors." - ) + pass def _import_monitor(name: str, globals_dict=None, locals_dict=None, fromlist=(), level=0): @@ -419,9 +389,7 @@ def _import_monitor(name: str, globals_dict=None, locals_dict=None, fromlist=(), ) continue else: - logger.debug( - f"_import_monitor: No module object found in sys.modules for '{package_to_check}', proceeding with SDK instrumentation attempt." - ) + pass _instrumenting_packages.add(package_to_check) try: @@ -552,9 +520,7 @@ def instrument_all(): if not is_sdk: continue else: - logger.debug( - f"instrument_all: No module object found for '{package_to_check}' in sys.modules during startup scan. Proceeding cautiously." - ) + pass _instrumenting_packages.add(package_to_check) try: @@ -571,7 +537,6 @@ def uninstrument_all(): builtins.__import__ = _original_builtins_import for instrumentor in _active_instrumentors: instrumentor.uninstrument() - logger.debug(f"Uninstrumented {instrumentor.__class__.__name__}") _active_instrumentors = [] _has_agentic_library = False diff --git a/agentops/instrumentation/agentic/ag2/instrumentor.py b/agentops/instrumentation/agentic/ag2/instrumentor.py index ebb9bf594..2295a7650 100644 --- a/agentops/instrumentation/agentic/ag2/instrumentor.py +++ b/agentops/instrumentation/agentic/ag2/instrumentor.py @@ -78,9 +78,8 @@ def _custom_wrap(self, **kwargs): for module, method, wrapper_factory in methods_to_wrap: try: wrap_function_wrapper(module, method, wrapper_factory(self._tracer)) - logger.debug(f"Successfully wrapped {method}") except (AttributeError, ModuleNotFoundError) as e: - logger.debug(f"Failed to wrap {method}: {e}") + logger.warning(f"Failed to wrap {method}: {e}") def _custom_unwrap(self, **kwargs): """Remove instrumentation from AG2.""" @@ -98,9 +97,8 @@ def _custom_unwrap(self, **kwargs): try: for module, method in methods_to_unwrap: otel_unwrap(module, method) - logger.debug("Successfully uninstrumented AG2") except Exception as e: - logger.debug(f"Failed to unwrap AG2 methods: {e}") + logger.warning(f"Failed to unwrap AG2 methods: {e}") def _set_llm_config_attributes(self, span, llm_config): if not isinstance(llm_config, dict): @@ -411,7 +409,7 @@ def _extract_chat_history(self, span, initiator, recipient): if "model" in meta: span.set_attribute(SpanAttributes.LLM_RESPONSE_MODEL, meta["model"]) except Exception as e: - logger.debug(f"Could not extract chat history: {e}") + logger.warning(f"Could not extract chat history: {e}") def _set_message_attributes(self, span, message, index, prefix): """Set message attributes on span.""" diff --git a/agentops/instrumentation/agentic/agno/instrumentor.py b/agentops/instrumentation/agentic/agno/instrumentor.py index 8c7cdd9ff..876a37f5b 100644 --- a/agentops/instrumentation/agentic/agno/instrumentor.py +++ b/agentops/instrumentation/agentic/agno/instrumentor.py @@ -936,7 +936,6 @@ def _custom_wrap(self, **kwargs): def _perform_wrapping(self): """Actually perform the wrapping - called after imports are complete.""" if not self._tracer: - logger.debug("No tracer available for Agno wrapping") return from agentops.instrumentation.common.wrappers import wrap_function_wrapper, WrapConfig, wrap @@ -989,7 +988,7 @@ def _perform_wrapping(self): wrap(wrap_config, self._tracer) wrapped_count += 1 except Exception as e: - logger.debug(f"Failed to wrap {wrap_config}: {e}") + logger.warning(f"Failed to wrap {wrap_config}: {e}") # Now wrap the streaming methods that need custom wrappers streaming_methods = [ @@ -1017,7 +1016,7 @@ def _perform_wrapping(self): wrap_function_wrapper(package, method, wrapper) wrapped_count += 1 except Exception as e: - logger.debug(f"Failed to wrap {package}.{method}: {e}") + logger.warning(f"Failed to wrap {package}.{method}: {e}") if wrapped_count > 0: logger.info(f"Agno instrumentation: Successfully wrapped {wrapped_count} methods") diff --git a/agentops/instrumentation/agentic/google_adk/patch.py b/agentops/instrumentation/agentic/google_adk/patch.py index 88d9aa2df..20b4f3b8a 100644 --- a/agentops/instrumentation/agentic/google_adk/patch.py +++ b/agentops/instrumentation/agentic/google_adk/patch.py @@ -328,7 +328,7 @@ def _extract_llm_attributes(llm_request_dict: dict, llm_response: Any) -> dict: attributes[SpanAttributes.LLM_RESPONSE_ID] = response_dict["id"] except Exception as e: - logger.debug(f"Failed to extract response attributes: {e}") + logger.warning(f"Failed to extract response attributes: {e}") return attributes @@ -647,7 +647,7 @@ def _patch(module_name: str, object_name: str, method_name: str, wrapper_functio obj = getattr(module, object_name) wrapt.wrap_function_wrapper(obj, method_name, wrapper_function(agentops_tracer)) _wrapped_methods.append((obj, method_name)) - logger.debug(f"Successfully wrapped {module_name}.{object_name}.{method_name}") + except Exception as e: logger.warning(f"Could not wrap {module_name}.{object_name}.{method_name}: {e}") @@ -658,14 +658,13 @@ def _patch_module_function(module_name: str, function_name: str, wrapper_functio module = __import__(module_name, fromlist=[function_name]) wrapt.wrap_function_wrapper(module, function_name, wrapper_function(agentops_tracer)) _wrapped_methods.append((module, function_name)) - logger.debug(f"Successfully wrapped {module_name}.{function_name}") + except Exception as e: logger.warning(f"Could not wrap {module_name}.{function_name}: {e}") def patch_adk(agentops_tracer): """Apply all patches to Google ADK modules.""" - logger.debug("Applying Google ADK patches for AgentOps instrumentation") # First, disable ADK's own tracer by replacing it with our NoOpTracer noop_tracer = NoOpTracer() @@ -694,7 +693,7 @@ def patch_adk(agentops_tracer): module = sys.modules[module_name] if hasattr(module, "tracer"): module.tracer = noop_tracer - logger.debug(f"Replaced tracer in {module_name}") + except Exception as e: logger.warning(f"Failed to replace tracer in {module_name}: {e}") @@ -739,7 +738,6 @@ def patch_adk(agentops_tracer): def unpatch_adk(): """Remove all patches from Google ADK modules.""" - logger.debug("Removing Google ADK patches") # Restore ADK's tracer try: @@ -757,7 +755,7 @@ def unpatch_adk(): if hasattr(getattr(obj, method_name), "__wrapped__"): original = getattr(obj, method_name).__wrapped__ setattr(obj, method_name, original) - logger.debug(f"Successfully unwrapped {obj}.{method_name}") + except Exception as e: logger.warning(f"Failed to unwrap {obj}.{method_name}: {e}") diff --git a/agentops/instrumentation/agentic/openai_agents/attributes/common.py b/agentops/instrumentation/agentic/openai_agents/attributes/common.py index 154055db1..2cb5b6bfe 100644 --- a/agentops/instrumentation/agentic/openai_agents/attributes/common.py +++ b/agentops/instrumentation/agentic/openai_agents/attributes/common.py @@ -543,7 +543,6 @@ def get_span_attributes(span_data: Any) -> AttributeMap: elif span_type == "SpeechGroupSpanData": attributes = get_speech_group_span_attributes(span_data) else: - logger.debug(f"[agentops.instrumentation.openai_agents.attributes] Unknown span type: {span_type}") attributes = {} return attributes diff --git a/agentops/instrumentation/agentic/openai_agents/attributes/completion.py b/agentops/instrumentation/agentic/openai_agents/attributes/completion.py index 1722109df..1518c4eba 100644 --- a/agentops/instrumentation/agentic/openai_agents/attributes/completion.py +++ b/agentops/instrumentation/agentic/openai_agents/attributes/completion.py @@ -8,7 +8,6 @@ from agentops.instrumentation.common.attributes import AttributeMap -from agentops.logging import logger from agentops.helpers.serialization import model_to_dict from agentops.semconv import ( SpanAttributes, @@ -88,7 +87,6 @@ def get_raw_response_attributes(response: Dict[str, Any]) -> Dict[str, Any]: usage_attrs: AttributeMap = {} process_token_usage(raw_response["usage"], usage_attrs) result.update(usage_attrs) - logger.debug(f"Extracted token usage from raw_responses[{i}]: {usage_attrs}") # Extract output content if "output" in raw_response and isinstance(raw_response["output"], list): diff --git a/agentops/instrumentation/agentic/openai_agents/attributes/tokens.py b/agentops/instrumentation/agentic/openai_agents/attributes/tokens.py index b22351273..746a5e317 100644 --- a/agentops/instrumentation/agentic/openai_agents/attributes/tokens.py +++ b/agentops/instrumentation/agentic/openai_agents/attributes/tokens.py @@ -29,7 +29,7 @@ def safe_parse(content: str) -> Optional[Dict[str, Any]]: return json.loads(content) except (json.JSONDecodeError, TypeError, ValueError): # If parsing fails, log a debug message and return None - logger.debug(f"Failed to parse JSON content: {content[:100]}...") + logger.warning(f"Failed to parse JSON content: {content[:100]}...") return None @@ -202,7 +202,7 @@ def has_key(obj, key): # Process this usage data recursively return process_token_usage(parsed_text["usage"], attributes) except Exception as e: - logger.debug(f"Error during deep token extraction: {e}") + logger.warning(f"Error during deep token extraction: {e}") return result diff --git a/agentops/instrumentation/agentic/openai_agents/exporter.py b/agentops/instrumentation/agentic/openai_agents/exporter.py index 1fc5b345a..0bc8679a2 100644 --- a/agentops/instrumentation/agentic/openai_agents/exporter.py +++ b/agentops/instrumentation/agentic/openai_agents/exporter.py @@ -62,10 +62,9 @@ def log_otel_trace_id(span_type): if hasattr(ctx, "trace_id") and ctx.trace_id: # Convert trace_id to 32-character hex string as shown in the API otel_trace_id = f"{ctx.trace_id:032x}" if isinstance(ctx.trace_id, int) else str(ctx.trace_id) - logger.debug(f"[SPAN] Export | Type: {span_type} | TRACE ID: {otel_trace_id}") + return otel_trace_id - logger.debug(f"[SPAN] Export | Type: {span_type} | NO TRACE ID AVAILABLE") return None @@ -137,7 +136,7 @@ def export_trace(self, trace: Any) -> None: trace_id = getattr(trace, "trace_id", "unknown") if not hasattr(trace, "trace_id"): - logger.debug("Cannot export trace: missing trace_id") + logger.warning("Cannot export trace: missing trace_id") return # Determine if this is a trace end event using status field diff --git a/agentops/instrumentation/agentic/openai_agents/instrumentor.py b/agentops/instrumentation/agentic/openai_agents/instrumentor.py index 00ccded2c..dc9eb876e 100644 --- a/agentops/instrumentation/agentic/openai_agents/instrumentor.py +++ b/agentops/instrumentation/agentic/openai_agents/instrumentor.py @@ -51,12 +51,10 @@ def instrumentation_dependencies(self) -> Collection[str]: def _instrument(self, **kwargs): """Instrument the OpenAI Agents SDK.""" if self._is_instrumented_instance_flag: - logger.debug("OpenAI Agents SDK already instrumented. Skipping.") return tracer_provider = kwargs.get("tracer_provider") if self._tracer is None: - logger.debug("OpenAI Agents SDK tracer is None, creating new tracer.") self._tracer = trace.get_tracer("agentops.instrumentation.openai_agents", LIBRARY_VERSION) try: @@ -82,7 +80,6 @@ def _instrument(self, **kwargs): def _uninstrument(self, **kwargs): """Remove instrumentation from OpenAI Agents SDK.""" if not self._is_instrumented_instance_flag: - logger.debug("OpenAI Agents SDK not currently instrumented. Skipping uninstrument.") return try: # Clean up any active spans in the exporter diff --git a/agentops/instrumentation/agentic/openai_agents/processor.py b/agentops/instrumentation/agentic/openai_agents/processor.py index 6407c2b52..46a5268c1 100644 --- a/agentops/instrumentation/agentic/openai_agents/processor.py +++ b/agentops/instrumentation/agentic/openai_agents/processor.py @@ -1,6 +1,5 @@ from typing import Any from opentelemetry.trace import StatusCode -from agentops.logging import logger class OpenAIAgentsProcessor: @@ -19,7 +18,6 @@ def __init__(self, exporter=None): def on_trace_start(self, sdk_trace: Any) -> None: """Called when a trace starts in the Agents SDK.""" - logger.debug(f"[agentops.instrumentation.openai_agents] Trace started: {sdk_trace}") self.exporter.export_trace(sdk_trace) def on_trace_end(self, sdk_trace: Any) -> None: @@ -29,13 +27,11 @@ def on_trace_end(self, sdk_trace: Any) -> None: # This is used by the exporter to determine whether to create or update a trace sdk_trace.status = StatusCode.OK.name - logger.debug(f"[agentops.instrumentation.openai_agents] Trace ended: {sdk_trace}") self.exporter.export_trace(sdk_trace) def on_span_start(self, span: Any) -> None: """Called when a span starts in the Agents SDK.""" - logger.debug(f"[agentops.instrumentation.openai_agents] Span started: {span}") self.exporter.export_span(span) def on_span_end(self, span: Any) -> None: @@ -45,7 +41,6 @@ def on_span_end(self, span: Any) -> None: # This is used by the exporter to determine whether to create or update a span span.status = StatusCode.OK.name - logger.debug(f"[agentops.instrumentation.openai_agents] Span ended: {span}") self.exporter.export_span(span) def shutdown(self) -> None: diff --git a/agentops/instrumentation/agentic/smolagents/instrumentor.py b/agentops/instrumentation/agentic/smolagents/instrumentor.py index ff185edfc..68ad3e985 100644 --- a/agentops/instrumentation/agentic/smolagents/instrumentor.py +++ b/agentops/instrumentation/agentic/smolagents/instrumentor.py @@ -261,26 +261,26 @@ def _custom_unwrap(self, **kwargs): try: unwrap("smolagents.agents", "CodeAgent.run") except Exception as e: - logger.debug(f"Failed to unwrap CodeAgent.run: {e}") + logger.warning(f"Failed to unwrap CodeAgent.run: {e}") try: unwrap("smolagents.agents", "ToolCallingAgent.run") except Exception as e: - logger.debug(f"Failed to unwrap ToolCallingAgent.run: {e}") + logger.warning(f"Failed to unwrap ToolCallingAgent.run: {e}") try: unwrap("smolagents.agents", "ToolCallingAgent.execute_tool_call") except Exception as e: - logger.debug(f"Failed to unwrap ToolCallingAgent.execute_tool_call: {e}") + logger.warning(f"Failed to unwrap ToolCallingAgent.execute_tool_call: {e}") try: unwrap("smolagents.models", "LiteLLMModel.generate") except Exception as e: - logger.debug(f"Failed to unwrap LiteLLMModel.generate: {e}") + logger.warning(f"Failed to unwrap LiteLLMModel.generate: {e}") try: unwrap("smolagents.models", "LiteLLMModel.generate_stream") except Exception as e: - logger.debug(f"Failed to unwrap LiteLLMModel.generate_stream: {e}") + logger.warning(f"Failed to unwrap LiteLLMModel.generate_stream: {e}") logger.info("SmoLAgents instrumentation disabled") diff --git a/agentops/instrumentation/common/instrumentor.py b/agentops/instrumentation/common/instrumentor.py index 03bb4f608..12a68ef96 100644 --- a/agentops/instrumentation/common/instrumentor.py +++ b/agentops/instrumentation/common/instrumentor.py @@ -69,7 +69,7 @@ def _uninstrument(self, **kwargs): try: unwrap(wrap_config) except Exception as e: - logger.debug( + logger.warning( f"Failed to unwrap {wrap_config.package}." f"{wrap_config.class_name}.{wrap_config.method_name}: {e}" ) @@ -88,7 +88,7 @@ def _wrap_methods(self): try: wrap(wrap_config, self._tracer) except (AttributeError, ModuleNotFoundError) as e: - logger.debug( + logger.warning( f"Could not wrap {wrap_config.package}." f"{wrap_config.class_name}.{wrap_config.method_name}: {e}" ) diff --git a/agentops/instrumentation/common/span_management.py b/agentops/instrumentation/common/span_management.py index ac0d323e8..e0f0a68b9 100644 --- a/agentops/instrumentation/common/span_management.py +++ b/agentops/instrumentation/common/span_management.py @@ -157,7 +157,7 @@ def safe_set_attribute(span: Span, key: str, value: Any, max_length: int = 1000) try: span.set_attribute(key, value) except Exception as e: - logger.debug(f"Failed to set span attribute {key}: {e}") + logger.warning(f"Failed to set span attribute {key}: {e}") def get_span_context_info(span: Optional[Span] = None) -> Tuple[str, str]: diff --git a/agentops/instrumentation/common/token_counting.py b/agentops/instrumentation/common/token_counting.py index c467a78c9..99c43a699 100644 --- a/agentops/instrumentation/common/token_counting.py +++ b/agentops/instrumentation/common/token_counting.py @@ -114,7 +114,7 @@ def _extract_from_crewai_format(token_usage_str: str) -> TokenUsage: usage.cached_prompt_tokens = metrics.get("cached_prompt_tokens") except Exception as e: - logger.debug(f"Failed to parse CrewAI token usage: {e}") + logger.warning(f"Failed to parse CrewAI token usage: {e}") return usage diff --git a/agentops/instrumentation/common/version.py b/agentops/instrumentation/common/version.py index a9a57b7c4..0b329865a 100644 --- a/agentops/instrumentation/common/version.py +++ b/agentops/instrumentation/common/version.py @@ -37,8 +37,7 @@ def get_library_version(package_name: str, default_version: str = "unknown") -> from importlib.metadata import version return version(package_name) - except (ImportError, Exception) as e: - logger.debug(f"Could not find {package_name} version: {e}") + except (ImportError, Exception): return default_version diff --git a/agentops/instrumentation/providers/anthropic/event_handler_wrapper.py b/agentops/instrumentation/providers/anthropic/event_handler_wrapper.py index 3588c23b8..e66dbfed7 100644 --- a/agentops/instrumentation/providers/anthropic/event_handler_wrapper.py +++ b/agentops/instrumentation/providers/anthropic/event_handler_wrapper.py @@ -43,7 +43,7 @@ def _forward_event(self, method_name: str, *args, **kwargs) -> None: method = getattr(self._original_handler, method_name) method(*args, **kwargs) except Exception as e: - logger.debug(f"Error in event handler {method_name}: {e}") + logger.warning(f"Error in event handler {method_name}: {e}") def on_event(self, event: Dict[str, Any]) -> None: """Handle any event by forwarding it to the original handler.""" @@ -87,4 +87,4 @@ def on_error(self, error: Exception) -> None: if self._original_handler is not None and hasattr(self._original_handler, "on_error"): self._original_handler.on_error(error) except Exception as e: - logger.debug(f"Error in event handler on_error: {e}") + logger.warning(f"Error in event handler on_error: {e}") diff --git a/agentops/instrumentation/providers/anthropic/instrumentor.py b/agentops/instrumentation/providers/anthropic/instrumentor.py index 7e4d5a73c..e7aba07bf 100644 --- a/agentops/instrumentation/providers/anthropic/instrumentor.py +++ b/agentops/instrumentation/providers/anthropic/instrumentor.py @@ -134,7 +134,7 @@ def _custom_wrap(self, **kwargs): messages_stream_async_wrapper(self._tracer), ) except (AttributeError, ModuleNotFoundError): - logger.debug("Failed to wrap Anthropic streaming methods") + logger.warning("Failed to wrap Anthropic streaming methods") def _custom_unwrap(self, **kwargs): """Perform custom unwrapping for streaming methods.""" @@ -143,4 +143,4 @@ def _custom_unwrap(self, **kwargs): otel_unwrap("anthropic.resources.messages.messages", "Messages.stream") otel_unwrap("anthropic.resources.messages.messages", "AsyncMessages.stream") except (AttributeError, ModuleNotFoundError): - logger.debug("Failed to unwrap Anthropic streaming methods") + logger.warning("Failed to unwrap Anthropic streaming methods") diff --git a/agentops/instrumentation/providers/anthropic/stream_wrapper.py b/agentops/instrumentation/providers/anthropic/stream_wrapper.py index c42084c19..deb92774b 100644 --- a/agentops/instrumentation/providers/anthropic/stream_wrapper.py +++ b/agentops/instrumentation/providers/anthropic/stream_wrapper.py @@ -94,7 +94,7 @@ def __enter__(self): for key, value in stream_attributes.items(): span.set_attribute(key, value) except Exception as e: - logger.debug(f"Error getting stream attributes: {e}") + logger.warning(f"Error getting stream attributes: {e}") # Set the event handler on the stream if provided if original_event_handler is not None: @@ -121,7 +121,7 @@ def __iter__(self): self.stream.text_stream = InstrumentedTextStream() except Exception as e: - logger.debug(f"Error patching text_stream: {e}") + logger.warning(f"Error patching text_stream: {e}") return self.stream @@ -176,7 +176,7 @@ def __exit__(self, exc_type, exc_val, exc_tb): total_tokens = usage.input_tokens + usage.output_tokens span.set_attribute(SpanAttributes.LLM_USAGE_TOTAL_TOKENS, total_tokens) except Exception as e: - logger.debug(f"Failed to extract final message data: {e}") + logger.warning(f"Failed to extract final message data: {e}") finally: if span.is_recording(): span.end() @@ -334,7 +334,7 @@ async def __aenter__(self): for key, value in stream_attributes.items(): span.set_attribute(key, value) except Exception as e: - logger.debug(f"Error getting async stream attributes: {e}") + logger.warning(f"Error getting async stream attributes: {e}") if original_event_handler is None: try: @@ -358,7 +358,7 @@ async def __aiter__(self): self.stream.text_stream = InstrumentedAsyncTextStream() except Exception as e: - logger.debug(f"Error patching async text_stream: {e}") + logger.warning(f"Error patching async text_stream: {e}") return self.stream @@ -417,7 +417,7 @@ async def __aexit__(self, exc_type, exc_val, exc_tb): total_tokens = usage.input_tokens + usage.output_tokens span.set_attribute(SpanAttributes.LLM_USAGE_TOTAL_TOKENS, total_tokens) except Exception as e: - logger.debug(f"Failed to extract final async message data: {e}") + logger.warning(f"Failed to extract final async message data: {e}") finally: if span.is_recording(): span.end() diff --git a/agentops/instrumentation/providers/google_genai/attributes/chat.py b/agentops/instrumentation/providers/google_genai/attributes/chat.py index 7bd4de998..55fd47145 100644 --- a/agentops/instrumentation/providers/google_genai/attributes/chat.py +++ b/agentops/instrumentation/providers/google_genai/attributes/chat.py @@ -77,7 +77,7 @@ def _set_chat_history_attributes(attributes: AttributeMap, args: Tuple, kwargs: attributes[MessageAttributes.PROMPT_CONTENT.format(i=i)] = content attributes[MessageAttributes.PROMPT_ROLE.format(i=i)] = role except Exception as e: - logger.debug(f"Error extracting chat message at index {i}: {e}") + logger.warning(f"Error extracting chat message at index {i}: {e}") def get_chat_attributes( diff --git a/agentops/instrumentation/providers/google_genai/attributes/common.py b/agentops/instrumentation/providers/google_genai/attributes/common.py index 77d69d908..f2bf40b37 100644 --- a/agentops/instrumentation/providers/google_genai/attributes/common.py +++ b/agentops/instrumentation/providers/google_genai/attributes/common.py @@ -80,7 +80,7 @@ def extract_request_attributes(kwargs: Dict[str, Any]) -> AttributeMap: ) ) except Exception as e: - logger.debug(f"Error extracting config parameters: {e}") + logger.warning(f"Error extracting config parameters: {e}") if "stream" in kwargs: attributes[SpanAttributes.LLM_REQUEST_STREAMING] = kwargs["stream"] diff --git a/agentops/instrumentation/providers/google_genai/attributes/model.py b/agentops/instrumentation/providers/google_genai/attributes/model.py index 414fd439b..a4fe5cb73 100644 --- a/agentops/instrumentation/providers/google_genai/attributes/model.py +++ b/agentops/instrumentation/providers/google_genai/attributes/model.py @@ -108,7 +108,7 @@ def _set_prompt_attributes(attributes: AttributeMap, args: Tuple, kwargs: Dict[s role = item.role attributes[MessageAttributes.PROMPT_ROLE.format(i=i)] = role except Exception as e: - logger.debug(f"Error extracting prompt content at index {i}: {e}") + logger.warning(f"Error extracting prompt content at index {i}: {e}") else: try: extracted_text = _extract_content_from_prompt(content) @@ -116,7 +116,7 @@ def _set_prompt_attributes(attributes: AttributeMap, args: Tuple, kwargs: Dict[s attributes[MessageAttributes.PROMPT_CONTENT.format(i=0)] = extracted_text attributes[MessageAttributes.PROMPT_ROLE.format(i=0)] = "user" except Exception as e: - logger.debug(f"Error extracting prompt content: {e}") + logger.warning(f"Error extracting prompt content: {e}") def _set_response_attributes(attributes: AttributeMap, response: Any) -> None: @@ -163,7 +163,7 @@ def _set_response_attributes(attributes: AttributeMap, response: Any) -> None: if hasattr(candidate, "finish_reason"): attributes[MessageAttributes.COMPLETION_FINISH_REASON.format(i=i)] = candidate.finish_reason except Exception as e: - logger.debug(f"Error extracting completion content: {e}") + logger.warning(f"Error extracting completion content: {e}") def get_model_attributes( diff --git a/agentops/instrumentation/providers/google_genai/instrumentor.py b/agentops/instrumentation/providers/google_genai/instrumentor.py index 32401a785..4c25ce47f 100644 --- a/agentops/instrumentation/providers/google_genai/instrumentor.py +++ b/agentops/instrumentation/providers/google_genai/instrumentor.py @@ -147,7 +147,7 @@ def _custom_wrap(self, **kwargs): f"Successfully wrapped streaming method {stream_method['module']}.{stream_method['class_method']}" ) except (AttributeError, ModuleNotFoundError) as e: - logger.debug(f"Failed to wrap {stream_method['module']}.{stream_method['class_method']}: {e}") + logger.warning(f"Failed to wrap {stream_method['module']}.{stream_method['class_method']}: {e}") logger.info("Google Generative AI instrumentation enabled") @@ -165,6 +165,6 @@ def _custom_unwrap(self, **kwargs): otel_unwrap(stream_method["module"], stream_method["class_method"]) logger.debug(f"Unwrapped streaming method {stream_method['module']}.{stream_method['class_method']}") except (AttributeError, ModuleNotFoundError) as e: - logger.debug(f"Failed to unwrap {stream_method['module']}.{stream_method['class_method']}: {e}") + logger.warning(f"Failed to unwrap {stream_method['module']}.{stream_method['class_method']}: {e}") logger.info("Google Generative AI instrumentation disabled") diff --git a/agentops/instrumentation/providers/ibm_watsonx_ai/attributes/common.py b/agentops/instrumentation/providers/ibm_watsonx_ai/attributes/common.py index 71b82a3f7..2765090b7 100644 --- a/agentops/instrumentation/providers/ibm_watsonx_ai/attributes/common.py +++ b/agentops/instrumentation/providers/ibm_watsonx_ai/attributes/common.py @@ -71,7 +71,7 @@ def convert_params_to_dict(params: Any) -> Dict[str, Any]: try: return params.to_dict() except Exception as e: - logger.debug(f"Could not convert params object to dict: {e}") + logger.warning(f"Could not convert params object to dict: {e}") return {} return params if isinstance(params, dict) else {} diff --git a/agentops/instrumentation/providers/ibm_watsonx_ai/instrumentor.py b/agentops/instrumentation/providers/ibm_watsonx_ai/instrumentor.py index 578827eda..4aaa283c5 100644 --- a/agentops/instrumentation/providers/ibm_watsonx_ai/instrumentor.py +++ b/agentops/instrumentation/providers/ibm_watsonx_ai/instrumentor.py @@ -121,11 +121,9 @@ def _custom_wrap(self, **kwargs): f"{generate_text_stream_config.class_name}.{generate_text_stream_config.method_name}", generate_text_stream_wrapper, ) - logger.debug( - f"Wrapped {generate_text_stream_config.package}.{generate_text_stream_config.class_name}.{generate_text_stream_config.method_name} with dedicated wrapper" - ) + except (StopIteration, AttributeError, ModuleNotFoundError) as e: - logger.debug(f"Could not wrap generate_text_stream with dedicated wrapper: {e}") + logger.warning(f"Could not wrap generate_text_stream with dedicated wrapper: {e}") try: chat_stream_config = next(wc for wc in WRAPPED_METHODS if wc.method_name == "chat_stream") @@ -134,11 +132,9 @@ def _custom_wrap(self, **kwargs): f"{chat_stream_config.class_name}.{chat_stream_config.method_name}", chat_stream_wrapper, ) - logger.debug( - f"Wrapped {chat_stream_config.package}.{chat_stream_config.class_name}.{chat_stream_config.method_name} with dedicated wrapper" - ) + except (StopIteration, AttributeError, ModuleNotFoundError) as e: - logger.debug(f"Could not wrap chat_stream with dedicated wrapper: {e}") + logger.warning(f"Could not wrap chat_stream with dedicated wrapper: {e}") logger.info("IBM watsonx.ai instrumentation enabled") diff --git a/agentops/instrumentation/providers/ibm_watsonx_ai/stream_wrapper.py b/agentops/instrumentation/providers/ibm_watsonx_ai/stream_wrapper.py index f84bca8fd..6210add2e 100644 --- a/agentops/instrumentation/providers/ibm_watsonx_ai/stream_wrapper.py +++ b/agentops/instrumentation/providers/ibm_watsonx_ai/stream_wrapper.py @@ -123,7 +123,7 @@ def __iter__(self): ) except json.JSONDecodeError as json_err: - logger.debug(f"Failed to parse JSON from internal chunk data: {json_err}") + logger.warning(f"Failed to parse JSON from internal chunk data: {json_err}") # Fallback to using the yielded chunk directly if isinstance(yielded_chunk, dict): # chat_stream yields dicts if "choices" in yielded_chunk and yielded_chunk["choices"]: @@ -132,7 +132,7 @@ def __iter__(self): elif isinstance(yielded_chunk, str): # generate_text_stream yields strings generated_text_chunk = yielded_chunk except Exception as parse_err: - logger.debug(f"Error processing internal chunk data: {parse_err}") + logger.warning(f"Error processing internal chunk data: {parse_err}") if isinstance(yielded_chunk, dict): # Fallback for chat if "choices" in yielded_chunk and yielded_chunk["choices"]: delta = yielded_chunk["choices"][0].get("delta", {}) @@ -149,7 +149,7 @@ def __iter__(self): generated_text_chunk = yielded_chunk except AttributeError as attr_err: - logger.debug(f"Could not access internal generator state (gi_frame.f_locals): {attr_err}") + logger.warning(f"Could not access internal generator state (gi_frame.f_locals): {attr_err}") if isinstance(yielded_chunk, dict): # Fallback for chat if "choices" in yielded_chunk and yielded_chunk["choices"]: delta = yielded_chunk["choices"][0].get("delta", {}) @@ -157,7 +157,7 @@ def __iter__(self): elif isinstance(yielded_chunk, str): # Fallback for generate generated_text_chunk = yielded_chunk except Exception as e: - logger.debug(f"Error accessing or processing internal generator state: {e}") + logger.warning(f"Error accessing or processing internal generator state: {e}") if isinstance(yielded_chunk, dict): # Fallback for chat if "choices" in yielded_chunk and yielded_chunk["choices"]: delta = yielded_chunk["choices"][0].get("delta", {}) @@ -230,7 +230,7 @@ def generate_text_stream_wrapper(wrapped, instance, args, kwargs): for key, value in span_attributes.items(): span.set_attribute(key, value) except Exception as e: - logger.debug(f"Error extracting attributes from params dict: {e}") + logger.warning(f"Error extracting attributes from params dict: {e}") span.set_attribute(SpanAttributes.LLM_REQUEST_STREAMING, True) @@ -287,7 +287,7 @@ def chat_stream_wrapper(wrapped, instance, args, kwargs): for key, value in span_attributes.items(): span.set_attribute(key, value) except Exception as e: - logger.debug(f"Error extracting attributes from params dict: {e}") + logger.warning(f"Error extracting attributes from params dict: {e}") span.set_attribute(SpanAttributes.LLM_REQUEST_STREAMING, True) diff --git a/agentops/instrumentation/providers/mem0/instrumentor.py b/agentops/instrumentation/providers/mem0/instrumentor.py index bf191d5b6..29a8df2cf 100644 --- a/agentops/instrumentation/providers/mem0/instrumentor.py +++ b/agentops/instrumentation/providers/mem0/instrumentor.py @@ -265,6 +265,6 @@ def _custom_unwrap(self, **kwargs): class_method = method_config["class_method"] unwrap(package, class_method) except Exception as e: - logger.debug(f"Failed to unwrap {package}.{class_method}: {e}") + logger.warning(f"Failed to unwrap {package}.{class_method}: {e}") logger.info("Mem0 instrumentation disabled") diff --git a/agentops/instrumentation/providers/openai/instrumentor.py b/agentops/instrumentation/providers/openai/instrumentor.py index 9497d7252..53012de74 100644 --- a/agentops/instrumentation/providers/openai/instrumentor.py +++ b/agentops/instrumentation/providers/openai/instrumentor.py @@ -138,9 +138,9 @@ def _custom_wrap(self, **kwargs): logger.warning(f"[OPENAI INSTRUMENTOR] Error setting up OpenAI streaming wrappers: {e}") else: if not is_openai_v1(): - logger.debug("[OPENAI INSTRUMENTOR] Skipping custom wrapping - not using OpenAI v1") + pass if not self._tracer: - logger.debug("[OPENAI INSTRUMENTOR] Skipping custom wrapping - no tracer available") + pass def _create_metrics(self, meter: Meter) -> Dict[str, Any]: """Create metrics for OpenAI instrumentation.""" diff --git a/agentops/instrumentation/providers/openai/stream_wrapper.py b/agentops/instrumentation/providers/openai/stream_wrapper.py index 15e541d82..e1593e88b 100644 --- a/agentops/instrumentation/providers/openai/stream_wrapper.py +++ b/agentops/instrumentation/providers/openai/stream_wrapper.py @@ -357,7 +357,6 @@ def chat_completion_stream_wrapper(tracer, wrapped, instance, args, kwargs): # Add stream_options if it doesn't exist if "stream_options" not in kwargs: kwargs["stream_options"] = {"include_usage": True} - logger.debug("[OPENAI WRAPPER] Adding stream_options.include_usage=True to get token counts") # If stream_options exists but doesn't have include_usage, add it elif isinstance(kwargs["stream_options"], dict) and "include_usage" not in kwargs["stream_options"]: kwargs["stream_options"]["include_usage"] = True @@ -623,7 +622,6 @@ def responses_stream_wrapper(tracer, wrapped, instance, args, kwargs): # If not streaming, just call the wrapped method directly # The normal instrumentation will handle it if not is_streaming: - logger.debug("[RESPONSES API WRAPPER] Non-streaming call, delegating to normal instrumentation") return wrapped(*args, **kwargs) # Only create span for streaming responses @@ -699,7 +697,6 @@ async def async_responses_stream_wrapper(tracer, wrapped, instance, args, kwargs # If not streaming, just call the wrapped method directly # The normal instrumentation will handle it if not is_streaming: - logger.debug("[RESPONSES API WRAPPER] Non-streaming call, delegating to normal instrumentation") return await wrapped(*args, **kwargs) # Only create span for streaming responses @@ -755,7 +752,6 @@ async def async_responses_stream_wrapper(tracer, wrapped, instance, args, kwargs response = await wrapped(*args, **kwargs) # For streaming, wrap the stream - logger.debug("[RESPONSES API WRAPPER] Wrapping streaming response with ResponsesAPIStreamWrapper") wrapped_stream = ResponsesAPIStreamWrapper(response, span, kwargs) return wrapped_stream