configure_tracing
Enable and manage distributed tracing for applications by configuring trace collection settings, including sampling rate and paths to exclude. Integrates with MCP Server for Coroot to optimize observability and performance monitoring.
Instructions
Configure distributed tracing for an application.
Controls trace collection settings including sampling rate and paths to exclude from tracing.
Args: project_id: The project ID app_id: The application ID enabled: Whether to enable tracing sample_rate: Optional trace sampling rate (0.0-1.0) excluded_paths: Optional list of URL paths to exclude
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ||
| enabled | Yes | ||
| excluded_paths | No | ||
| project_id | Yes | ||
| sample_rate | No |
Implementation Reference
- src/mcp_coroot/server.py:2016-2069 (handler)Core handler implementation for the configure_tracing tool. Handles FastMCP type conversions (string to float/list), constructs config, calls CorootClient.configure_tracing, and manages responses/errors.async def configure_tracing_impl( project_id: str, app_id: str, enabled: bool, sample_rate: Any = None, excluded_paths: Any = None, ) -> dict[str, Any]: """Implementation for configure_tracing tool.""" try: client = get_client() config = {"enabled": enabled} # Handle FastMCP type conversion issue for sample_rate if sample_rate is not None: if isinstance(sample_rate, str): try: sample_rate = float(sample_rate) except ValueError: return { "success": False, "error": f"Invalid sample_rate: {sample_rate}", } config["sample_rate"] = sample_rate # Handle FastMCP type conversion issue for excluded_paths if excluded_paths: if isinstance(excluded_paths, str): try: excluded_paths = json.loads(excluded_paths) if not isinstance(excluded_paths, list): return { "success": False, "error": ( f"excluded_paths must be a list, " f"got {type(excluded_paths).__name__}" ), } except json.JSONDecodeError: return { "success": False, "error": f"Invalid JSON for excluded_paths: {excluded_paths}", } config["excluded_paths"] = excluded_paths result = await client.configure_tracing(project_id, app_id, config) return { "success": True, "message": "Tracing configuration updated successfully", "config": result, } except ValueError as e: return {"success": False, "error": str(e)} except Exception as e: return {"success": False, "error": f"Unexpected error: {str(e)}"}
- src/mcp_coroot/server.py:2072-2096 (registration)FastMCP tool registration with @mcp.tool() decorator. Defines input schema via parameters and delegates execution to configure_tracing_impl.@mcp.tool() async def configure_tracing( project_id: str, app_id: str, enabled: bool, sample_rate: Any = None, excluded_paths: Any = None, ) -> dict[str, Any]: """ Configure distributed tracing for an application. Controls trace collection settings including sampling rate and paths to exclude from tracing. Args: project_id: The project ID app_id: The application ID enabled: Whether to enable tracing sample_rate: Optional trace sampling rate (0.0-1.0) excluded_paths: Optional list of URL paths to exclude """ return await configure_tracing_impl( project_id, app_id, enabled, sample_rate, excluded_paths )
- src/mcp_coroot/client.py:1573-1594 (helper)CorootClient helper method that makes the actual HTTP POST request to the Coroot API to configure tracing for the application.async def configure_tracing( self, project_id: str, app_id: str, config: dict[str, Any] ) -> dict[str, Any]: """Configure tracing for an application. Args: project_id: The project ID app_id: The application ID config: Tracing configuration Returns: Dict containing updated configuration """ # URL encode the app_id in case it contains slashes encoded_app_id = quote(app_id, safe="") response = await self._request( "POST", f"/api/project/{project_id}/app/{encoded_app_id}/tracing", json=config, ) data: dict[str, Any] = response.json() return data