observability-instrumentation
Add business metrics using AWS EMF (Embedded Metric Format) to API endpoints. Focus on domain-specific metrics only - AWS AppRunner provides default SLO/SLA…
от VilnaCRM-Org★ 16 звёзд на GitHub
Установить observability-instrumentation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Business Metrics with AWS EMF
Instrument API endpoints with business metrics using AWS CloudWatch Embedded Metric Format (EMF). This skill focuses exclusively on domain-specific metrics - AWS AppRunner already provides infrastructure SLO/SLA metrics automatically.
What This Skill Covers
- Business metrics - Domain events (users created, orders placed, payments processed)
- AWS EMF format - Logs that automatically become CloudWatch metrics
- Event subscribers - Metrics emitted via domain event subscribers (not in handlers)
- Type-safe metrics - Concrete metric classes instead of arrays
- SOLID principles - Single Responsibility (subscribers) + Open/Closed (new metric classes)
What This Skill Does NOT Cover
- Infrastructure metrics - Latency, error rates, RPS (AWS AppRunner provides these)
- SLO/SLA metrics - Availability, response times (AWS AppRunner provides these)
- Distributed tracing - Use AWS X-Ray integration instead
When to Use This Skill
Use this skill when:
- Implementing new API endpoints that have business significance
- Adding domain events that should trigger metric emission
- Tracking domain events for analytics and business intelligence
- Building dashboards for business KPIs
User Service defaults: use
Endpoint=Userwith operations likecreate(registration),update(profile changes), andrequest-password-reset; run checks viamake <command>; keep Domain entities free of framework/validation concerns.
Architecture Overview
Business metrics follow these patterns:
- Metric classes - Each metric type is a concrete class extending
BusinessMetric - Event subscribers - Metrics are emitted via domain event subscribers (not hardcoded in handlers)
- Symfony logger - EMF output goes through Monolog with a custom EMF formatter
- No arrays - All metric configuration uses typed objects, not arrays
- Collections - Multiple metrics use
MetricCollection, not arrays
SOLID Principles in Observability
Single Responsibility Principle (SRP)
Each class has ONE responsibility:
| Class | Responsibility |
|---|---|
UsersCreatedMetric |
Define metric name, value, dimensions |
UserCreatedMetricsSubscriber |
Listen to event, emit metric |
AwsEmfBusinessMetricsEmitter |
Format and write EMF logs |
MetricCollection |
Hold multiple metrics for batch emission |
Anti-pattern: Metrics emitted directly in command handlers (violates SRP - handler should only handle commands)
Open/Closed Principle (OCP)
- Open for extension: Add new metrics via new classes
- Closed for modification: Don't change existing metric/emitter code
// ✅ GOOD: Add new metric by creating new class
final readonly class OrdersPlacedMetric extends EndpointOperationBusinessMetric { ... }
// ❌ BAD: Modify existing emitter to handle new metric type
Why Event Subscribers (Not Handler Injection)
// ❌ BAD: Metrics in command handler (violates SRP)
final class CreateUserHandler
{
public function __construct(
private UserRepository $repository,
private BusinessMetricsEmitterInterface $metrics // Wrong!
) {}
}
// ✅ GOOD: Metrics in dedicated event subscriber
final class UserCreatedMetricsSubscriber implements DomainEventSubscriberInterface
{
public function __invoke(UserCreatedEvent $event): void
{
$this->metricsEmitter->emit($this->metricFactory->create());
}
}
Benefits:
- Handler focuses on domain logic only
- Metrics emission is decoupled and testable
- Easy to add/remove metrics without touching business logic
- Multiple subscribers can react to same event
Type-Safe Metric Class Hierarchy
BusinessMetric (abstract)
├── EndpointOperationBusinessMetric (abstract) - for metrics with Endpoint/Operation dimensions
│ ├── UsersCreatedMetric
│ ├── UsersUpdatedMetric
│ ├── UsersDeletedMetric
│ └── EndpointInvocationsMetric
└── (other base classes for different dimension patterns)
MetricDimensionsInterface
├── EndpointOperationMetricDimensions - Endpoint + Operation
└── (custom dimensions for specific metrics)
MetricDimensions - typed collection of MetricDimension objects
MetricDimension - key/value pair
MetricUnit (enum)
├── COUNT, NONE, SECONDS, MILLISECONDS, BYTES, PERCENT
MetricCollection - typed collection implementing IteratorAggregate, Countable
Why no arrays?
| Arrays | Typed Classes |
|---|---|
| No type safety | Full type checking |
| No IDE autocomplete | IDE support |
| Runtime errors | Compile-time errors |
| Hard to refactor | Easy to refactor |
| No encapsulation | Validation in constructor |
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- examples/instrumented-command-handler.md
- reference/metrics-patterns.md
- reference/pr-evidence-guide.md
- reference/quick-start.md
- reference/structured-logging.md
FAQ
Что делает скилл observability-instrumentation?
Add business metrics using AWS EMF (Embedded Metric Format) to API endpoints. Focus on domain-specific metrics only - AWS AppRunner provides default SLO/SLA metrics. Use when implementing new endpoints, adding command handlers, or instrumenting business events.
Как установить скилл observability-instrumentation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл observability-instrumentation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…