Pre-deployment Checklist
Before deploying to production, ensure you have:- Finalized Configuration: Your
AgentMonitor
configuration is set for production (e.g., appropriatebatchSize
,flushInterval
, andlogLevel
). - Tested Thoroughly: Your application has been tested against a staging environment. See our Testing Guide for comprehensive strategies.
- Managed Secrets: Your
AGENT_GOVERNANCE_API_KEY
and other secrets are managed securely and are not hardcoded.
Environment Configuration
It is critical to manage different configurations for your development, staging, and production environments. The most secure and flexible way to do this is with environment variables.Deployment Strategies
The Agent Governance SDK is a standard Node.js library and can be deployed in any environment that supports Node.js.Serverless (AWS Lambda, Vercel)
Serverless (AWS Lambda, Vercel)
In a serverless environment, the execution context can be frozen or terminated after a request is handled. This makes graceful shutdown even more important.Key Considerations:
shutdown()
is essential: Because serverless functions can terminate at any time, you mustflush()
orshutdown()
the monitor at the end of each invocation that tracks events.- Connection Reuse: Serverless platforms often reuse execution contexts. You can initialize the monitor outside of your handler function to reuse the instance across invocations, but be mindful of flushing data.
Containers (Docker, Kubernetes)
Containers (Docker, Kubernetes)
Deploying with containers is a robust way to manage your application and its dependencies.Key Considerations:
- Dockerfile: Ensure your
Dockerfile
correctly installs dependencies (npm ci --only=production
) and copies necessary files. - Environment Variables: Pass your API key and other configurations to the container using environment variables (
-e
flag in Docker orenv
in Kubernetes manifests). - Health Checks: Configure Kubernetes liveness and readiness probes for your application.
- Graceful Shutdown: Kubernetes sends a
SIGTERM
signal to pods before termination. Your application must handle this signal to callmonitor.shutdown()
.
Traditional Servers (EC2, Virtual Machines)
Traditional Servers (EC2, Virtual Machines)
When deploying on a traditional virtual machine, using a process manager like PM2 is highly recommended.Key Considerations:
- Process Manager: Use PM2 to manage your Node.js process, handle restarts, and manage logs.
- Graceful Shutdown with PM2: PM2 sends
SIGINT
to your application, which you can catch to triggermonitor.shutdown()
. - Environment Configuration: Use a
.env
file or the OS’s environment to manage secrets.