Scan your whole stack
From OX Research Newsroom
Are you using @loongsuite/cms_metrics?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v1.0.12
@loongsuite/cms_metrics was last scanned on 26 Nov 2026 at version 1.0.12. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 1.0.12 LATEST | 26 Nov 2026 | No rules fired |
| 1.0.12-beta.2 | 5 Nov 2026 | No rules fired |
| 1.0.12-beta.1 | 5 Nov 2026 | No rules fired |
| 1.0.11-beta.1 | 22 Oct 2026 | Not shown |
| 1.0.10 | 28 Sep 2026 | Not shown |
Findings for v1.0.12. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 1.0.12; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
CMS Metrics 是 CMS 可观测性 SDK 的指标能力包。目前提供基础的指标功能探测,为未来的指标采集与导出实现预留接口。这是可观测性三大支柱(追踪、指标、日志)中指标部分的实现基础。
# 使用 anpm (推荐)
anpm add @loongsuite/cms_metrics
# 或使用 npm
npm install @loongsuite/cms_metrics
目前主要提供指标功能的可用性检测:
import { info } from '@loongsuite/cms_metrics';
// 检测指标功能是否可用
const status = info();
console.log(status); // 输出: 'cms_metrics ready'
import {
info,
// 未来可能添加的导出
Meter,
Counter,
Histogram,
Gauge,
MetricExporter
} from '@loongsuite/cms_metrics';
import { info } from '@loongsuite/cms_metrics';
// 检查指标功能状态
const metricsStatus = info();
console.log('Metrics functionality status:', metricsStatus);
// 在应用启动时检查
if (metricsStatus === 'cms_metrics ready') {
console.log('Metrics system is ready');
} else {
console.warn('Metrics system is not available');
}
import { NodeSDK } from '@loongsuite/cms_node_sdk';
import { info } from '@loongsuite/cms_metrics';
const sdk = new NodeSDK({
serviceName: 'my-service'
});
// 启动前检查指标功能
const metricsStatus = info();
console.log('Metrics status before SDK start:', metricsStatus);
sdk.start();
// 启动后再次检查
const postStartStatus = info();
console.log('Metrics status after SDK start:', postStartStatus);
import { info } from '@loongsuite/cms_metrics';
class ApplicationMetrics {
private isMetricsAvailable: boolean;
constructor() {
this.isMetricsAvailable = info() === 'cms_metrics ready';
}
recordCounter(name: string, value: number, labels?: Record<string, string>) {
if (this.isMetricsAvailable) {
// 使用 CMS 指标系统
this.recordWithCMS(name, value, labels);
} else {
// 降级到简单计数
console.log(`[METRIC] ${name}: ${value}`, labels);
}
}
recordHistogram(name: string, value: number, labels?: Record<string, string>) {
if (this.isMetricsAvailable) {
// 使用 CMS 指标系统
this.recordHistogramWithCMS(name, value, labels);
} else {
// 降级处理
console.log(`[HISTOGRAM] ${name}: ${value}`, labels);
}
}
private recordWithCMS(name: string, value: number, labels?: Record<string, string>) {
// 未来实现 CMS 指标记录
console.log(`[CMS-METRIC] ${name}: ${value}`, labels);
}
private recordHistogramWithCMS(name: string, value: number, labels?: Record<string, string>) {
// 未来实现 CMS 直方图记录
console.log(`[CMS-HISTOGRAM] ${name}: ${value}`, labels);
}
}
// 使用示例
const metrics = new ApplicationMetrics();
// 记录请求计数
metrics.recordCounter('http_requests_total', 1, {
method: 'GET',
status: '200',
endpoint: '/api/users'
});
// 记录响应时间
metrics.recordHistogram('http_request_duration_ms', 150, {
method: 'GET',
endpoint: '/api/users'
});
// 未来可能的 API 设计
import {
Meter,
Counter,
Histogram,
Gauge,
BatchMetricProcessor,
PrometheusExporter
} from '@loongsuite/cms_metrics';
// 创建指标记录器
const meter = new Meter('my-service', '1.0.0');
// 创建计数器
const requestCounter = meter.createCounter('http_requests_total', {
description: 'Total number of HTTP requests',
unit: '1'
});
// 创建直方图
const requestDuration = meter.createHistogram('http_request_duration_ms', {
description: 'HTTP request duration in milliseconds',
unit: 'ms',
buckets: [10, 50, 100, 500, 1000, 5000]
});
// 创建仪表盘
const activeConnections = meter.createGauge('active_connections', {
description: 'Number of active connections',
unit: '1'
});
// 记录指标
requestCounter.add(1, { method: 'GET', status: '200' });
requestDuration.record(150, { method: 'GET', endpoint: '/api/users' });
activeConnections.set(42);
// 配置指标处理器
const metricProcessor = new BatchMetricProcessor(
new PrometheusExporter({ port: 9090 }),
{ scheduledDelayMillis: 5000 }
);
import { info } from '@loongsuite/cms_metrics';
import { NodeSDK } from '@loongsuite/cms_node_sdk';
const sdk = new NodeSDK({
serviceName: 'my-service'
});
sdk.start();
// 在追踪上下文中记录指标状态
const tracer = sdk.getTracerManager().getTracer('my-service');
const span = tracer.startSpan('metrics-check');
span.setAttributes({
'metrics.status': info(),
'metrics.available': info() === 'cms_metrics ready'
});
span.end();
// 未来可能的集成方式
import { Meter } from '@loongsuite/cms_metrics';
import { NodeSDK } from '@loongsuite/cms_node_sdk';
const sdk = new NodeSDK({
serviceName: 'my-service'
});
sdk.start();
// 自动关联追踪上下文
const meter = new Meter('my-service', '1.0.0');
const requestCounter = meter.createCounter('http_requests_total');
// 指标会自动包含当前 span 信息
requestCounter.add(1, {
method: 'GET',
status: '200',
trace_id: 'abc123...' // 自动关联
});
// Counter - 请求计数
const requestCounter = meter.createCounter('http_requests_total');
requestCounter.add(1, { method: 'GET', status: '200' });
// Histogram - 响应时间分布
const responseTime = meter.createHistogram('http_response_time_ms');
responseTime.record(150, { endpoint: '/api/users' });
// Gauge - 当前连接数
const connections = meter.createGauge('active_connections');
connections.set(42);
// Summary - 分位数统计
const latency = meter.createSummary('request_latency_ms');
latency.record(100, { service: 'user-service' });
import { info } from '@loongsuite/cms_metrics';
class MetricsMonitor {
private checkInterval: NodeJS.Timeout;
start() {
// 定期检查指标功能状态
this.checkInterval = setInterval(() => {
const status = info();
if (status !== 'cms_metrics ready') {
console.warn('Metrics system status changed:', status);
}
}, 30000); // 每30秒检查一次
}
stop() {
if (this.checkInterval) {
clearInterval(this.checkInterval);
}
}
}
// 好的指标命名
const goodMetrics = {
'http_requests_total': 'HTTP请求总数',
'http_request_duration_ms': 'HTTP请求耗时',
'database_connections_active': '活跃数据库连接数'
};
// 避免的指标命名
const badMetrics = {
'requests': '太模糊',
'time': '不明确',
'connections': '缺少上下文'
};
import { info } from '@loongsuite/cms_metrics';
// 详细的状态检查
function checkMetricsStatus() {
const status = info();
console.log('Metrics status check:', {
status,
timestamp: new Date().toISOString(),
nodeVersion: process.version,
environment: process.env.NODE_ENV
});
return status === 'cms_metrics ready';
}
// 在关键点检查状态
checkMetricsStatus();
@loongsuite/cms_core: 核心类型和接口定义(未来可能)MIT License
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.