add-custom-metrics-to-your-application

add-custom-metrics-to-your-application is a cursor rule for Cursor from PaulJPhilp/EffectPatterns. It costs 389 tokens per session, scanned A, original, MIT.

A TypeScript rule for defining and updating custom application measurements with Effect's Metric module.

In plain words
What is it for?
Use it to count processed jobs, track current users, and record request durations with counters, gauges, and histograms.
Why use it?
It records business and performance information that can be monitored over time.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/pauljphilp/effectpatterns/add-custom-metrics-to-your-application
Clone the repo
git clone --depth 1 https://github.com/PaulJPhilp/EffectPatterns

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for add-custom-metrics-to-your-application

README.md
[![agentmods](https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/add-custom-metrics-to-your-application.svg)](https://agentmods.dev/rules/pauljphilp/effectpatterns/add-custom-metrics-to-your-application)
Your own site
<a href="https://agentmods.dev/rules/pauljphilp/effectpatterns/add-custom-metrics-to-your-application"><img src="https://agentmods.dev/badge/rules/pauljphilp/effectpatterns/add-custom-metrics-to-your-application.svg" alt="Measured on agentmods" height="20"></a>
Per session 389 This file is loaded in full into every session.
When invoked 389 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00389 $0.00389
Opus 5 $0.00195 $0.00195
Sonnet 5 $0.00078 $0.00078
Haiku 4.5 $0.00039 $0.00039

Measured 6d ago against content hash 50d8fd180b3a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

add-custom-metrics-to-your-application scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

content/published/rules/cursor/add-custom-metrics-to-your-application.mdc · 49 lines

What it actually says

description: Use Effect's Metric module to define and update custom metrics for business and performance monitoring. globs: "**/*.ts" alwaysApply: true

Add Custom Metrics to Your Application

Rule: Use Effect's Metric module to define and update custom metrics for business and performance monitoring.

Example

import { Effect, Metric } from "effect";

// Define a counter metric for processed jobs
const jobsProcessed = Metric.counter("jobs_processed");

// Increment the counter when a job is processed
const processJob = Effect.gen(function* () {
  // ... process the job
  yield* Effect.log("Job processed");
  yield* Metric.increment(jobsProcessed);
});

// Define a gauge for current active users
const activeUsers = Metric.gauge("active_users");

// Update the gauge when users sign in or out
const userSignedIn = Metric.set(activeUsers, 1); // Set to 1 (simplified example)
const userSignedOut = Metric.set(activeUsers, 0); // Set to 0 (simplified example)

// Define a histogram for request durations
const requestDuration = Metric.histogram("request_duration", [
  0.1, 0.5, 1, 2, 5,
] as any); // boundaries in seconds

// Record a request duration
const recordDuration = (duration: number) =>
  Metric.update(requestDuration, duration);

Explanation:

  • Metric.counter tracks counts of events.
  • Metric.gauge tracks a value that can go up or down (e.g., active users).
  • Metric.histogram tracks distributions (e.g., request durations).
  • Effect.updateMetric updates the metric in your workflow.

Explanation:
Metrics provide quantitative insight into your application's behavior and performance.
By instrumenting your code with metrics, you can monitor key events, detect anomalies, and drive business decisions.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 49 lines · 389 tokens per session scan A 50d8fd180b3a

Subscribe to this mod's changes

add-custom-metrics-to-your-application is a cursor rule published in the GitHub repository PaulJPhilp/EffectPatterns (796 stars, last pushed 2mo ago), licensed MIT. It adds 389 tokens to every session, about $0.0019 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.