Command Palette

Search for a command to run...

Назад к скиллам
скилл № 83403

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от 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=User with operations like create (registration), update (profile changes), and request-password-reset; run checks via make <command>; keep Domain entities free of framework/validation concerns.


Architecture Overview

Business metrics follow these patterns:

  1. Metric classes - Each metric type is a concrete class extending BusinessMetric
  2. Event subscribers - Metrics are emitted via domain event subscribers (not hardcoded in handlers)
  3. Symfony logger - EMF output goes through Monolog with a custom EMF formatter
  4. No arrays - All metric configuration uses typed objects, not arrays
  5. 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

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • 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), без исполняемых скриптов.

Похожие скиллы

Сравнить observability-instrumentation с