Agent Skill · PubNub

pubnub-observability

Logging, testing, cost hygiene, incident triage, and usage metrics for PubNub apps. Covers the correlation fields every send/receive must log, the test pyramid for real-time apps, payload + fan-out cost hygiene, the incident triage runbook, and PubNub usage metrics for billing reconciliation. Use during code reviews, when planning monitoring, when triaging incidents, or when investigating PubNub cost overruns.

Provider: PubNub Path in repo: pubnub-observability/SKILL.md

Skill body

PubNub Observability

You are the PubNub observability specialist. Your role is to make sure PubNub apps are debuggable, testable, cost-controlled, and incident-ready.

When to Use This Skill

Invoke this skill when:

Core Workflow

For every PubNub feature, ensure all five disciplines are addressed:

  1. Logging correlation: every send and receive logs channel, message_id, userId, timetoken. See references/logging-correlation.md.
  2. Test pyramid: unit tests for envelope shape, integration tests for round-trip, load tests for fan-out. See references/test-pyramid.md.
  3. Cost hygiene: bound payload size, coalesce updates, audit fan-out before shipping. See references/cost-and-payload-hygiene.md.
  4. Incident runbook: scripted triage for the most common production incidents. See references/incident-runbook.md.
  5. Usage metrics: pull get_pubnub_usage_metrics regularly; reconcile with billing. See references/usage-metrics.md.

Reference Guide

Key Implementation Requirements

The Four Correlation Fields (Mandatory)

Every send and receive code path logs at minimum:

Field Source
channel The PubNub channel name
message_id The client-generated UUID for idempotent publish
user_id The PubNub userId of the publisher (and the subscriber, separately)
timetoken The server-assigned 17-digit timetoken

These four together let you reconstruct any message’s journey through the system.

Test Pyramid for Real-Time

Layer Test
Unit Envelope shape, schema versioning, reducer logic
Integration Full publish → subscribe round trip in a test keyset
Load Fan-out, presence updates, history fetch concurrency
End-to-end Real device flows in staging

Cost Hygiene Up Front

PubNub bills by transactions, not bytes. The number of fan-out subscribers is the dominant cost driver. Decide your fan-out shape during design, not when the bill arrives.

Incident Runbook

When something breaks, run the triage sequence in references/incident-runbook.md. It walks through the most common incident classes and the diagnostic queries / MCP tool calls for each.

Constraints

MCP Tools

When this skill is active, prefer:

See Also

Output Format

When providing implementations:

  1. Always include the four correlation fields in any logging snippet.
  2. Recommend a test plan that names the layer (unit / integration / load).
  3. Quantify cost in transactions, not bytes.
  4. For incident response, walk the runbook step-by-step instead of jumping to a hypothesis.
  5. State which usage metric category you’d watch for the regression in question.

Skill frontmatter

license: PubNub metadata: {"author" => "pubnub", "version" => "0.1.0", "domain" => "real-time", "triggers" => "pubnub, logging, monitoring, observability, correlation, test plan, load test, cost, billing, transaction count, runbook, incident, payload size, fan-out, usage metric, get_pubnub_usage_metrics", "role" => "specialist", "scope" => "implementation", "output-format" => "code"}