Skip to content

Instantly share code, notes, and snippets.

View jotak's full-sized avatar

Joel Takvorian jotak

View GitHub Profile
@jotak
jotak / index.adoc
Created June 18, 2018 08:59
vertx mm metrics doc

Vert.x Micrometer Metrics

This project is an implementation of the Vert.x Metrics Service Provider Interface (SPI). It uses Micrometer for managing metrics and reporting to several backends.

Features

  • Vert.x core tools monitoring: TCP/HTTP client and servers, {@link io.vertx.core.datagram.DatagramSocket} , {@link io.vertx.core.eventbus.EventBus} and pools

  • User defined metrics through Micrometer

@jotak
jotak / file.tsx
Created May 30, 2018 08:29
min/max errors
const len = dataRps.length;
let minRps: number = len > 1 ? +dataRps[1] : 0;
let maxRps: number = minRps;
let errSample: number = dataErrors.length > 1 ? +dataErrors[1] : 0;
let pctMinErr: number = 100 * errSample / minRps;
let pctMaxErr: number = pctMinErr;
for (let i = 2; i < len; ++i) {
const sample: number = +dataRps[i];
minRps = sample < minRps ? sample : minRps;
@jotak
jotak / file.go
Created May 29, 2018 07:54
branch coverage
var countHistograms, countGauges uint32
api.SpyArgumentsAndReturnEmpty(func(args mock.Arguments) {
query := args[1].(string)
assert.IsType(t, v1.Range{}, args[2])
r := args[2].(v1.Range)
assert.Contains(t, query, "svc.ns.svc.cluster.local")
assert.Contains(t, query, "[1m]")
if strings.Contains(query, "histogram_quantile") {
[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ vertx-rx-java ---
[INFO] io.vertx:vertx-rx-java:jar:3.6.0-SNAPSHOT
[INFO] +- io.vertx:vertx-rx-java-codegen:jar:3.6.0-SNAPSHOT:compile
[INFO] | \- io.reactivex:rxjava:jar:1.3.5:compile
[INFO] +- io.vertx:vertx-core:test-jar:tests:3.6.0-SNAPSHOT:test
[INFO] | +- io.netty:netty-common:jar:4.1.19.Final:compile
[INFO] | +- io.netty:netty-buffer:jar:4.1.19.Final:compile
[INFO] | +- io.netty:netty-transport:jar:4.1.19.Final:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.19.Final:compile
[INFO] | | \- io.netty:netty-codec:jar:4.1.19.Final:compile
@jotak
jotak / run.go
Created February 20, 2018 15:34
Setup server with external prometheus + CORS allowed
package main
import (
"log"
"net/http"
"time"
"github.com/swift-sunshine/swscore/config"
"github.com/swift-sunshine/swscore/routing"
)
@jotak
jotak / MyTest.java
Last active January 26, 2018 09:50
Hanging test
package io.vertx.monitoring;
import io.vertx.core.Vertx;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@jotak
jotak / test.java
Last active January 16, 2018 08:42
TestContext and Async
@RunWith(VertxUnitRunner.class)
public class MyTest {
@Test
public void testRunningForever(TestContext context) {
Vertx vertx = Vertx.vertx();
Async async = context.async();
vertx.setTimer(1000, t -> {
context.fail("something wrong");
async.complete();
@jotak
jotak / prometheus.yml
Created December 8, 2017 08:20
For Medium
global:
scrape_interval: 10s
scrape_timeout: 10s
scrape_configs:
- job_name: my-kubernetes-job
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
# role "pod", or whatever
@jotak
jotak / prometheus.yml
Created December 8, 2017 08:18
For Medium
global:
# set whatever you like
scrape_interval: 10s
scrape_timeout: 10s
scrape_configs:
- job_name: dc_prometheus
honor_labels: true
metrics_path: /federate
params:
match[]:
@jotak
jotak / prometheus.yml
Created December 8, 2017 08:12
For Medium
# Label from HTTP code family & server name (ex from vertx_http_servers_0_0_0_0:8081_responses_2xx_total)
metric_relabel_configs:
# Transforming vertx_http_servers_0_0_0_0:8081_responses_2xx_total ...
# ... to vertx_http_servers_0_0_0_0:8081_responses_total{code=2xx}
- source_labels: [__name__]
regex: '(.*)_(\dxx)_(.*)'
replacement: '${2}'
target_label: code
- source_labels: [__name__]
regex: '(.*)_(\dxx)_(.*)'