Modern gözlemleme (observability) sistemlerinde, metrik toplama süreçlerini ve veri boru hatlarını doğrulamak için gerçekçi veri setlerine ihtiyaç duyulur. Mock-jutsu kütüphanesi, bu ihtiyacı profesyonel düzeyde karşılamak amacıyla geliştirilmiş kapsamlı bir araçtır. Kütüphanenin sunduğu openmetrics_snapshot fonksiyonu, Prometheus ekosisteminin bir üst kümesi olan OpenMetrics standartlarında dinamik test verisi üretmenize olanak tanır. Bu fonksiyon, özellikle metrik toplama (scraping) mekanizmalarını, veri görselleştirme panellerini veya karmaşık alarm sistemlerini test ederken geliştiricilere büyük esneklik sağlar.
Openmetrics_snapshot fonksiyonu, teknik altyapı olarak OpenMetrics exposition formatını temel alır. Üretilen çıktı; metrik ailelerini, her bir metriğin amacını belirten açıklamaları (# HELP) ve veri tipini tanımlayan etiketleri (# TYPE) içerir. Fonksiyonun en kritik özelliklerinden biri, OpenMetrics standardının zorunlu kıldığı "# EOF" sonlandırıcısını otomatik olarak eklemesidir. Bu titiz yapısal bütünlük, üretilen mock data örneklerinin OTLP (OpenTelemetry Protocol) ve Grafana Mimir gibi modern gözlemleme araçları tarafından gerçek bir veri kaynağıymış gibi işlenmesini sağlar. Böylece, sistemlerinizin standartlara uyumluluğunu henüz üretim ortamına geçmeden test etme imkanına sahip olursunuz.
Bu fonksiyonun kullanım senaryoları oldukça geniştir. Bir mikro hizmetin metrik uç noktasını (endpoint) simüle etmek istediğinizde, mock-jutsu sayesinde saniyeler içinde geçerli bir yanıt şablonu oluşturabilirsiniz. Özellikle JMeter entegrasyonu sayesinde, yüksek hacimli metrik verisi altında sistemin nasıl tepki verdiğini ölçmek için openmetrics_snapshot fonksiyonunu yük testlerinize dahil edebilirsiniz. Geliştiriciler, Python projelerinde jutsu.generate('openmetrics_snapshot') komutuyla programatik olarak test verisi üretebilir veya CLI üzerinden hızlıca prototipleme yapabilirler. Bu yaklaşım, manuel veri hazırlama zahmetini ortadan kaldırarak hata payını minimize eder.
Sonuç olarak, openmetrics_snapshot fonksiyonu, izleme altyapılarını test etmek için gereken karmaşık yapılandırmaları basitleştirir. Gerçek bir Prometheus exporter kurulumuna ihtiyaç duymadan, standartlara tam uyumlu ve tutarlı veriler elde etmenizi sağlar. Mock-jutsu kütüphanesinin bu yeteneği, CI/CD süreçlerindeki otomatik testlerin kalitesini artırırken, metrik tabanlı çalışan uygulamaların hata ayıklama süreçlerini de önemli ölçüde hızlandırır. Gelişmiş veri üretim algoritmaları sayesinde, sistemlerinizin en zorlu veri senaryolarına hazır olduğundan emin olabilirsiniz.
mockjutsu generate openmetrics_snapshotmockjutsu bulk openmetrics_snapshot --count 10mockjutsu export openmetrics_snapshot --count 10 --format jsonmockjutsu export openmetrics_snapshot --count 10 --format csvmockjutsu export openmetrics_snapshot --count 10 --format sqlfrom mockjutsu import jutsujutsu.generate('openmetrics_snapshot')jutsu.bulk('openmetrics_snapshot', count=10)jutsu.template(['openmetrics_snapshot'], count=5)${__mockjutsu_prometheus(openmetrics_snapshot)}# JMeter Function: __mockjutsu_prometheus# Parameter 1: openmetrics_snapshot# Parameter 2: (not required for this function)GET /generate/openmetrics_snapshot# → {"type":"openmetrics_snapshot","result":"...","status":"ok"}GET /bulk/openmetrics_snapshot?count=10POST /template {"types":["openmetrics_snapshot"],"count":1}Örnek Çıktılar
{"exposition": "# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.\n# TYPE process_cpu_seconds_total counter\nprocess_cpu_seconds_total 13016.55\n# HELP process_resident_memory_bytes Resident memory size in bytes.\n# TYPE process_resident_memory_bytes gauge\nprocess_resident_memory_bytes 2115629577\n# HELP process_virtual_memory_bytes Virtual memory size in bytes.\n# TYPE process_virtual_memory_bytes gauge\nprocess_virtual_memory_bytes 2319095732\n# HELP process_open_fds Number of open file descriptors.\n# TYPE process_open_fds gauge\nprocess_open_fds 313\n# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.\n# TYPE process_start_time_seconds gauge\nprocess_start_time_seconds 1781297013.879\n\n# HELP http_requests_total Total number of HTTP requests received.\n# TYPE http_requests_total counter\nhttp_requests_total{method=\"PUT\",path=\"/api/v1/auth/token\",status=\"502\"} 67640\nhttp_requests_total{method=\"PUT\",path=\"/metrics\",status=\"201\"} 71613\nhttp_requests_total{method=\"PUT\",path=\"/api/v1/orders\",status=\"200\"} 85374\nhttp_requests_total{method=\"POST\",path=\"/api/v1/auth/token\",status=\"404\"} 13772\nhttp_requests_total{method=\"POST\",path=\"/metrics\",status=\"403\"} 73675\nhttp_requests_total{method=\"POST\",path=\"/api/v1/orders\",status=\"404\"} 96447\n\n# HELP http_request_duration_seconds HTTP request latency in seconds.\n# TYPE http_request_duration_seconds histogram\nhttp_request_duration_seconds_bucket{le=\"0.005\"} 1953\nhttp_request_duration_seconds_bucket{le=\"0.01\"} 2759\nhttp_request_duration_seconds_bucket{le=\"0.025\"} 5896\nhttp_request_duration_seconds_bucket{le=\"0.05\"} 6261\nhttp_request_duration_seconds_bucket{le=\"0.1\"} 7130\nhttp_request_duration_seconds_bucket{le=\"0.25\"} 8192\nhttp_request_duration_seconds_bucket{le=\"0.5\"} 11179\nhttp_request_duration_seconds_bucket{le=\"1\"} 17004\nhttp_request_duration_seconds_bucket{le=\"2.5\"} 23989\nhttp_request_duration_seconds_bucket{le=\"5\"} 24845\nhttp_request_duration_seconds_bucket{le=\"10\"} 33448\nhttp_request_duration_seconds_bucket{le=\"+Inf\"} 33448\nhttp_request_duration_seconds_sum 31164.496\nhttp_request_duration_seconds_count 33448\n\n# HELP go_goroutines Number of goroutines that currently exist.\n# TYPE go_goroutines gauge\ngo_goroutines 116\n# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.\n# TYPE go_memstats_alloc_bytes gauge\ngo_memstats_alloc_bytes 323901561\n# HELP go_gc_duration_seconds A summary of GC invocation durations.\n# TYPE go_gc_duration_seconds summary\ngo_gc_duration_seconds{quantile=\"0\"} 7.177796e-06\ngo_gc_duration_seconds{quantile=\"0.25\"} 1.923168e-04\ngo_gc_duration_seconds{quantile=\"0.5\"} 3.633791e-04\ngo_gc_duration_seconds{quantile=\"0.75\"} 4.818765e-04\ngo_gc_duration_seconds{quantile=\"1\"} 7.334534e-04\ngo_gc_duration_seconds_sum 0.2956\ngo_gc_duration_seconds_count 960\n# EOF\n", "format": "openmetrics", "metric_families": ["process_cpu_seconds_total", "process_resident_memory_bytes", "process_virtual_memory_bytes", "process_open_fds", "process_start_time_seconds", "http_requests_total", "http_request_duration_seconds", "go_goroutines", "go_memstats_alloc_bytes", "go_gc_duration_seconds"], "total_samples": 34}Doğrulama Kuralları
- Mock Jutsu tarafından gerçek format kurallarına uygun üretilir
- Üretilen değerler tamamen sentetiktir
- Geliştirme, test ve demo ortamları için tasarlanmıştır