Initial commit: Complete Software Architecture course with 11 modules
- Added comprehensive course structure with 11 modules - Included theoretical content, practical examples, and tasks - Multi-language code examples (Java, Rust, Node.js, Python) - Detailed analysis of architectural approaches and trade-offs - Complete caching strategies documentation - Architecture examples from real-world systems (Twitter, Netflix, Uber) - Structured navigation and learning path - Ready for educational use
This commit is contained in:
commit
15e744da49
107 files changed
+61762
No files matched your search
@@ -0,0 +1,92 @@
|
||||
# Observability
|
||||
|
||||
## Навигация
|
||||
- [🏠 Главная страница курса](../../../README.md)
|
||||
- [📚 Модуль 5](../README.md)
|
||||
|
||||
---
|
||||
|
||||
## Три столпа Observability
|
||||
|
||||
### 1. Metrics (Метрики)
|
||||
- Количественные измерения
|
||||
- Агрегированные данные
|
||||
- Хорошо для мониторинга трендов
|
||||
|
||||
### 2. Logs (Логи)
|
||||
- События с временными метками
|
||||
- Детальная информация
|
||||
- Хорошо для отладки
|
||||
|
||||
### 3. Traces (Трассировки)
|
||||
- Путь запроса через систему
|
||||
- Временные зависимости
|
||||
- Хорошо для анализа производительности
|
||||
|
||||
## Паттерны наблюдаемости
|
||||
|
||||
### 1. Health Checks
|
||||
```java
|
||||
@Component
|
||||
public class HealthIndicator implements HealthIndicator {
|
||||
@Override
|
||||
public Health health() {
|
||||
try {
|
||||
// проверка зависимостей
|
||||
boolean dbHealthy = checkDatabase();
|
||||
boolean cacheHealthy = checkCache();
|
||||
|
||||
if (dbHealthy && cacheHealthy) {
|
||||
return Health.up()
|
||||
.withDetail("database", "UP")
|
||||
.withDetail("cache", "UP")
|
||||
.build();
|
||||
} else {
|
||||
return Health.down()
|
||||
.withDetail("database", dbHealthy ? "UP" : "DOWN")
|
||||
.withDetail("cache", cacheHealthy ? "UP" : "DOWN")
|
||||
.build();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return Health.down(e).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Custom Metrics
|
||||
```java
|
||||
@Component
|
||||
public class BusinessMetrics {
|
||||
private final Counter ordersCreated;
|
||||
private final Timer orderProcessingTime;
|
||||
private final Gauge activeUsers;
|
||||
|
||||
public BusinessMetrics(MeterRegistry meterRegistry) {
|
||||
this.ordersCreated = Counter.builder("orders.created")
|
||||
.description("Total orders created")
|
||||
.register(meterRegistry);
|
||||
|
||||
this.orderProcessingTime = Timer.builder("orders.processing.time")
|
||||
.description("Order processing time")
|
||||
.register(meterRegistry);
|
||||
|
||||
this.activeUsers = Gauge.builder("users.active")
|
||||
.description("Number of active users")
|
||||
.register(meterRegistry, this, obj -> obj.getActiveUsersCount());
|
||||
}
|
||||
|
||||
public void recordOrderCreated() {
|
||||
ordersCreated.increment();
|
||||
}
|
||||
|
||||
public void recordOrderProcessingTime(Duration duration) {
|
||||
orderProcessingTime.record(duration);
|
||||
}
|
||||
|
||||
private int getActiveUsersCount() {
|
||||
// логика подсчета активных пользователей
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user