变差发布 v1.4 后 · 3 分钟前
POST /api/checkout
212 → 486 ms +129 %
95% 的调用低于此值,发布前后对比
- http486 ms+129 %
- db.query74 ms±0 %
- payment.charge402 ms+191 %
← 被你的发布拖慢的代码块
按端点监控延迟每次发布都与上一次对比自动找出变慢的代码块
01
工作原理。
测量
包裹一个路由或代码块。每次调用约一微秒,无需任何配置。
发布
新版本拥有自己的数据。wshapnin 会在每张图表上标出这次发布。
对比
它每分钟把最近 15 分钟与之前几个小时对比,并标出变差的部分。
async with wshapnin.timer("http", labels={"endpoint": "GET /api/products"}, version="1.3"):
async with wshapnin.timer("db.query"):
rows = await load_products()
wshapnin.record("browser.roundtrip", 182.4, labels={"endpoint": "GET /api/products"})pip install wshapnin · Python 3.10+
import * as wshapnin from "wshapnin";
const http = wshapnin.timer("http", { labels: { endpoint: "GET /api/products" }, version: "1.3" });
const query = wshapnin.timer("db.query");
app.get("/api/products", async (req, res) => {
const rows = await http.run(() => query.run(() => loadProducts()));
res.json(rows);
});
// every route at once: app.use(wshapnin.express()), Fastify: app.register(wshapnin.fastify())npm install wshapnin · Node.js 22+ · 浏览器耗时(record)目前仅支持 Python
func products(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
defer wshapnin.Measure(&ctx, "http",
wshapnin.WithLabels(wshapnin.Labels{"endpoint": "GET /api/products"}),
wshapnin.WithVersion("1.3"))(nil)
ctx, end := wshapnin.Start(ctx, "db.query")
rows, err := loadProducts(ctx)
end(err)
// …
}
// every route at once: http.ListenAndServe(":8080", wshapnin.Middleware(mux))go get github.com/princteq/wshapnin-sdk/go · Go 1.23+ · 浏览器耗时(record)目前仅支持 Python
static HTTP: wshapnin::Timer = wshapnin::Timer::new("http")
.labels(&[("endpoint", "GET /api/products")])
.version("1.3");
static QUERY: wshapnin::Timer = wshapnin::Timer::new("db.query");
async fn products() -> Json<Vec<Product>> {
HTTP.run(async { Json(QUERY.run(load_products()).await) }).await
}
// every route at once: Router::new().layer(wshapnin::axum::layer())cargo add wshapnin · Rust 1.85+ · 浏览器耗时(record)目前仅支持 Python
03
在你的服务上试试。
告诉我们你的技术栈,我们为你开通一个项目:30 天免费,用你自己的端点。你的服务只需一个变量(项目密钥)即可发送数据。
30 天免费,用你自己的端点。