AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

instrument-logs

Add PostHog log capture to track application logs. Use after implementing features or reviewing PRs to ensure meaningful log events are captured with structured properties. Also handles initial OTLP exporter setup if not yet configured.

Original source
posthog
License
MIT
Pinned revision
cac7c80a9e5b73484d18eda1bffb47297c938e0c

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read posthog--instrument-logs at revision cac7c80a9e5b73484d18eda1bffb47297c938e0c, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 19

references/best-practices.md · 24000

ages

  • Only scalar values (strings, numbers, booleans) are logged. No raw objects, large arrays, or full API response bodies
  • Context is accumulated throughout the request lifecycle (e.g., cart_total added once calculated, payment_id added later)

Business and trace context

  • The "Who": posthogDistinctId, org_id, account_tier, or equivalent
  • The "What": order_id, transaction_id, feature_flag_variants, or equivalent
  • The "Where": service.name, service.version, deployment.environment set as OTel resource attributes
  • Trace IDs: OpenTelemetry trace_id is attached so you can jump from logs to traces
  • Session IDs: PostHog session_id is included to enable Session Replay linking

Levels and sampling

  • Log levels are correct: INFO for request completion, WARN for retries or non-breaking issues, ERROR only if someone needs to act
  • Health checks (/healthz) and load balancer pings are excluded or sampled down
  • A sampling strategy is in place (or planned) for high-traffic services
  • A try/finally or global error handler flushes log context if the process dies mid-request

Security and compliance

  • No secrets: API keys, Bearer tokens, and passwords are scrubbed
  • PII is masked: emails, physical addresses, and credit card numbers are hashed or removed per GDPR/HIPAA requirements
  • Request/response bodies are not logged (to avoid capturing sensitive user data)
  • Field names and value types are treated as a stable schema (changes are communicated)
  • Consider enabling automatic PII scrubbing as a safety net for accidental leaks
  • Link logs to Session Replays for full user context