Skip to content

Latest commit

 

History

History
67 lines (53 loc) · 1.7 KB

manual-metric-tap-to-track.md

File metadata and controls

67 lines (53 loc) · 1.7 KB

manualMetricTapToTrack

Suggests Effect.trackSuccesses/trackErrors/trackDefects when an Effect.tap/tapError/tapDefect only updates a metric

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v4
Diagnostic codes TS377154
Language Service name manualMetricTapToTrack
Oxlint name effecttsgo/manual-metric-tap-to-track

Preview

import { Effect, Metric } from "effect"

const responseSize = Metric.gauge("response_size")

declare const handleRequest: Effect.Effect<number, Error>

export const instrumented = handleRequest.pipe(Effect.tap((size) => Metric.update(responseSize, size)))
/**
                                               ^^^^^^^^^^ effecttsgo(manual-metric-tap-to-track): `Effect.trackSuccesses` expresses recording a metric on every success directly.
*/

Language Service Configuration

See the Language Service setup guide for installation instructions.

{
  "$schema": "./node_modules/@effect/tsgo/schema.json",
  "compilerOptions": {
    "plugins": [
      {
        "name": "@effect/language-service",
        "diagnosticSeverity": {
          "manualMetricTapToTrack": "warning"
        }
      }
    ]
  }
}

Oxlint Configuration

See the Oxlint setup guide for installation and patching instructions.

{
  "$schema": "./node_modules/@effect/tsgo/oxlint-schema.json",
  "options": {
    "typeAware": true
  },
  "plugins": ["effecttsgo"],
  "rules": {
    "effecttsgo/manual-metric-tap-to-track": "warn"
  }
}