vectra-client 0.3.3 → 0.3.4

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.
@@ -0,0 +1,158 @@
1
+ # Grafana Dashboard - Quick Start for Screenshots
2
+
3
+ **Get beautiful dashboard screenshots in 5 minutes!**
4
+
5
+ ## Step-by-Step Guide
6
+
7
+ ### 1. Install Dependencies
8
+
9
+ ```bash
10
+ # Install prometheus-client gem
11
+ gem install prometheus-client
12
+
13
+ # Or add to Gemfile:
14
+ # gem 'prometheus-client'
15
+ ```
16
+
17
+ ### 2. Start Prometheus Exporter (Terminal 1)
18
+
19
+ ```bash
20
+ cd /path/to/vectra
21
+ ruby examples/prometheus-exporter.rb
22
+ ```
23
+
24
+ You should see:
25
+ ```
26
+ 🚀 Vectra Prometheus Exporter
27
+ 📊 Metrics endpoint: http://localhost:9394/metrics
28
+ 🌐 Web interface: http://localhost:9394
29
+ ```
30
+
31
+ **Keep this running!**
32
+
33
+ ### 3. Setup Grafana Cloud
34
+
35
+ 1. Go to [grafana.com](https://grafana.com) and sign up (free)
36
+ 2. Create a new organization
37
+ 3. Go to **Connections** → **Data Sources**
38
+ 4. Click **Add new data source**
39
+ 5. Select **Prometheus**
40
+ 6. Configure:
41
+ - **Name:** `Prometheus` (or any name)
42
+ - **URL:** `http://localhost:9394` (if using local)
43
+ - OR use Grafana Cloud's Prometheus (recommended)
44
+ 7. Click **Save & Test** (should show "Data source is working")
45
+
46
+ ### 4. Import Dashboard
47
+
48
+ 1. Go to **Dashboards** → **New** → **Import**
49
+ 2. Click **Upload JSON file**
50
+ 3. Select `examples/grafana-dashboard.json`
51
+ 4. Select your Prometheus data source
52
+ 5. Click **Import**
53
+
54
+ ### 5. View Dashboard
55
+
56
+ - Dashboard will appear with all panels
57
+ - Wait 1-2 minutes for metrics to accumulate
58
+ - Refresh dashboard (F5) to see new data
59
+
60
+ ### 6. Take Screenshots
61
+
62
+ **Option A: Browser Screenshot**
63
+ - Use browser dev tools (F12)
64
+ - Or use screenshot tool (Cmd+Shift+4 on Mac)
65
+
66
+ **Option B: Grafana Share**
67
+ - Click panel → **Share** → **Direct link rendered image**
68
+ - Or use **Export** → **Save as image**
69
+
70
+ ## Best Panels for Screenshots
71
+
72
+ ### 🎯 Top Recommendations:
73
+
74
+ 1. **Request Rate by Operation** (Time Series)
75
+ - Shows query, upsert, delete operations
76
+ - Clean lines, professional look
77
+ - Perfect for: Twitter, LinkedIn, blog posts
78
+
79
+ 2. **Latency Distribution** (P50, P95, P99)
80
+ - Three lines showing percentiles
81
+ - Shows performance depth
82
+ - Perfect for: Technical blog posts, documentation
83
+
84
+ 3. **Operations Distribution** (Pie Chart)
85
+ - Colorful, easy to understand
86
+ - Shows operation breakdown
87
+ - Perfect for: Overview posts, presentations
88
+
89
+ 4. **Top Row Stats** (4 Stat Panels)
90
+ - Total Requests, Error Rate, P95 Latency, Cache Hit Ratio
91
+ - Shows key metrics at a glance
92
+ - Perfect for: Hero images, feature highlights
93
+
94
+ ## Tips for Best Screenshots
95
+
96
+ ### Time Range
97
+ - Set to **"Last 15 minutes"** for demo screenshots
98
+ - Shows active, recent data
99
+
100
+ ### Theme
101
+ - Use **Dark theme** (Settings → Preferences)
102
+ - Looks more professional
103
+
104
+ ### Panel Settings
105
+ - Hide legend if too cluttered (Panel → Options → Legend)
106
+ - Add panel descriptions (Panel → Title → Description)
107
+
108
+ ### Data Density
109
+ - Let exporter run for 2-3 minutes before screenshot
110
+ - More data = better visualization
111
+
112
+ ## Troubleshooting
113
+
114
+ ### No Data Showing?
115
+
116
+ 1. **Check exporter is running:**
117
+ ```bash
118
+ curl http://localhost:9394/metrics | head -20
119
+ ```
120
+ Should show Prometheus metrics
121
+
122
+ 2. **Check Grafana data source:**
123
+ - Go to Data Sources
124
+ - Click "Test" button
125
+ - Should show "Data source is working"
126
+
127
+ 3. **Check dashboard queries:**
128
+ - Click panel → Edit
129
+ - Check if query returns data
130
+ - Try: `sum(vectra_requests_total)`
131
+
132
+ ### Metrics Not Appearing?
133
+
134
+ - Exporter generates metrics every 0.5-2 seconds
135
+ - Wait 1-2 minutes for data to accumulate
136
+ - Refresh dashboard (F5)
137
+
138
+ ## Next Steps
139
+
140
+ - Run comprehensive demo to generate real metrics:
141
+ ```bash
142
+ bundle exec ruby examples/comprehensive_demo.rb
143
+ ```
144
+
145
+ - See [grafana-setup.md](grafana-setup.md) for production setup
146
+
147
+ - Check [monitoring guide](../docs/guides/monitoring.md) for full monitoring setup
148
+
149
+ ## Example Screenshot Workflow
150
+
151
+ 1. ✅ Start exporter: `ruby examples/prometheus-exporter.rb`
152
+ 2. ✅ Import dashboard to Grafana
153
+ 3. ✅ Wait 2 minutes for data
154
+ 4. ✅ Set time range to "Last 15 minutes"
155
+ 5. ✅ Take screenshot of "Request Rate by Operation" panel
156
+ 6. ✅ Take screenshot of "Latency Distribution" panel
157
+ 7. ✅ Take screenshot of full dashboard
158
+ 8. ✅ Done! 🎉
@@ -0,0 +1,320 @@
1
+ # Vectra Examples
2
+
3
+ This directory contains comprehensive examples demonstrating Vectra's capabilities.
4
+
5
+ ## Prerequisites
6
+
7
+ ### For Qdrant examples:
8
+ ```bash
9
+ # Start Qdrant locally with Docker
10
+ docker run -p 6333:6333 qdrant/qdrant
11
+
12
+ # Or install Qdrant directly
13
+ brew install qdrant
14
+ qdrant
15
+ ```
16
+
17
+ ### For pgvector examples:
18
+ ```bash
19
+ # Install PostgreSQL with pgvector
20
+ brew install postgresql pgvector
21
+
22
+ # Start PostgreSQL
23
+ brew services start postgresql
24
+
25
+ # Create database and enable extension
26
+ createdb vectra_demo
27
+ psql vectra_demo -c "CREATE EXTENSION vector;"
28
+ ```
29
+
30
+ ## Examples
31
+
32
+ ### 1. **Comprehensive Demo** (`comprehensive_demo.rb`)
33
+
34
+ **⭐ START HERE** - Complete production-ready demonstration of all Vectra features.
35
+
36
+ ```bash
37
+ bundle exec ruby examples/comprehensive_demo.rb
38
+ ```
39
+
40
+ **What it demonstrates:**
41
+ - ✅ Basic CRUD operations (Create, Read, Update, Delete)
42
+ - ✅ Batch processing (50+ documents)
43
+ - ✅ **Async batch operations** (concurrent processing)
44
+ - ✅ **Streaming queries** (memory-efficient large result sets)
45
+ - ✅ Advanced queries with metadata filtering
46
+ - ✅ Update operations (metadata and vectors)
47
+ - ✅ Multiple delete strategies
48
+ - ✅ Cache performance (3-5x speedup)
49
+ - ✅ Error handling & resilience
50
+ - ✅ **Rate limiting** (proactive throttling)
51
+ - ✅ **Circuit breaker** (failover pattern)
52
+ - ✅ Multi-tenancy with namespaces
53
+ - ✅ Health monitoring & statistics
54
+ - ✅ **Structured JSON logging**
55
+ - ✅ **Audit logging** (compliance)
56
+ - ✅ **Error tracking** (Sentry, Honeybadger)
57
+
58
+ **Output preview:**
59
+ ```
60
+ ================================================================================
61
+ VECTRA COMPREHENSIVE DEMO
62
+ ================================================================================
63
+
64
+ Provider: Qdrant
65
+ Host: http://localhost:6333
66
+ Index: documents
67
+ Dimension: 128
68
+
69
+ ────────────────────────────────────────────────────────────────────────────────
70
+ │ 1. Basic CRUD Operations
71
+ ────────────────────────────────────────────────────────────────────────────────
72
+
73
+ 🏥 Checking system health...
74
+ ✅ System healthy (3.21ms latency)
75
+
76
+ 📦 Creating index 'documents'...
77
+ ✅ Index created
78
+
79
+ 📝 Inserting single document...
80
+ ✅ Inserted 1 document
81
+
82
+ [... continues with 13 sections ...]
83
+
84
+ 📊 Operations Summary:
85
+ Total operations: 60+
86
+ Cache hits: 2
87
+ Errors handled: 3
88
+ Retries: 0
89
+
90
+ 🎯 Features Demonstrated:
91
+ ✅ Basic CRUD operations
92
+ ✅ Batch processing
93
+ ✅ Async batch operations
94
+ ✅ Streaming queries
95
+ ✅ Advanced queries with filtering
96
+ ✅ Update operations
97
+ ✅ Delete operations
98
+ ✅ Caching & performance
99
+ ✅ Error handling
100
+ ✅ Multi-tenancy (namespaces)
101
+ ✅ Health monitoring
102
+ ✅ Rate limiting
103
+ ✅ Circuit breaker
104
+ ✅ Monitoring & logging
105
+
106
+ ✅ Demo completed successfully!
107
+ ```
108
+
109
+ **Run with cleanup:**
110
+ ```bash
111
+ bundle exec ruby examples/comprehensive_demo.rb --cleanup
112
+ ```
113
+
114
+ ---
115
+
116
+ ### 2. **Blog Search Engine** (`blog_search_engine.rb`)
117
+
118
+ Simple semantic search engine for blog posts with caching.
119
+
120
+ ```bash
121
+ bundle exec ruby examples/blog_search_engine.rb
122
+ ```
123
+
124
+ **Features:**
125
+ - Blog post indexing with metadata
126
+ - Semantic search with category filtering
127
+ - Cache performance testing
128
+ - Simple embedding generation
129
+
130
+ **Best for:**
131
+ - Learning the basics
132
+ - Understanding semantic search
133
+ - Quick prototyping
134
+
135
+ ---
136
+
137
+ ## Running Examples
138
+
139
+ ### Basic Usage
140
+
141
+ ```bash
142
+ # Run with default settings (localhost:6333)
143
+ bundle exec ruby examples/comprehensive_demo.rb
144
+
145
+ # Specify custom host
146
+ bundle exec ruby examples/comprehensive_demo.rb http://your-qdrant-host:6333
147
+
148
+ # Run with cleanup
149
+ bundle exec ruby examples/comprehensive_demo.rb --cleanup
150
+ ```
151
+
152
+ ### Troubleshooting
153
+
154
+ **"Cannot connect to Qdrant"**
155
+ ```bash
156
+ # Check if Qdrant is running
157
+ curl http://localhost:6333/health
158
+
159
+ # Start Qdrant if needed
160
+ docker run -p 6333:6333 qdrant/qdrant
161
+ ```
162
+
163
+ **"Index already exists"**
164
+ ```bash
165
+ # Run with cleanup flag
166
+ bundle exec ruby examples/comprehensive_demo.rb --cleanup
167
+ ```
168
+
169
+ **Performance issues**
170
+ ```bash
171
+ # Check Qdrant dashboard
172
+ open http://localhost:6333/dashboard
173
+ ```
174
+
175
+ ## Example Output Comparison
176
+
177
+ ### Comprehensive Demo
178
+ - **Operations:** 60+ operations across 13 sections
179
+ - **Duration:** ~10-15 seconds
180
+ - **Documents:** 80+ indexed
181
+ - **Features shown:** ALL major features including:
182
+ - Performance optimizations (async, streaming, caching)
183
+ - Resilience patterns (rate limiting, circuit breaker)
184
+ - Production monitoring (logging, audit, error tracking)
185
+
186
+ ### Blog Search Engine
187
+ - **Operations:** ~10 operations
188
+ - **Duration:** ~2-3 seconds
189
+ - **Documents:** 5-8 indexed
190
+ - **Features shown:** Basic CRUD + caching
191
+
192
+ ## Grafana Dashboard 📊
193
+
194
+ Create beautiful monitoring dashboards with Grafana - perfect for screenshots!
195
+
196
+ ### Quick Start (5 minutes)
197
+
198
+ 1. **Start Prometheus Exporter:**
199
+ ```bash
200
+ ruby examples/prometheus-exporter.rb
201
+ ```
202
+
203
+ 2. **Setup Grafana:**
204
+ - Sign up at [grafana.com](https://grafana.com) (free)
205
+ - Add Prometheus data source
206
+ - Import `examples/grafana-dashboard.json`
207
+
208
+ 3. **Take Screenshots:**
209
+ - Wait 1-2 minutes for metrics
210
+ - Use browser screenshot or Grafana's export feature
211
+ - Perfect panels: Request Rate, Latency Distribution, Pie Charts
212
+
213
+ **See [GRAFANA_QUICKSTART.md](GRAFANA_QUICKSTART.md) for step-by-step guide.**
214
+
215
+ ### Dashboard Features
216
+
217
+ - **12 Professional Panels:**
218
+ - Request rate, error rate, latency metrics
219
+ - Cache performance, connection pool status
220
+ - Time series, pie charts, bar gauges
221
+ - Color-coded thresholds
222
+
223
+ - **Perfect for Screenshots:**
224
+ - Clean, modern design
225
+ - Dark theme support
226
+ - Multiple visualization types
227
+ - Real-time data updates
228
+
229
+ See [grafana-setup.md](grafana-setup.md) for complete production setup.
230
+
231
+ ## Next Steps
232
+
233
+ 1. **Read the main README:** `../README.md`
234
+ 2. **Check the documentation:** [vectra-docs.netlify.app](https://vectra-docs.netlify.app/)
235
+ 3. **Explore the source code:** `../lib/vectra/`
236
+ 4. **Try with different providers:** Pinecone, Weaviate, pgvector
237
+ 5. **Build your own application!**
238
+
239
+ ## New Features in Comprehensive Demo
240
+
241
+ The comprehensive demo now includes **4 additional sections** demonstrating production-ready features:
242
+
243
+ ### Section 10: Async Batch Operations
244
+ - Concurrent batch upsert with configurable worker count
245
+ - Automatic chunking and error handling
246
+ - Performance metrics and throughput analysis
247
+
248
+ ### Section 11: Streaming Large Queries
249
+ - Memory-efficient query processing
250
+ - Batch-by-batch result streaming
251
+ - Perfect for large result sets without memory overflow
252
+
253
+ ### Section 12: Resilience Features
254
+ - **Rate Limiting**: Token bucket algorithm for smooth throttling
255
+ - **Circuit Breaker**: Automatic failover with state management
256
+ - Real-world resilience patterns
257
+
258
+ ### Section 13: Monitoring & Logging
259
+ - **Structured JSON Logging**: Machine-readable log format
260
+ - **Audit Logging**: Compliance-ready audit trails
261
+ - **Error Tracking**: Sentry and Honeybadger integration
262
+ - Production monitoring setup
263
+
264
+ ## Tips for Production
265
+
266
+ ### Performance
267
+ ```ruby
268
+ # Use caching for frequently queried vectors
269
+ cache = Vectra::Cache.new(ttl: 600, max_size: 10000)
270
+ client = Vectra::CachedClient.new(base_client, cache: cache)
271
+
272
+ # Batch operations for efficiency
273
+ client.upsert(index: 'docs', vectors: large_batch)
274
+ ```
275
+
276
+ ### Error Handling
277
+ ```ruby
278
+ begin
279
+ client.query(index: 'docs', vector: embedding, top_k: 10)
280
+ rescue Vectra::NotFoundError => e
281
+ # Handle missing index
282
+ rescue Vectra::ValidationError => e
283
+ # Handle invalid input
284
+ rescue Vectra::ServerError => e
285
+ # Handle server errors
286
+ end
287
+ ```
288
+
289
+ ### Monitoring
290
+ ```ruby
291
+ # Regular health checks
292
+ health = client.health_check(include_stats: true)
293
+ puts "Latency: #{health.latency_ms}ms"
294
+ puts "Vector count: #{health.stats[:vector_count]}"
295
+ ```
296
+
297
+ ### Multi-tenancy
298
+ ```ruby
299
+ # Isolate tenant data with namespaces
300
+ client.upsert(
301
+ index: 'shared_index',
302
+ vectors: tenant_vectors,
303
+ namespace: "tenant-#{tenant_id}"
304
+ )
305
+
306
+ # Query only tenant's data
307
+ results = client.query(
308
+ index: 'shared_index',
309
+ vector: query_vec,
310
+ namespace: "tenant-#{tenant_id}"
311
+ )
312
+ ```
313
+
314
+ ## Contributing
315
+
316
+ Found an issue or want to add a new example? [Open an issue](https://github.com/stokry/vectra/issues) or submit a PR!
317
+
318
+ ## License
319
+
320
+ MIT - See [LICENSE](../LICENSE)