v1.6.0
Adds two complementary observability surfaces to etag.Transport and
removes the single-purpose WithDriftDetected callback (BREAKING). Drift
transitions are now delivered via the unified WithEventCallback hook
as KindDriftDetected / KindDriftRecovered events; the full
DriftEvent payload remains available on evt.DriftEvent.
Added
etag.Statsgains four per-Outcome counters:TotalHits,
TotalMisses,TotalStores,TotalBypasses. All atomic, monotonic
over the Transport's lifetime, read viaStats()without taking the
driftMu mutex (the existing brief lock for{Degraded, DegradedAt}
consistency is unchanged). Lets consumers compute hit-rate /
store-rate / bypass-rate by pollingStats()at any cadence, without
bumping the slog handler toLevelDebugto scrapeetag_eventrecords
on the hot path.TotalBypassesaggregates all four uncached
pass-through paths (bypass_oversize,bypass_noncacheable, both
no_etag_headersites). Rare error and invalidation outcomes
(get_error,store_error,remove_error,invalidated_gone) remain
observable via slog at INFO/WARN level.etag.WithEventCallback(cb func(ctx context.Context, evt etag.Event))
for per-call attribution. The callback fires on every cache decision,
validation outcome, store/invalidation, and drift transition with the
request URL, normalised path template, and Kind-specific fields.etag.Eventstruct andetag.Kindtype with 14 constants matching
the existing slogkindattribute values. Drift kinds drop the
etag_prefix that the slog kind attributes carry, for naming
consistency with the bareetag_eventkinds.
Removed (BREAKING)
etag.WithDriftDetected(cb func(DriftEvent)) Option. Use
etag.WithEventCallback(cb)and filter on
evt.Kind == etag.KindDriftDetected || evt.Kind == etag.KindDriftRecovered.
The fullDriftEventpayload remains onevt.DriftEvent. See
MIGRATION.md "v1.6: per-call event attribution" for a copy-paste swap.- Slog event
drift_callback_panic. The previous version used a
recover()guard around the drift callback; v1.6 does not catch
panics fromWithEventCallback, so the corresponding slog event no
longer fires. Panics propagate up throughRoundTrip.
Documentation
MIGRATION.mdgains a "v1.6: per-call event attribution" recipe
showingWithEventCallbackctx propagation, repo extraction from
Event.URL, and the per-page callback fan-out under thepages
package.README.mdline 503 now referencesStats's per-Outcome counters
and theWithEventCallbackhook.PROPOSALS.mdupdates the observability-roadmap row to mark
per-call event callbacks as Implemented.- Godoc on the
Transporttype (etag/transport.go:90-91) and on
theStatsstruct (etag/drift.go:55-56) updated to reference
the new surfaces. - Slog event allowlist comment at
etag/transport.go:3-18updated:
drift_callback_panicremoved (the recover guard is gone). etag/drift.go:1-9package prologue updated: drift transitions are
observable viaWithEventCallback.