Skip to content

Instantly share code, notes, and snippets.

View felixbarny's full-sized avatar

Felix Barnsteiner felixbarny

View GitHub Profile
@felixbarny
felixbarny / gist:1f6ef39321849d7dd3889c5998e02a21
Created August 25, 2021 13:04
Flattened and runtime field test
PUT test
{
"mappings": {
"dynamic": "runtime",
"properties": {
"service": {
"type": "object",
"properties": {
"name": {
"type": "keyword"
@felixbarny
felixbarny / data-model.txt
Last active May 13, 2021 06:47
Elasticsearch profiling
DELETE /profile?ignore_unavailable=true
PUT /profile
{
"settings": {
"index": {
"codec": "best_compression"
}
},
"mappings": {
@felixbarny
felixbarny / NativeBinding.java
Last active January 9, 2020 14:16 — forked from raphw/NativeBinding.java
Example of a shadingproof JNI binding.
package com.shadeproof;
import net.bytebuddy.ByteBuddy;
public abstract class NativeBinding {
public static final NativeBinding INSTANCE;
static {
String expected = "!com!shadeproof!NativeBinding!";
@felixbarny
felixbarny / attach.sh
Last active May 27, 2019 07:18
Attach Elastic APM Java agent to docker containers
#!/usr/bin/env bash
set -ex
attach () {
if [[ $(docker inspect ${container_id} | jq --raw-output .[0].Config.Cmd[0]) == java ]]
then
echo attaching to $(docker ps --no-trunc | grep ${container_id})
docker cp /Users/felixbarnsteiner/Applications/apm/apm-agent-attach-1.6.1.jar ${container_id}:/apm-agent-attach.jar
docker exec ${container_id} java -jar /apm-agent-attach.jar --config
fi
@felixbarny
felixbarny / breakdown-example.txt
Created April 5, 2019 15:47
Metrics-based breakdown graphs
# Metric-based transaction breakdown example
# Paste in Kibana Dev Tools to try it out
# This example contains two hosts (host-a and host-b).
# One transaction (APIRestController#orders) which only has spans of type `db`
# On host a, there were 10 transactions each taking 40ms and consisting of 10 `db` calls, each taking 1ms on average (30ms transaction self_time)
# On host b, there were 5 transactions each taking 40ms and consisting of 15 `db` calls, each taking 1.333ms on average (20ms transaction self_time)
DELETE /apm-metrics?ignore_unavailable=true
@felixbarny
felixbarny / baseline.json
Created January 8, 2019 15:49
Current performance vs potential by having low contention object pools and reporter queue
This file has been truncated, but you can view the full file.
[
{
"jmhVersion" : "1.21",
"benchmark" : "co.elastic.apm.agent.benchmark.ElasticApmActiveContinuousBenchmark.benchmarkWithApm",
"mode" : "sample",
"threads" : 8,
"forks" : 1,
"jvm" : "/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java",
"jvmArgs" : [
"-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=53415:/Applications/IntelliJ IDEA.app/Contents/bin",
This file has been truncated, but you can view the full file.
[
{
"jmhVersion" : "1.21",
"benchmark" : "co.elastic.apm.agent.benchmark.ElasticApmActiveContinuousBenchmark.benchmarkWithApm",
"mode" : "sample",
"threads" : 16,
"forks" : 1,
"jvm" : "/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java",
"jvmArgs" : [
"-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=60247:/Applications/IntelliJ IDEA.app/Contents/bin",
@felixbarny
felixbarny / synchronized-map.json
Created January 8, 2019 08:54
Weak map benchmarks
This file has been truncated, but you can view the full file.
[
{
"jmhVersion" : "1.21",
"benchmark" : "co.elastic.apm.agent.benchmark.ElasticApmActiveContinuousBenchmark.benchmarkWithApm",
"mode" : "sample",
"threads" : 16,
"forks" : 1,
"jvm" : "/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java",
"jvmArgs" : [
"-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=60273:/Applications/IntelliJ IDEA.app/Contents/bin",
package org.jstage.shop.commons.utils;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
public class BlockingAtomicReference<V> extends AtomicReference<V> {
private final CountDownLatch initialized = new CountDownLatch(1);
/**
@felixbarny
felixbarny / ByteBuddyProfiler
Created April 2, 2015 14:03
ByteBuddyProfiler
package org.stagemonitor.instrument;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.instrumentation.MethodDelegation;
import net.bytebuddy.instrumentation.method.bytecode.bind.annotation.Origin;