e11y 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +4 -0
- data/.rubocop.yml +69 -0
- data/CHANGELOG.md +26 -0
- data/CODE_OF_CONDUCT.md +64 -0
- data/LICENSE.txt +21 -0
- data/README.md +179 -0
- data/Rakefile +37 -0
- data/benchmarks/run_all.rb +33 -0
- data/config/README.md +83 -0
- data/config/loki-local-config.yaml +35 -0
- data/config/prometheus.yml +15 -0
- data/docker-compose.yml +78 -0
- data/docs/00-ICP-AND-TIMELINE.md +483 -0
- data/docs/01-SCALE-REQUIREMENTS.md +858 -0
- data/docs/ADR-001-architecture.md +2617 -0
- data/docs/ADR-002-metrics-yabeda.md +1395 -0
- data/docs/ADR-003-slo-observability.md +3337 -0
- data/docs/ADR-004-adapter-architecture.md +2385 -0
- data/docs/ADR-005-tracing-context.md +1372 -0
- data/docs/ADR-006-security-compliance.md +4143 -0
- data/docs/ADR-007-opentelemetry-integration.md +1385 -0
- data/docs/ADR-008-rails-integration.md +1911 -0
- data/docs/ADR-009-cost-optimization.md +2993 -0
- data/docs/ADR-010-developer-experience.md +2166 -0
- data/docs/ADR-011-testing-strategy.md +1836 -0
- data/docs/ADR-012-event-evolution.md +958 -0
- data/docs/ADR-013-reliability-error-handling.md +2750 -0
- data/docs/ADR-014-event-driven-slo.md +1533 -0
- data/docs/ADR-015-middleware-order.md +1061 -0
- data/docs/ADR-016-self-monitoring-slo.md +1234 -0
- data/docs/API-REFERENCE-L28.md +914 -0
- data/docs/COMPREHENSIVE-CONFIGURATION.md +2366 -0
- data/docs/IMPLEMENTATION_NOTES.md +2804 -0
- data/docs/IMPLEMENTATION_PLAN.md +1971 -0
- data/docs/IMPLEMENTATION_PLAN_ARCHITECTURE.md +586 -0
- data/docs/PLAN.md +148 -0
- data/docs/QUICK-START.md +934 -0
- data/docs/README.md +296 -0
- data/docs/design/00-memory-optimization.md +593 -0
- data/docs/guides/MIGRATION-L27-L28.md +692 -0
- data/docs/guides/PERFORMANCE-BENCHMARKS.md +434 -0
- data/docs/guides/README.md +44 -0
- data/docs/prd/01-overview-vision.md +440 -0
- data/docs/use_cases/README.md +119 -0
- data/docs/use_cases/UC-001-request-scoped-debug-buffering.md +813 -0
- data/docs/use_cases/UC-002-business-event-tracking.md +1953 -0
- data/docs/use_cases/UC-003-pattern-based-metrics.md +1627 -0
- data/docs/use_cases/UC-004-zero-config-slo-tracking.md +728 -0
- data/docs/use_cases/UC-005-sentry-integration.md +759 -0
- data/docs/use_cases/UC-006-trace-context-management.md +905 -0
- data/docs/use_cases/UC-007-pii-filtering.md +2648 -0
- data/docs/use_cases/UC-008-opentelemetry-integration.md +1153 -0
- data/docs/use_cases/UC-009-multi-service-tracing.md +1043 -0
- data/docs/use_cases/UC-010-background-job-tracking.md +1018 -0
- data/docs/use_cases/UC-011-rate-limiting.md +1906 -0
- data/docs/use_cases/UC-012-audit-trail.md +2301 -0
- data/docs/use_cases/UC-013-high-cardinality-protection.md +2127 -0
- data/docs/use_cases/UC-014-adaptive-sampling.md +1940 -0
- data/docs/use_cases/UC-015-cost-optimization.md +735 -0
- data/docs/use_cases/UC-016-rails-logger-migration.md +785 -0
- data/docs/use_cases/UC-017-local-development.md +867 -0
- data/docs/use_cases/UC-018-testing-events.md +1081 -0
- data/docs/use_cases/UC-019-tiered-storage-migration.md +562 -0
- data/docs/use_cases/UC-020-event-versioning.md +708 -0
- data/docs/use_cases/UC-021-error-handling-retry-dlq.md +956 -0
- data/docs/use_cases/UC-022-event-registry.md +648 -0
- data/docs/use_cases/backlog.md +226 -0
- data/e11y.gemspec +76 -0
- data/lib/e11y/adapters/adaptive_batcher.rb +207 -0
- data/lib/e11y/adapters/audit_encrypted.rb +239 -0
- data/lib/e11y/adapters/base.rb +580 -0
- data/lib/e11y/adapters/file.rb +224 -0
- data/lib/e11y/adapters/in_memory.rb +216 -0
- data/lib/e11y/adapters/loki.rb +333 -0
- data/lib/e11y/adapters/otel_logs.rb +203 -0
- data/lib/e11y/adapters/registry.rb +141 -0
- data/lib/e11y/adapters/sentry.rb +230 -0
- data/lib/e11y/adapters/stdout.rb +108 -0
- data/lib/e11y/adapters/yabeda.rb +370 -0
- data/lib/e11y/buffers/adaptive_buffer.rb +339 -0
- data/lib/e11y/buffers/base_buffer.rb +40 -0
- data/lib/e11y/buffers/request_scoped_buffer.rb +246 -0
- data/lib/e11y/buffers/ring_buffer.rb +267 -0
- data/lib/e11y/buffers.rb +14 -0
- data/lib/e11y/console.rb +122 -0
- data/lib/e11y/current.rb +48 -0
- data/lib/e11y/event/base.rb +894 -0
- data/lib/e11y/event/value_sampling_config.rb +84 -0
- data/lib/e11y/events/base_audit_event.rb +43 -0
- data/lib/e11y/events/base_payment_event.rb +33 -0
- data/lib/e11y/events/rails/cache/delete.rb +21 -0
- data/lib/e11y/events/rails/cache/read.rb +23 -0
- data/lib/e11y/events/rails/cache/write.rb +22 -0
- data/lib/e11y/events/rails/database/query.rb +45 -0
- data/lib/e11y/events/rails/http/redirect.rb +21 -0
- data/lib/e11y/events/rails/http/request.rb +26 -0
- data/lib/e11y/events/rails/http/send_file.rb +21 -0
- data/lib/e11y/events/rails/http/start_processing.rb +26 -0
- data/lib/e11y/events/rails/job/completed.rb +22 -0
- data/lib/e11y/events/rails/job/enqueued.rb +22 -0
- data/lib/e11y/events/rails/job/failed.rb +22 -0
- data/lib/e11y/events/rails/job/scheduled.rb +23 -0
- data/lib/e11y/events/rails/job/started.rb +22 -0
- data/lib/e11y/events/rails/log.rb +56 -0
- data/lib/e11y/events/rails/view/render.rb +23 -0
- data/lib/e11y/events.rb +18 -0
- data/lib/e11y/instruments/active_job.rb +201 -0
- data/lib/e11y/instruments/rails_instrumentation.rb +141 -0
- data/lib/e11y/instruments/sidekiq.rb +175 -0
- data/lib/e11y/logger/bridge.rb +205 -0
- data/lib/e11y/metrics/cardinality_protection.rb +172 -0
- data/lib/e11y/metrics/cardinality_tracker.rb +134 -0
- data/lib/e11y/metrics/registry.rb +234 -0
- data/lib/e11y/metrics/relabeling.rb +226 -0
- data/lib/e11y/metrics.rb +102 -0
- data/lib/e11y/middleware/audit_signing.rb +174 -0
- data/lib/e11y/middleware/base.rb +140 -0
- data/lib/e11y/middleware/event_slo.rb +167 -0
- data/lib/e11y/middleware/pii_filter.rb +266 -0
- data/lib/e11y/middleware/pii_filtering.rb +280 -0
- data/lib/e11y/middleware/rate_limiting.rb +214 -0
- data/lib/e11y/middleware/request.rb +163 -0
- data/lib/e11y/middleware/routing.rb +157 -0
- data/lib/e11y/middleware/sampling.rb +254 -0
- data/lib/e11y/middleware/slo.rb +168 -0
- data/lib/e11y/middleware/trace_context.rb +131 -0
- data/lib/e11y/middleware/validation.rb +118 -0
- data/lib/e11y/middleware/versioning.rb +132 -0
- data/lib/e11y/middleware.rb +12 -0
- data/lib/e11y/pii/patterns.rb +90 -0
- data/lib/e11y/pii.rb +13 -0
- data/lib/e11y/pipeline/builder.rb +155 -0
- data/lib/e11y/pipeline/zone_validator.rb +110 -0
- data/lib/e11y/pipeline.rb +12 -0
- data/lib/e11y/presets/audit_event.rb +65 -0
- data/lib/e11y/presets/debug_event.rb +34 -0
- data/lib/e11y/presets/high_value_event.rb +51 -0
- data/lib/e11y/presets.rb +19 -0
- data/lib/e11y/railtie.rb +138 -0
- data/lib/e11y/reliability/circuit_breaker.rb +216 -0
- data/lib/e11y/reliability/dlq/file_storage.rb +277 -0
- data/lib/e11y/reliability/dlq/filter.rb +117 -0
- data/lib/e11y/reliability/retry_handler.rb +207 -0
- data/lib/e11y/reliability/retry_rate_limiter.rb +117 -0
- data/lib/e11y/sampling/error_spike_detector.rb +225 -0
- data/lib/e11y/sampling/load_monitor.rb +161 -0
- data/lib/e11y/sampling/stratified_tracker.rb +92 -0
- data/lib/e11y/sampling/value_extractor.rb +82 -0
- data/lib/e11y/self_monitoring/buffer_monitor.rb +79 -0
- data/lib/e11y/self_monitoring/performance_monitor.rb +97 -0
- data/lib/e11y/self_monitoring/reliability_monitor.rb +146 -0
- data/lib/e11y/slo/event_driven.rb +150 -0
- data/lib/e11y/slo/tracker.rb +119 -0
- data/lib/e11y/version.rb +9 -0
- data/lib/e11y.rb +283 -0
- metadata +452 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ae952b91e779ee9e04150e324109586016d6dd0e9831d6acf7867e05f686f579
|
|
4
|
+
data.tar.gz: 8c3a957e11bd4cc84b4f5fa9c90eae3248c083b98a518ee328cad76401d5454b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ce56d9787c13db96db175a07418a34b17a43dd11dceb23d463c346abb7082caa1c45151826f6dc59981a069d8f2ec10d0f6eb4516f2da8cbce91754c483bae20
|
|
7
|
+
data.tar.gz: b5b650f09a2b634e31fedcebd058965dbc9787960769387b12a84bb5c14c96eb68bcc3245d04393bb75d51011dd290064185040daddcbc975aa8a66f6bda1709
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# See https://rubystyle.guide/ for Ruby style guide
|
|
4
|
+
# See https://docs.rubocop.org/rubocop/ for all available cops
|
|
5
|
+
|
|
6
|
+
require:
|
|
7
|
+
- rubocop-rspec
|
|
8
|
+
|
|
9
|
+
AllCops:
|
|
10
|
+
TargetRubyVersion: 3.2
|
|
11
|
+
NewCops: enable
|
|
12
|
+
SuggestExtensions: false
|
|
13
|
+
Exclude:
|
|
14
|
+
- 'bin/**/*'
|
|
15
|
+
- 'vendor/**/*'
|
|
16
|
+
- 'node_modules/**/*'
|
|
17
|
+
- 'tmp/**/*'
|
|
18
|
+
|
|
19
|
+
# Metrics
|
|
20
|
+
Metrics/BlockLength:
|
|
21
|
+
Exclude:
|
|
22
|
+
- 'spec/**/*'
|
|
23
|
+
- 'Rakefile'
|
|
24
|
+
- '*.gemspec'
|
|
25
|
+
|
|
26
|
+
Metrics/MethodLength:
|
|
27
|
+
Max: 15
|
|
28
|
+
Exclude:
|
|
29
|
+
- 'spec/**/*'
|
|
30
|
+
|
|
31
|
+
Metrics/ClassLength:
|
|
32
|
+
Max: 100
|
|
33
|
+
Exclude:
|
|
34
|
+
- 'spec/**/*'
|
|
35
|
+
|
|
36
|
+
# Style
|
|
37
|
+
Style/Documentation:
|
|
38
|
+
Enabled: true
|
|
39
|
+
Exclude:
|
|
40
|
+
- 'spec/**/*'
|
|
41
|
+
|
|
42
|
+
Style/StringLiterals:
|
|
43
|
+
EnforcedStyle: double_quotes
|
|
44
|
+
|
|
45
|
+
Style/FrozenStringLiteralComment:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
# RSpec
|
|
49
|
+
RSpec/ExampleLength:
|
|
50
|
+
Max: 20 # Allow longer examples for integration tests
|
|
51
|
+
|
|
52
|
+
RSpec/MultipleExpectations:
|
|
53
|
+
Max: 10 # Allow more expectations for integration tests
|
|
54
|
+
|
|
55
|
+
RSpec/NestedGroups:
|
|
56
|
+
Max: 3
|
|
57
|
+
|
|
58
|
+
# Gem-specific: Development dependencies can be in gemspec
|
|
59
|
+
Gemspec/DevelopmentDependencies:
|
|
60
|
+
Enabled: false
|
|
61
|
+
|
|
62
|
+
# Allow integration tests without specific class
|
|
63
|
+
RSpec/DescribeClass:
|
|
64
|
+
Exclude:
|
|
65
|
+
- "spec/zeitwerk_spec.rb"
|
|
66
|
+
|
|
67
|
+
# Allow simple doubles for now (will improve in Phase 1)
|
|
68
|
+
RSpec/VerifiedDoubles:
|
|
69
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial gem skeleton setup
|
|
12
|
+
- Zeitwerk autoloading configuration
|
|
13
|
+
- Basic project structure (lib/, spec/, bin/)
|
|
14
|
+
- CI/CD pipeline (GitHub Actions)
|
|
15
|
+
- Documentation framework (YARD, README)
|
|
16
|
+
|
|
17
|
+
## [0.1.0] - 2026-01-17
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- Project initialization
|
|
21
|
+
- Phase 0: Gem Setup & Best Practices Research complete
|
|
22
|
+
- Research documents for 6 successful gems (Devise, Sidekiq, Puma, Dry-rb, Yabeda, Sentry)
|
|
23
|
+
- Best practices synthesis for configuration DSL, testing, documentation, CI/CD, release process
|
|
24
|
+
|
|
25
|
+
[Unreleased]: https://github.com/arturseletskiy/e11y/compare/v0.1.0...HEAD
|
|
26
|
+
[0.1.0]: https://github.com/arturseletskiy/e11y/releases/tag/v0.1.0
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
49
|
+
an individual is officially representing the community in public spaces.
|
|
50
|
+
|
|
51
|
+
## Enforcement
|
|
52
|
+
|
|
53
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
54
|
+
reported to the community leaders responsible for enforcement at team@e11y.dev.
|
|
55
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
56
|
+
|
|
57
|
+
## Attribution
|
|
58
|
+
|
|
59
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
60
|
+
version 2.1, available at
|
|
61
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
62
|
+
|
|
63
|
+
[homepage]: https://www.contributor-covenant.org
|
|
64
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Artur Seletskiy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# E11y - Easy Telemetry for Ruby on Rails
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/e11y)
|
|
4
|
+
[](https://github.com/arturseletskiy/e11y/actions)
|
|
5
|
+
[](https://codecov.io/gh/arturseletskiy/e11y)
|
|
6
|
+
[](https://github.com/rubocop/rubocop)
|
|
7
|
+
|
|
8
|
+
**Production-ready observability for Rails applications.**
|
|
9
|
+
|
|
10
|
+
E11y (Easy Telemetry) provides structured business event tracking with request-scoped debug buffering, pattern-based metrics, zero-config SLO tracking, and pluggable adapters for logs/metrics/traces. Designed for SuperApp architecture with compliance-ready PII filtering and audit trails.
|
|
11
|
+
|
|
12
|
+
## 🚀 Quick Start
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
# Gemfile
|
|
16
|
+
gem "e11y"
|
|
17
|
+
|
|
18
|
+
# Define your first event
|
|
19
|
+
class OrderPaidEvent < E11y::Event::Base
|
|
20
|
+
schema do
|
|
21
|
+
required(:order_id).filled(:integer)
|
|
22
|
+
required(:amount).filled(:float)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
severity :success # Optional - auto-detected from name
|
|
26
|
+
adapters :loki # Optional - auto-selected based on severity
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Track events (zero-allocation pattern)
|
|
30
|
+
OrderPaidEvent.track(order_id: 123, amount: 99.99)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## ✨ Features
|
|
34
|
+
|
|
35
|
+
- 🎯 **Zero-Allocation Event Tracking** - Class-based pattern with zero GC pressure
|
|
36
|
+
- 📐 **Convention over Configuration** - Smart defaults from event names
|
|
37
|
+
- 📊 **Type-Safe Events** - Declarative schemas with dry-schema validation
|
|
38
|
+
- 🔄 **Event Versioning** - Built-in version support for schema evolution
|
|
39
|
+
- 🎭 **Severity Levels** - Auto-detection from event names
|
|
40
|
+
- 🔌 **Pluggable Adapters** - Loki, Sentry, OpenTelemetry, File, Stdout, Memory
|
|
41
|
+
- 📦 **Future Ready** - Architecture designed for Phase 2+ features:
|
|
42
|
+
- Request-Scoped Debug Buffering
|
|
43
|
+
- Pattern-Based Metrics (Prometheus/Yabeda)
|
|
44
|
+
- PII Filtering & Audit Trails (GDPR/SOC2)
|
|
45
|
+
- Rate Limiting & Cardinality Protection
|
|
46
|
+
- OpenTelemetry Integration
|
|
47
|
+
- Rails/Sidekiq Integration
|
|
48
|
+
|
|
49
|
+
## 📚 Documentation
|
|
50
|
+
|
|
51
|
+
- [Quick Start Guide](docs/QUICK-START.md)
|
|
52
|
+
- [Implementation Plan](docs/IMPLEMENTATION_PLAN.md)
|
|
53
|
+
- [Architecture Decisions (ADRs)](docs/)
|
|
54
|
+
- [Use Cases](docs/use_cases/)
|
|
55
|
+
- [API Reference](https://e11y.dev/api)
|
|
56
|
+
|
|
57
|
+
## 🛠️ Installation
|
|
58
|
+
|
|
59
|
+
Add this line to your application's Gemfile:
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
gem "e11y"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
And then execute:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
$ bundle install
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or install it yourself as:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
$ gem install e11y
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 📖 Usage
|
|
78
|
+
|
|
79
|
+
### Define Events
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
# Convention-based configuration (minimal)
|
|
83
|
+
class UserSignupEvent < E11y::Event::Base
|
|
84
|
+
schema do
|
|
85
|
+
required(:user_id).filled(:integer)
|
|
86
|
+
required(:email).filled(:string)
|
|
87
|
+
end
|
|
88
|
+
# Severity auto-detected: :info
|
|
89
|
+
# Adapters auto-selected: [:loki]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Explicit configuration
|
|
93
|
+
class PaymentFailedEvent < E11y::Event::Base
|
|
94
|
+
severity :error # Explicit severity
|
|
95
|
+
version 2 # Event version
|
|
96
|
+
adapters :loki, :sentry # Multiple adapters
|
|
97
|
+
|
|
98
|
+
schema do
|
|
99
|
+
required(:payment_id).filled(:integer)
|
|
100
|
+
required(:error_code).filled(:string)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Track events (class method - no instances!)
|
|
105
|
+
UserSignupEvent.track(user_id: 123, email: "user@example.com")
|
|
106
|
+
PaymentFailedEvent.track(payment_id: 456, error_code: "CARD_DECLINED")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Convention-Based Defaults
|
|
110
|
+
|
|
111
|
+
E11y uses smart conventions to minimize configuration:
|
|
112
|
+
|
|
113
|
+
**Severity from event name:**
|
|
114
|
+
- `*Failed*`, `*Error*` → `:error`
|
|
115
|
+
- `*Paid*`, `*Success*`, `*Completed*` → `:success`
|
|
116
|
+
- `*Warn*`, `*Warning*` → `:warn`
|
|
117
|
+
- Default → `:info`
|
|
118
|
+
|
|
119
|
+
**Adapters from severity:**
|
|
120
|
+
- `:error`, `:fatal` → `[:loki, :sentry]` (errors need both logging and alerting)
|
|
121
|
+
- Others → `[:loki]` (logs only)
|
|
122
|
+
|
|
123
|
+
**Result:** 90% of events need only `schema` definition!
|
|
124
|
+
|
|
125
|
+
## 🧪 Development
|
|
126
|
+
|
|
127
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Install dependencies
|
|
131
|
+
bin/setup
|
|
132
|
+
|
|
133
|
+
# Run tests
|
|
134
|
+
bundle exec rspec
|
|
135
|
+
|
|
136
|
+
# Run linter
|
|
137
|
+
bundle exec rubocop
|
|
138
|
+
|
|
139
|
+
# Run security audit
|
|
140
|
+
bundle exec bundler-audit check --update
|
|
141
|
+
bundle exec brakeman
|
|
142
|
+
|
|
143
|
+
# Generate documentation
|
|
144
|
+
bundle exec yard doc
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 🤝 Contributing
|
|
148
|
+
|
|
149
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/arturseletskiy/e11y. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).
|
|
150
|
+
|
|
151
|
+
## 📜 License
|
|
152
|
+
|
|
153
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
|
|
154
|
+
|
|
155
|
+
## 🙏 Code of Conduct
|
|
156
|
+
|
|
157
|
+
Everyone interacting in the E11y project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
|
|
158
|
+
|
|
159
|
+
## 📊 Project Status
|
|
160
|
+
|
|
161
|
+
**Current Version:** 0.1.0
|
|
162
|
+
|
|
163
|
+
**Phase 1 Progress (In Development):**
|
|
164
|
+
- ✅ Phase 0: Gem Setup & Best Practices
|
|
165
|
+
- 🔄 Phase 1: Core Foundation (In Progress)
|
|
166
|
+
- ✅ Event::Base with zero-allocation pattern
|
|
167
|
+
- ✅ Convention-based configuration
|
|
168
|
+
- ✅ Schema validation (dry-schema)
|
|
169
|
+
- 🔄 Adaptive Buffer implementation
|
|
170
|
+
- ⏳ Middleware Pipeline
|
|
171
|
+
- ⏳ track() method with pipeline
|
|
172
|
+
|
|
173
|
+
**Next Phases:**
|
|
174
|
+
- ⏳ Phase 2: Core Features (PII, Adapters, Metrics)
|
|
175
|
+
- ⏳ Phase 3: Rails Integration
|
|
176
|
+
- ⏳ Phase 4: Production Hardening
|
|
177
|
+
- ⏳ Phase 5: Scale & Optimization
|
|
178
|
+
|
|
179
|
+
See [IMPLEMENTATION_PLAN.md](docs/IMPLEMENTATION_PLAN.md) for detailed timeline.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
require "rubocop/rake_task"
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
8
|
+
|
|
9
|
+
RuboCop::RakeTask.new
|
|
10
|
+
|
|
11
|
+
task default: %i[spec rubocop]
|
|
12
|
+
|
|
13
|
+
# Custom tasks
|
|
14
|
+
namespace :e11y do
|
|
15
|
+
desc "Start interactive console"
|
|
16
|
+
task :console do
|
|
17
|
+
require "pry"
|
|
18
|
+
require_relative "lib/e11y"
|
|
19
|
+
Pry.start
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "Run performance benchmarks"
|
|
23
|
+
task :benchmark do
|
|
24
|
+
ruby "spec/benchmarks/run_all.rb"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc "Generate documentation"
|
|
28
|
+
task :docs do
|
|
29
|
+
sh "yard doc"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
desc "Run security audit"
|
|
33
|
+
task :audit do
|
|
34
|
+
sh "bundle exec bundler-audit check --update"
|
|
35
|
+
sh "bundle exec brakeman --no-pager"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# E11y Benchmarks Runner
|
|
5
|
+
#
|
|
6
|
+
# Run all benchmarks:
|
|
7
|
+
# bundle exec ruby benchmarks/run_all.rb
|
|
8
|
+
#
|
|
9
|
+
# Run with specific iterations:
|
|
10
|
+
# ITERATIONS=10000 bundle exec ruby benchmarks/run_all.rb
|
|
11
|
+
|
|
12
|
+
require "bundler/setup"
|
|
13
|
+
require "benchmark"
|
|
14
|
+
require "e11y"
|
|
15
|
+
|
|
16
|
+
ITERATIONS = (ENV["ITERATIONS"] || 1000).to_i
|
|
17
|
+
|
|
18
|
+
puts "🚀 E11y Benchmarks (#{ITERATIONS} iterations)"
|
|
19
|
+
puts "=" * 60
|
|
20
|
+
|
|
21
|
+
# Benchmarks will be implemented in Phase 1+
|
|
22
|
+
# Examples:
|
|
23
|
+
# - Event creation (zero-allocation goal)
|
|
24
|
+
# - Buffer operations (push/flush)
|
|
25
|
+
# - Middleware chain execution
|
|
26
|
+
# - Adapter send performance
|
|
27
|
+
|
|
28
|
+
puts "\n⚠️ Benchmarks will be implemented in Phase 1+"
|
|
29
|
+
puts "Expected metrics (from ADR-009):"
|
|
30
|
+
puts " - Event creation: < 10µs per event (zero-allocation)"
|
|
31
|
+
puts " - Buffer push: < 1µs (lock-free)"
|
|
32
|
+
puts " - Middleware: < 5µs per middleware"
|
|
33
|
+
puts " - Memory: < 100KB baseline, < 10MB under load"
|
data/config/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Docker Compose Test Backends
|
|
2
|
+
|
|
3
|
+
This Docker Compose setup provides test backends for E11y integration testing.
|
|
4
|
+
|
|
5
|
+
## Services
|
|
6
|
+
|
|
7
|
+
| Service | Port | Purpose | Health Check |
|
|
8
|
+
|---------|------|---------|--------------|
|
|
9
|
+
| **Loki** | 3100 | Log aggregation | http://localhost:3100/ready |
|
|
10
|
+
| **Prometheus** | 9090 | Metrics collection | http://localhost:9090/-/healthy |
|
|
11
|
+
| **Elasticsearch** | 9200 | Log storage & search | http://localhost:9200/_cluster/health |
|
|
12
|
+
| **Redis** | 6379 | Caching & pub/sub | redis-cli ping |
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### Start all backends:
|
|
17
|
+
```bash
|
|
18
|
+
docker-compose up -d
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Check status:
|
|
22
|
+
```bash
|
|
23
|
+
docker-compose ps
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### View logs:
|
|
27
|
+
```bash
|
|
28
|
+
docker-compose logs -f [service_name]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Stop all backends:
|
|
32
|
+
```bash
|
|
33
|
+
docker-compose down
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Stop and remove volumes:
|
|
37
|
+
```bash
|
|
38
|
+
docker-compose down -v
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Configuration Files
|
|
42
|
+
|
|
43
|
+
- `config/loki-local-config.yaml` - Loki configuration
|
|
44
|
+
- `config/prometheus.yml` - Prometheus scrape configuration
|
|
45
|
+
|
|
46
|
+
## Integration Testing
|
|
47
|
+
|
|
48
|
+
These backends are used for:
|
|
49
|
+
- **Loki**: Testing `E11y::Adapters::LokiAdapter` (Phase 3)
|
|
50
|
+
- **Prometheus**: Testing Yabeda metrics integration (Phase 1)
|
|
51
|
+
- **Elasticsearch**: Testing `E11y::Adapters::ElasticsearchAdapter` (Phase 3)
|
|
52
|
+
- **Redis**: Testing rate limiting, caching (Phase 1)
|
|
53
|
+
|
|
54
|
+
## Resource Requirements
|
|
55
|
+
|
|
56
|
+
- **Memory**: ~2GB RAM total
|
|
57
|
+
- **Disk**: ~500MB for images + data volumes
|
|
58
|
+
- **Network**: Bridge network `e11y_network`
|
|
59
|
+
|
|
60
|
+
## Health Checks
|
|
61
|
+
|
|
62
|
+
All services include health checks with automatic retries:
|
|
63
|
+
- Loki: 10s interval, 5 retries
|
|
64
|
+
- Prometheus: 10s interval, 5 retries
|
|
65
|
+
- Elasticsearch: 10s interval, 10 retries (slower startup)
|
|
66
|
+
- Redis: 5s interval, 5 retries
|
|
67
|
+
|
|
68
|
+
## Troubleshooting
|
|
69
|
+
|
|
70
|
+
### Elasticsearch fails to start:
|
|
71
|
+
```bash
|
|
72
|
+
# Increase vm.max_map_count on Linux/macOS
|
|
73
|
+
sysctl -w vm.max_map_count=262144
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Port conflicts:
|
|
77
|
+
Edit `docker-compose.yml` and change port mappings.
|
|
78
|
+
|
|
79
|
+
## Production Note
|
|
80
|
+
|
|
81
|
+
⚠️ **This is for TESTING ONLY!** Do not use these configurations in production.
|
|
82
|
+
|
|
83
|
+
For production setup, see `docs/guides/production-deployment.md` (Phase 5).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
auth_enabled: false
|
|
2
|
+
|
|
3
|
+
server:
|
|
4
|
+
http_listen_port: 3100
|
|
5
|
+
grpc_listen_port: 9096
|
|
6
|
+
|
|
7
|
+
common:
|
|
8
|
+
path_prefix: /tmp/loki
|
|
9
|
+
storage:
|
|
10
|
+
filesystem:
|
|
11
|
+
chunks_directory: /tmp/loki/chunks
|
|
12
|
+
rules_directory: /tmp/loki/rules
|
|
13
|
+
replication_factor: 1
|
|
14
|
+
ring:
|
|
15
|
+
instance_addr: 127.0.0.1
|
|
16
|
+
kvstore:
|
|
17
|
+
store: inmemory
|
|
18
|
+
|
|
19
|
+
schema_config:
|
|
20
|
+
configs:
|
|
21
|
+
- from: 2020-10-24
|
|
22
|
+
store: boltdb-shipper
|
|
23
|
+
object_store: filesystem
|
|
24
|
+
schema: v11
|
|
25
|
+
index:
|
|
26
|
+
prefix: index_
|
|
27
|
+
period: 24h
|
|
28
|
+
|
|
29
|
+
ruler:
|
|
30
|
+
alertmanager_url: http://localhost:9093
|
|
31
|
+
|
|
32
|
+
# By default, Loki will send anonymous usage data to Grafana Labs.
|
|
33
|
+
# To disable, set false.
|
|
34
|
+
analytics:
|
|
35
|
+
reporting_enabled: false
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
global:
|
|
2
|
+
scrape_interval: 15s
|
|
3
|
+
evaluation_interval: 15s
|
|
4
|
+
|
|
5
|
+
scrape_configs:
|
|
6
|
+
- job_name: 'prometheus'
|
|
7
|
+
static_configs:
|
|
8
|
+
- targets: ['localhost:9090']
|
|
9
|
+
|
|
10
|
+
- job_name: 'e11y-metrics'
|
|
11
|
+
static_configs:
|
|
12
|
+
- targets: ['host.docker.internal:9394']
|
|
13
|
+
labels:
|
|
14
|
+
app: 'e11y'
|
|
15
|
+
environment: 'test'
|
data/docker-compose.yml
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
loki:
|
|
5
|
+
image: grafana/loki:2.9.0
|
|
6
|
+
container_name: e11y_loki
|
|
7
|
+
ports:
|
|
8
|
+
- "3100:3100"
|
|
9
|
+
volumes:
|
|
10
|
+
- ./config/loki-local-config.yaml:/etc/loki/local-config.yaml
|
|
11
|
+
command: -config.file=/etc/loki/local-config.yaml
|
|
12
|
+
healthcheck:
|
|
13
|
+
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3100/ready"]
|
|
14
|
+
interval: 10s
|
|
15
|
+
timeout: 5s
|
|
16
|
+
retries: 5
|
|
17
|
+
networks:
|
|
18
|
+
- e11y_network
|
|
19
|
+
|
|
20
|
+
prometheus:
|
|
21
|
+
image: prom/prometheus:v2.45.0
|
|
22
|
+
container_name: e11y_prometheus
|
|
23
|
+
ports:
|
|
24
|
+
- "9090:9090"
|
|
25
|
+
volumes:
|
|
26
|
+
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
27
|
+
command:
|
|
28
|
+
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
29
|
+
- '--storage.tsdb.path=/prometheus'
|
|
30
|
+
healthcheck:
|
|
31
|
+
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9090/-/healthy"]
|
|
32
|
+
interval: 10s
|
|
33
|
+
timeout: 5s
|
|
34
|
+
retries: 5
|
|
35
|
+
networks:
|
|
36
|
+
- e11y_network
|
|
37
|
+
|
|
38
|
+
elasticsearch:
|
|
39
|
+
image: elasticsearch:8.9.0
|
|
40
|
+
container_name: e11y_elasticsearch
|
|
41
|
+
ports:
|
|
42
|
+
- "9200:9200"
|
|
43
|
+
- "9300:9300"
|
|
44
|
+
environment:
|
|
45
|
+
- discovery.type=single-node
|
|
46
|
+
- xpack.security.enabled=false
|
|
47
|
+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
|
48
|
+
healthcheck:
|
|
49
|
+
test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health"]
|
|
50
|
+
interval: 10s
|
|
51
|
+
timeout: 5s
|
|
52
|
+
retries: 10
|
|
53
|
+
networks:
|
|
54
|
+
- e11y_network
|
|
55
|
+
|
|
56
|
+
redis:
|
|
57
|
+
image: redis:7-alpine
|
|
58
|
+
container_name: e11y_redis
|
|
59
|
+
ports:
|
|
60
|
+
- "6379:6379"
|
|
61
|
+
command: redis-server --appendonly yes
|
|
62
|
+
healthcheck:
|
|
63
|
+
test: ["CMD", "redis-cli", "ping"]
|
|
64
|
+
interval: 5s
|
|
65
|
+
timeout: 3s
|
|
66
|
+
retries: 5
|
|
67
|
+
volumes:
|
|
68
|
+
- redis_data:/data
|
|
69
|
+
networks:
|
|
70
|
+
- e11y_network
|
|
71
|
+
|
|
72
|
+
networks:
|
|
73
|
+
e11y_network:
|
|
74
|
+
driver: bridge
|
|
75
|
+
|
|
76
|
+
volumes:
|
|
77
|
+
redis_data:
|
|
78
|
+
driver: local
|