|
| 1 | +# RIE Telemetry Package |
| 2 | + |
| 3 | +The RIE (Runtime Interface Emulator) telemetry package provides Telemetry API. |
| 4 | + |
| 5 | +## Architecture Overview |
| 6 | + |
| 7 | +``` |
| 8 | +┌─────────────────┐ ┌─────────────────┐ ┌──────────────────┐ |
| 9 | +│ EventsAPI │ │ LogsEgress │ │ SubscriptionAPI │ |
| 10 | +│ │ │ │ │ │ |
| 11 | +│ • Platform │ │ • Runtime logs │ │ • Subscription │ |
| 12 | +│ events │ │ • Extension │ │ management │ |
| 13 | +│ • Lifecycle │ │ logs │ │ • Schema │ |
| 14 | +│ events │ │ • Log capture │ │ validation │ |
| 15 | +└─────────┬───────┘ └─────────┬───────┘ └──────────┬───────┘ |
| 16 | + │ │ │ |
| 17 | + └──────────────┬───────────────────────────────┘ |
| 18 | + │ |
| 19 | + ┌────▼────┐ |
| 20 | + │ Relay │ |
| 21 | + │ │ |
| 22 | + │ Event │ |
| 23 | + │ Broker │ |
| 24 | + └────┬────┘ |
| 25 | + │ |
| 26 | + ┌──────────────┼──────────────┐ |
| 27 | + │ │ │ |
| 28 | + ┌─────▼─────┐ ┌─────▼─────┐ ┌─────▼─────┐ |
| 29 | + │Subscriber │ │Subscriber │ │Subscriber │ |
| 30 | + │ A │ │ B │ │ C │ |
| 31 | + └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ |
| 32 | + │ │ │ |
| 33 | + ┌─────▼─────┐ ┌─────▼─────┐ ┌─────▼─────┐ |
| 34 | + │TCP Client │ │HTTP Client│ │TCP Client │ |
| 35 | + └───────────┘ └───────────┘ └───────────┘ |
| 36 | +``` |
| 37 | + |
| 38 | +## Core Components |
| 39 | + |
| 40 | +### 1. EventsAPI (`events_api.go`) |
| 41 | +**Responsibility**: Platform event generation and distribution |
| 42 | + |
| 43 | +The EventsAPI serves as the primary interface for generating and broadcasting AWS Lambda platform events. It implements the `EventsAPI` interface and handles various lifecycle events including initialization, invocation, and error reporting. |
| 44 | + |
| 45 | +### 2. LogsEgress (`logs_egress.go`) |
| 46 | +**Responsibility**: Log capture and forwarding |
| 47 | + |
| 48 | +The LogsEgress component implements the `StdLogsEgressAPI` interface to capture stdout/stderr from both runtime and extensions, forwarding them to telemetry subscribers while maintaining original console output. |
| 49 | + |
| 50 | +### 3. Relay (`relay.go`) |
| 51 | +**Responsibility**: Event broadcasting and subscriber management |
| 52 | + |
| 53 | +The Relay acts as a central event broker, managing subscribers and broadcasting events to all registered telemetry consumers. |
| 54 | + |
| 55 | +### 4. SubscriptionAPI (`subscription_api.go`) |
| 56 | +**Responsibility**: Subscription management and validation |
| 57 | + |
| 58 | +The SubscriptionAPI handles telemetry subscription requests, validates them against JSON schemas, and manages the subscription lifecycle. |
| 59 | + |
| 60 | +## Internal Components |
| 61 | + |
| 62 | +### 1. Subscriber (`internal/subscriber.go`) |
| 63 | +**Responsibility**: Event batching and delivery |
| 64 | + |
| 65 | +Each subscriber represents a telemetry consumer and manages efficient event delivery through batching and asynchronous processing. |
| 66 | + |
| 67 | +### 2. Client (`internal/client.go`) |
| 68 | +**Responsibility**: Protocol-specific event delivery |
| 69 | + |
| 70 | +The client abstraction provides protocol-specific implementations for delivering events to telemetry consumers. |
| 71 | + |
| 72 | +### 3. Batch (`internal/batch.go`) |
| 73 | +**Responsibility**: Event collection and timing |
| 74 | + |
| 75 | +The batch component manages collections of events with size and time-based flushing logic. |
| 76 | + |
| 77 | +### 4. Types (`internal/types.go`) |
| 78 | +**Responsibility**: Type definitions and constants |
| 79 | + |
| 80 | +Centralized type definitions for protocols, event categories, and configuration structures. |
| 81 | + |
| 82 | +## Event Flow |
| 83 | + |
| 84 | +### 1. Subscription Flow |
| 85 | +``` |
| 86 | +Extension/Agent → SubscriptionAPI → Schema Validation → Subscriber Creation → Relay Registration |
| 87 | +``` |
| 88 | + |
| 89 | +### 2. Event Flow |
| 90 | +``` |
| 91 | +Event Source → EventsAPI → Relay → Subscribers → Batching → Client |
| 92 | +``` |
| 93 | + |
| 94 | +### 3. Log Flow |
| 95 | +``` |
| 96 | +Runtime/Extension → LogsEgress → Console Output + Relay → Subscribers → Batching → Client |
| 97 | +``` |
0 commit comments