:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(logs): show bytes dropped alongside records in drop-rules table (#59557)
Daniel Visca2184bfd6a268
diff --git a/products/logs/frontend/components/LogsSampling/LogsSamplingRulesSortableTable.tsx b/products/logs/frontend/components/LogsSampling/LogsSamplingRulesSortableTable.tsxindex 1970156f0a5a..7795ea56e696 100644--- a/products/logs/frontend/components/LogsSampling/LogsSamplingRulesSortableTable.tsx+++ b/products/logs/frontend/components/LogsSampling/LogsSamplingRulesSortableTable.tsx@@ -25,16 +25,19 @@ import { LemonButton, LemonSwitch } from '@posthog/lemon-ui'import { SortableDragIcon } from 'lib/lemon-ui/icons'import { Tooltip } from 'lib/lemon-ui/Tooltip/Tooltip'-import { compactNumber } from 'lib/utils'+import { compactNumber, humanizeBytes } from 'lib/utils'import { urls } from 'scenes/urls'import { LogsSamplingRuleApi } from 'products/logs/frontend/generated/api.schemas'import { logsSamplingSectionLogic } from './logsSamplingSectionLogic'import { ruleTypeLabel } from './ruleTypeLabel'+import { type SamplingRuleDropTotals } from './samplingRuleDropImpact'type RuleDropImpactCellState = 'loading' | 'ok' | 'error' | 'unknown'+const EMPTY_IMPACT: SamplingRuleDropTotals = { records: 0, bytes: 0 }+interface SortableRowProps {row: LogsSamplingRuleApiorderIndex: number@@ -42,7 +45,7 @@ interface SortableRowProps {ruleEnabledTogglePendingId: string | nullsaveRulesOrderPending: booleanruleDropImpactCellState: RuleDropImpactCellState- dropped24h: number+ impact24h: SamplingRuleDropTotalsonSetRuleEnabled: (ruleId: string, enabled: boolean) => void}@@ -53,7 +56,7 @@ function SortableRow({ruleEnabledTogglePendingId,saveRulesOrderPending,ruleDropImpactCellState,- dropped24h,+ impact24h,onSetRuleEnabled,}: SortableRowProps): JSX.Element {const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({@@ -105,7 +108,11 @@ function SortableRow({<span className="text-muted">…</span>) : ruleDropImpactCellState === 'ok' ? (<span>- ~{compactNumber(dropped24h)} dropped <span className="text-muted">(24h)</span>+ ~{compactNumber(impact24h.records)} dropped+ {impact24h.bytes > 0 && (+ <span className="text-muted"> · ~{humanizeBytes(impact24h.bytes)}</span>+ )}{' '}+ <span className="text-muted">(24h)</span></span>) : (<span@@ -240,8 +247,10 @@ export function LogsSamplingRulesSortableTable(): JSX.Element {<Tooltiptitle={<>- Log lines dropped by this rule in ingestion metrics. Rules scoped to- a service only affect that service; others count across the project.+ Log lines and bytes dropped by this rule in ingestion metrics. Bytes+ appear once any drops have been attributed by the current producer+ (older drops show records only). Rules scoped to a service only+ affect that service; others count across the project.</>}>@@ -275,7 +284,7 @@ export function LogsSamplingRulesSortableTable(): JSX.Element {ruleEnabledTogglePendingId={ruleEnabledTogglePendingId}saveRulesOrderPending={saveRulesOrderPending}ruleDropImpactCellState={ruleDropImpactCellState}- dropped24h={ruleDropImpact[row.id] ?? 0}+ impact24h={ruleDropImpact[row.id] ?? EMPTY_IMPACT}onSetRuleEnabled={setRuleEnabled}/>))}diff --git a/products/logs/frontend/components/LogsSampling/logsSamplingSectionLogic.ts b/products/logs/frontend/components/LogsSampling/logsSamplingSectionLogic.tsindex d7e8163bbd68..464bfc362c25 100644--- a/products/logs/frontend/components/LogsSampling/logsSamplingSectionLogic.ts+++ b/products/logs/frontend/components/LogsSampling/logsSamplingSectionLogic.ts@@ -13,7 +13,7 @@ import {import { LogsSamplingRuleApi } from 'products/logs/frontend/generated/api.schemas'import type { logsSamplingSectionLogicType } from './logsSamplingSectionLogicType'-import { fetchSamplingRuleDropTotalsLast24h } from './samplingRuleDropImpact'+import { type SamplingRuleDropTotals, fetchSamplingRuleDropTotalsLast24h } from './samplingRuleDropImpact'// Background refresh cadence for the per-rule 24h drop counts. The underlying// `app_metrics2` table flushes every ~1 min, so a 30s tick is fast enough that@@ -64,7 +64,7 @@ export const logsSamplingSectionLogic = kea<logsSamplingSectionLogicType>([},],ruleDropImpact: [- {} as Record<string, number>,+ {} as Record<string, SamplingRuleDropTotals>,{loadRuleDropImpact: async (_, breakpoint) => {const rules = values.rules@@ -73,15 +73,7 @@ export const logsSamplingSectionLogic = kea<logsSamplingSectionLogicType>([return {}}await breakpoint(1)- const totals = await fetchSamplingRuleDropTotalsLast24h(ids)- // The list-view cell only renders record count (column space is tight).- // Byte totals are surfaced on the rule detail page; here we collapse- // back to the records number this loader has always exposed.- const out: Record<string, number> = {}- for (const [id, { records }] of Object.entries(totals)) {- out[id] = records- }- return out+ return await fetchSamplingRuleDropTotalsLast24h(ids)},},],