//Include module
var base = require("../lib/index.js");

/**
 * NOTE:
 * All resource: Logger, Redis, Cassandra, Elastic, Mailer, Metrics has same logic
 */

/**
 * "/metrics" route is automatically added to expres
 * Also automatically collect general data from procces and from access like:
 * "process_cpu_user_seconds_total"
 * "process_cpu_system_seconds_total"
 * "process_cpu_seconds_total"
 * "process_start_time_seconds"
 * "process_resident_memory_bytes"
 * "nodejs_eventloop_lag_seconds"
 * "nodejs_active_handles_total"
 * "nodejs_active_requests_total"
 * "nodejs_heap_size_total_bytes"
 * "nodejs_heap_size_used_bytes"
 * "nodejs_heap_space_size_total_bytes"
 * "nodejs_heap_space_size_used_bytes"
 * "nodejs_heap_space_size_available_bytes"
 * "nodejs_version_info"
 * "up"
 */

/**
 * To use metrics in your project is pretty simple just call base.metrics() to get Prometeus registry
 */
base.metrics();

/**
 * You can have multiple registries
 * To create a new registry use base.metrics.newInstance("registry name")
 */
base.metrics.newInstance("name");

/**
 * To use a specific registry alredy created you can use base.metrics() with registry name
 */
 base.metrics("name");

/**
 * To delete all metrics from a registry use base.metrics("optional name").destroy();
 */
base.metrics().destroy();

/**
 * Get string representation for all metrics
 */
base.metrics().metrics();

/**
 * Reset all metrics in the registry
 */
base.metrics().resetMetrics();

/**
 * Get all metrics as objects
 */
base.metrics().getMetricsAsJSON();

/**
 * Set static labels to every metric emitted by this registry
 * @param labels of name/value pairs:
 * { defaultLabel: "value", anotherLabel: "value 2" }
 */
base.metrics().setDefaultLabels();

/**
 * Gets the Content-Type of the metrics for use in the response headers.
 */
base.metrics().contentType;


/**
 * We support 3 type of metrics: counter, gauge, history
 */

/**
 * To create a new metric in some registry can use:
 * You can not use same name for multiple metrics, not even in different types
 */
let aggregators = this.base.AGGREGATORS.MIN | this.base.AGGREGATORS.AVERAGE | this.base.AGGREGATORS.MAX;
this.base.metrics().newCounter("name", "description", ["labels"]);
this.base.metrics().newGauge("name", "description", ["labels"], aggregators); // Just Gauge support aggregators
this.base.metrics().newHistogram("name", "description", ["labels"]);

/**
 * To use some metric from a registry can use:
 */
this.base.metrics().counter("name");  
this.base.metrics().gauge("name");
this.base.metrics().histogram("name");

/**
 * To delete some metric from a registry can use:
 */
this.base.metrics().deleteCounter("name");  
this.base.metrics().deleteGauge("name");
this.base.metrics().deleteHistogram("name");
  
  