configure_tracing
Configure distributed tracing settings for applications, including sampling rates and URL path exclusions, to control trace collection and optimize 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
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| app_id | Yes | ||
| enabled | Yes | ||
| sample_rate | No | ||
| excluded_paths | No |
Implementation Reference
- src/mcp_coroot/server.py:2016-2069 (handler)Core handler implementation for the configure_tracing tool. Handles FastMCP type conversion issues by parsing string sample_rate to float and JSON string excluded_paths to list. Builds the config dictionary and calls the Coroot client to update tracing configuration.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-2095 (registration)Registers the 'configure_tracing' tool with the FastMCP server using the @mcp.tool() decorator. Defines the tool schema via function parameters and docstring. Acts as a thin wrapper delegating to the impl function.@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 performs the HTTP POST request to the Coroot API endpoint for updating tracing configuration. Called by the tool handler.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