Event Instrumentation & Naming Standard (Practical Guide)
Practical naming rules, required properties, a reusable JSON event contract template, concrete examples, and a 10‑point QA checklist to design reliable, versioned telemetry that supports repeatable analytics and downstream models.
Why this matters
Bad telemetry creates confusion, wasted engineering time, and wrong decisions. Good event instrumentation makes analytics trustworthy, reproducible, and actionable. This guide gives concrete naming conventions, required properties, a JSON event contract template, sample events, and a compact QA checklist so teams can ship telemetry that answers real questions instead of producing accidental artifacts.
Design principles
- Instrument at the source: capture the intent and context where the action happens.
- Design for consumers: analytics, monitoring, and ML models should be able to rely on stable schema and semantics.
- Be explicit about ownership, versioning, and privacy constraints.
- Favor a small, consistent set of mandatory fields and a free-form properties object for extensibility.
- Validate and test events before deploying to production.
Naming convention (recommended)
Use a predictable, dot-separated entity.action.object pattern. Use lowercase letters, dots as separators, and short, meaningful words.
Pattern: entity.action.object (where object is optional when action applies to the entity directly)
- Examples:
order.created,cart.item.added,user.password.reset_requested,file.upload.failed. - Use verbs for actions (
created, updated, deleted, started, completed, failed). - Prefer nouns for entities (
order, cart, user, file, session). - Avoid embedding implementation details (e.g., avoid names that include queue names, internal module names, or SDK specifics).
Event vs. Metric
Events are discrete occurrences (a user clicked, an order was created). Metrics are aggregated measurements derived from events (counts, rates, latencies). Capture events with rich context so metrics can be computed downstream. Do not conflate the two:
- Event: contains timestamp, identifiers, and properties describing the occurrence.
- Metric: often stored as an aggregated timeseries (count, sum, gauge) and should be produced from event streams or instrumentation libraries where appropriate.
Mandatory event properties (contract fundamentals)
Every tracked event should include this minimal set. Types shown in parentheses.
- event_name (string) — follows naming convention, e.g.,
order.created. - event_id (string, UUID) — unique per event for deduplication and tracing.
- timestamp (string, ISO 8601 UTC) — when the event occurred.
- schema_version (string) — event contract version, e.g.,
v1or semantic like1.0. - source (string) — service, app, device, or component producing the event.
- environment (string) — e.g.,
prod,staging,dev. - user_id (string|null) — stable user identifier when available; null when anonymous.
- context (object) — session_id, locale, platform, app_version, tenant_id, ip_hash (if needed), and privacy flags.
- properties (object) — event-specific payload; keep properties focused and documented.
- sampling_rate (number|null) — when events are sampled; helps consumers interpret counts.
Event contract template (JSON)
{
"event_name": "order.created",
"event_id": "uuid-v4",
"timestamp": "2024-08-25T14:23:12Z",
"schema_version": "1.0",
"source": "checkout-service",
"environment": "prod",
"user_id": "user-12345",
"context": {
"session_id": "sess-6789",
"platform": "web",
"app_version": "2024.5.2",
"tenant_id": "tenant-9",
"privacy_level": "standard"
},
"properties": {
"order_id": "ord-4321",
"total_amount": 129.95,
"currency": "USD",
"items": [ { "sku": "SKU-1", "qty": 2 } ]
},
"sampling_rate": null
}
Concrete examples
order.created — properties: order_id, total_amount, currency, payment_method, items_count
cart.item.added — properties: cart_id, item_sku, qty, price, user_logged_in
file.upload.failed — properties: file_name, file_size_bytes, error_code, retryable
Versioning and schema evolution
- Include
schema_versionon every event. - Support additive changes (new optional fields) and avoid renaming or changing field semantic meaning without bumping the schema version.
- Provide a deprecation policy: announce removals/changes, maintain backward compatibility for a defined period, and provide mapping guidance for consumers.
Privacy, security, and compliance
- Never send raw PII unless explicitly required and approved. Use hashes, pseudonyms, or tokens when possible.
- Include explicit privacy flags in
contextto indicate consent, retention limits, or GDPR/CCPA constraints. - Document retention expectations and have processes for data deletion requests.
10‑item QA checklist before shipping instrumentation
- Does the event_name follow the naming convention and include the right entity and action?
- Is event_id unique and generated at the producer (UUID preferred)?
- Is timestamp present, correct, and in ISO 8601 UTC?
- Is schema_version set and does the consumer contract exist in the registry?
- Are required fields present and typed correctly (user_id, context, properties)?
- Have privacy risks been evaluated and PII handling approved?
- Has the event been validated using a JSON schema or automated test harness in staging?
- Is there an owner and consumer list for the event, with documented expectations?
- Is sampling documented and correctly reported (sampling_rate)?
- Has consumer sign‑off been obtained (analytics, monitoring, ML) and are dashboards/tests updated to use the new event?
Operational guidance
- Set up schema validation and alerting on production schema drift or missing required fields.
- Run end-to-end tests that send synthetic events to the pipeline and validate downstream consumption.
- Provide an event registry (readable catalog) with examples, owners, and version history.
- Monitor counts and characteristic distributions after rollout to detect unexpected changes.
Common mistakes to avoid
- Names that embed implementation details or are inconsistent across teams.
- Overpopulating properties with ephemeral internal IDs or huge payloads.
- Shipping events without schema_version or clear ownership.
- Failing to account for sampling when interpreting counts.
Next steps
Adopt this contract as a baseline, publish an event registry, and run the 10‑item QA checklist as part of your CI/CD checks for services that produce telemetry. Consider creating an interactive checklist for teams to document and submit event contracts for review (see capability suggestions below).
Discussion
Comments and conversation will live here.