Summary
Add OpenTelemetry metrics for ActivityPub collection dispatch and pagination, including request counts, dispatch duration, and collection page sizes.
Current state
Fedify already creates spans for activitypub.dispatch_collection and activitypub.dispatch_collection_page. The OpenTelemetry documentation also lists attributes such as activitypub.collection.total_items, fedify.collection.cursor, and fedify.collection.items.
Those spans help debug a single collection request. Operators still need aggregate metrics to see whether collection endpoints are slow, whether pagination is producing unexpectedly large pages, or whether custom collection dispatchers are a source of latency.
Proposed solution
Once #619 adds metrics support, add metrics around collection and collection-page dispatch.
Proposed instruments:
activitypub.collection.request: counter, incremented when Fedify dispatches a collection or collection page.
activitypub.collection.dispatch.duration: histogram, recording dispatcher duration in milliseconds.
activitypub.collection.page.items: histogram, recording the number of items returned in a collection page.
activitypub.collection.total_items: histogram, recording reported collection size where available.
Proposed attributes:
activitypub.collection.kind: followers, following, liked, featured, outbox, or custom, where Fedify can classify the collection.
activitypub.collection.page: true or false.
activitypub.collection.result: served, not_found, not_acceptable, or error.
fedify.collection.dispatcher: built_in or custom.
Do not include actor identifiers, collection IDs, cursor values, object IDs, or route parameter values as metric attributes.
Scope
- Instrument built-in and custom collection dispatcher paths in
@fedify/fedify.
- Record page item counts where Fedify has the page items in memory.
- Record total item counts where the dispatcher reports them without extra work.
- Keep remote collection fetching and conversation backfill out of scope.
- Update
docs/manual/opentelemetry.md with metric names, units, and cardinality guidance.
Acceptance criteria
- Collection and collection-page dispatch counts are emitted for successful and failed requests.
- Dispatcher duration is recorded for collection and collection-page paths.
- Page item count histograms are recorded without exposing item IDs or cursors.
- Total item count histograms are recorded only when the value is already available.
- Tests cover at least one collection and one collection page path.
- Documentation explains which collection kinds are classified and how custom collections are labeled.
Open questions
- Should collection kind use existing dispatcher names or a smaller normalized taxonomy?
- Should
activitypub.collection.total_items be a histogram, gauge, or span-only attribute?
- Should collection metrics include outbox serving metrics, or should outbox be tracked only through ActivityPub delivery metrics?
Summary
Add OpenTelemetry metrics for ActivityPub collection dispatch and pagination, including request counts, dispatch duration, and collection page sizes.
Current state
Fedify already creates spans for
activitypub.dispatch_collectionandactivitypub.dispatch_collection_page. The OpenTelemetry documentation also lists attributes such asactivitypub.collection.total_items,fedify.collection.cursor, andfedify.collection.items.Those spans help debug a single collection request. Operators still need aggregate metrics to see whether collection endpoints are slow, whether pagination is producing unexpectedly large pages, or whether custom collection dispatchers are a source of latency.
Proposed solution
Once #619 adds metrics support, add metrics around collection and collection-page dispatch.
Proposed instruments:
activitypub.collection.request: counter, incremented when Fedify dispatches a collection or collection page.activitypub.collection.dispatch.duration: histogram, recording dispatcher duration in milliseconds.activitypub.collection.page.items: histogram, recording the number of items returned in a collection page.activitypub.collection.total_items: histogram, recording reported collection size where available.Proposed attributes:
activitypub.collection.kind:followers,following,liked,featured,outbox, orcustom, where Fedify can classify the collection.activitypub.collection.page:trueorfalse.activitypub.collection.result:served,not_found,not_acceptable, orerror.fedify.collection.dispatcher:built_inorcustom.Do not include actor identifiers, collection IDs, cursor values, object IDs, or route parameter values as metric attributes.
Scope
@fedify/fedify.docs/manual/opentelemetry.mdwith metric names, units, and cardinality guidance.Acceptance criteria
Open questions
activitypub.collection.total_itemsbe a histogram, gauge, or span-only attribute?