mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Comprehensive telemetry quality improvements across Sentry and PostHog, grounded in an audit of the live data plus current best-practice research. Sentry: job_id/instance_id tags, operational fingerprinting, PII-safe settings context on bug events, web tag population + extension-noise filtering, an early-crash buffer, http status/method kept on breadcrumbs, and a gated-off-by-default performance-tracing re-enable (tracesSampler that zeroes db/redis/queue-poll root spans + drops the Redis integration) with worker job spans and canonical-host cron monitors. PostHog: history_change SPA pageviews, instance_id super property for fleet rollups, enriched tool_used (formats, byte sizes, is_batch, execution_hint, real error_kind taxonomy), the previously-dead result_saved/batch_processed/ai_bundle_prompted events fired, search click-through, editor + Automate authoring + auth instrumentation, a before_send PII boundary, and minimal opt-in landing-site pageviews.
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildTracesSampler } from "../../../apps/api/src/lib/sentry-tracing.js";
|
|
|
|
const sampler = buildTracesSampler(0.05);
|
|
|
|
describe("buildTracesSampler (the July-incident guard)", () => {
|
|
it("zeroes standalone redis root transactions (BullMQ blocking polls)", () => {
|
|
expect(sampler({ name: "BRPOPLPUSH", attributes: { "db.system": "redis" } })).toBe(0);
|
|
});
|
|
|
|
it("zeroes standalone db root transactions (pg idle pings) by op prefix", () => {
|
|
expect(sampler({ name: "SELECT 1", attributes: { "sentry.op": "db.query" } })).toBe(0);
|
|
expect(sampler({ name: "pg", attributes: { "sentry.op": "db.redis" } })).toBe(0);
|
|
});
|
|
|
|
it("drops queue poll transactions but samples real job executions", () => {
|
|
expect(sampler({ name: "queue.poll", attributes: { "messaging.system": "bullmq" } })).toBe(0);
|
|
expect(
|
|
sampler({ name: "job.process", attributes: { "messaging.system": "bullmq" } }),
|
|
).toBeGreaterThan(0);
|
|
expect(
|
|
sampler({ name: "job resize", attributes: { "messaging.system": "bullmq" } }),
|
|
).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("never samples infra endpoints even as HTTP", () => {
|
|
expect(sampler({ name: "GET /healthz", attributes: { "http.request.method": "GET" } })).toBe(0);
|
|
expect(sampler({ name: "GET /readyz", attributes: { "http.request.method": "GET" } })).toBe(0);
|
|
expect(sampler({ name: "GET /metrics", attributes: { "http.request.method": "GET" } })).toBe(0);
|
|
});
|
|
|
|
it("samples real inbound HTTP at the configured rate", () => {
|
|
expect(
|
|
sampler({
|
|
name: "POST /api/v1/tools/image/resize",
|
|
attributes: { "http.request.method": "POST" },
|
|
}),
|
|
).toBe(0.05);
|
|
});
|
|
|
|
it("respects an explicit parent sampling decision via inheritOrSampleWith", () => {
|
|
expect(
|
|
sampler({
|
|
name: "GET /api/v1/x",
|
|
attributes: { "http.request.method": "GET" },
|
|
inheritOrSampleWith: () => 1,
|
|
}),
|
|
).toBe(1);
|
|
});
|
|
|
|
it("drops anything unrecognized when there is no parent", () => {
|
|
expect(sampler({ name: "mystery", attributes: {} })).toBe(0);
|
|
expect(sampler({})).toBe(0);
|
|
});
|
|
});
|