.claude/skills/metrics-collector/SKILL.md
Guardrails for edits to core/monitoring/metrics-collector.js to preserve Prometheus metric names, labels, cardinality limits, and emission patterns. Use when adding or changing metrics or collectors.
npx skillsauth add thefixer3x/onasis-gateway metrics-collectorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Apply this skill when modifying core/monitoring/metrics-collector.js.
The Metrics Collector provides:
api_requests_totalapi_request_duration_secondsapi_errors_totalapi_error_rateapi_response_size_bytesapi_concurrent_requestscircuit_breaker_statecircuit_breaker_failures_totalrate_limit_hits_totalrate_limit_remainingauth_attempts_totaltoken_refreshes_totalcompliance_violations_totaldata_processing_events_totaltransaction_volume_totaltransaction_value_totalservice_health_statusdependency_health_status200 vs "200").transaction_id labels.user_id labels.request_id labels.timestamp labels.[0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10, 30][100, 1000, 10000, 100000, 1000000, 10000000]Metric examples use the onasis_ prefix (for example, onasis_new_metric_total) as a placeholder. Replace it with your actual project/service prefix (for example, gateway_new_metric_total) and apply that prefix consistently across your metrics.
// Must register with proper name, help, labelNames
this.metrics.metricName = new this.prometheus.Counter({
name: 'metric_name_total',
help: 'Clear description of what this metric measures',
labelNames: ['service', 'endpoint', 'method'],
registers: [this.register]
});
// Must emit events after recording metrics
recordRequest(context) {
this.metrics.requestsTotal.inc(labels);
this.emit('metric:request', context);
}
// Must use consistent label values
const labels = {
service: context.service, // lowercase, snake_case
endpoint: context.endpoint, // /path/to/endpoint format
method: context.method, // uppercase: GET, POST, etc.
status_code: context.statusCode // numeric as string
};
// Must use standard error type classification
getErrorType(statusCode) {
if (statusCode >= 400 && statusCode < 500) return 'client_error';
if (statusCode >= 500) return 'server_error';
return 'unknown_error';
}
// Must use numeric state values for Prometheus
const stateValue = { 'CLOSED': 0, 'OPEN': 1, 'HALF_OPEN': 2 }[state] || 0;
// Add in initializeMetrics()
this.metrics.newMetric = new this.prometheus.Counter({
name: 'onasis_new_metric_total',
help: 'Description of what this measures',
labelNames: ['service', 'type'],
registers: [this.register]
});
recordNewMetric(service, type) {
this.metrics.newMetric.labels(service, type).inc();
this.emit('metric:new_metric', { service, type });
}
this.metrics.newHistogram = new this.prometheus.Histogram({
name: 'onasis_new_histogram_seconds',
help: 'Description',
labelNames: ['service', 'operation'],
buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10],
registers: [this.register]
});
this.metrics.newGauge = new this.prometheus.Gauge({
name: 'onasis_new_gauge',
help: 'Current value of something',
labelNames: ['service'],
registers: [this.register]
});
this.metrics.newGauge.labels('my-service').set(42);
| Component | Integration Method |
|-----------|-------------------|
| Base Client | Emits request, response, error events |
| Compliance Manager | Records compliance violations |
| Version Manager | Version label in request metrics |
| Prometheus | getMetrics() endpoint for scraping |
| Grafana | Query metrics via PromQL |
| Label | Acceptable Values | Max Cardinality | |-------|-------------------|-----------------| | service | Service names | ~50 | | endpoint | API paths | ~200 per service | | method | GET, POST, PUT, DELETE, PATCH | 5 | | status_code | HTTP status codes | ~20 | | error_type | client_error, server_error, unknown_error | 3 | | auth_type | bearer, apikey, basic, hmac, oauth2 | 5 | | regulation | PCI_DSS, GDPR, PSD2, SOX, HIPAA | 5 |
Run these checks before shipping changes:
npm test -- --grep "MetricsCollector"
node -e "const MC = require('./core/monitoring/metrics-collector'); const mc = new MC(); console.log('Metrics registered:', Object.keys(mc.metrics).length);"
node -e "const MC = require('./core/monitoring/metrics-collector'); const mc = new MC(); mc.getMetrics().then(m => console.log(m.substring(0, 500)));"
tools
# Onasis Gateway — Agent & IDE Skill Guide > **Read this file first.** This guide is the primary reference for AI agents (Claude, Cursor, Copilot, etc.) and developers working with the Onasis Gateway API integration repository. It covers all 16 third-party API integrations, Postman MCP setup, auth patterns, environment variables, and recommended workflows. --- ## Table of Contents 1. [Overview](#overview) 2. [Postman MCP Integration](#postman-mcp-integration) 3. [16 API Integrations](#16-api
data-ai
Guardrails for edits to core/versioning/version-manager.js covering semver validation, deprecation, migrations, and compatibility rules. Use when changing version registration or migration handling.
tools
Guardrails for edits to core/abstraction/vendor-abstraction.js that preserve vendor isolation, mappings, fallback selection, and stable client-facing schemas. Use when adding/removing vendors, operations, or schema fields.
tools
Use this skill when adding new methods, tools, or schema changes to the `@lanonasis/mem-intel-sdk`. Trigger when the user wants to extend the SDK with new capabilities, add a new MCP tool to mcp-core, add a new intelligence endpoint, or migrate the behavior_patterns schema. Also trigger when the user says things like "add a new tool to the SDK", "extend mem-intel-sdk", "add behavior X to the MCP server", or "update the SDK schema." Do NOT use for general behavior pattern recording/recall — use the behavior-memory skill for that.