- My laptop benchmarks normal random long (including work to create the java object representing a context) is something like 40 per microsecond
- Desktop: 2.8Ghz macbook pro
- Using threadlocalrandom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.opentracing.contrib; | |
import io.opentracing.NoopTracerFactory; | |
import io.opentracing.Tracer; | |
import java.util.Iterator; | |
import java.util.ServiceLoader; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class TraceIdGenerator { | |
private static final ThreadLocal<Integer> ThreadTraceIdSequence = new ThreadLocal<Integer>(){ | |
@Override | |
protected Integer initialValue() { | |
return 0; | |
} | |
}; | |
private static final int PROCESS_UUID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Code from | |
* https://github.com/Nike-Inc/wingtips/blob/38d8ce83207ffee3d638bf7466b8f7058bb36498/wingtips-core/src/main/java/com/nike/wingtips/TraceAndSpanIdGenerator.java#L60 | |
* Thanks to @adriancole | |
*/ | |
public static long generate64BitRandomLong() { | |
byte[] random8Bytes = new byte[8]; | |
random.nextBytes(random8Bytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by wusheng on 2016/12/21. | |
*/ | |
public class Transaction { | |
// 当前线程事务GUID | |
private java.lang.String traceId; | |
// 相关性上级GUID | |
private java.lang.String refTraceId; | |
// 全局 GUID | |
private java.lang.String tripId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* https://github.com/stagemonitor/stagemonitor/blob/80793ac6c582944c9078b420138dda4d23517a69/stagemonitor-core/src/main/java/org/stagemonitor/core/instrument/AgentAttacher.java#L149-L166 | |
*/ | |
private static ClassFileTransformer initByteBuddyClassFileTransformer(AutoEvictingCachingBinaryLocator binaryLocator) { | |
AgentBuilder agentBuilder = createAgentBuilder(binaryLocator); | |
for (StagemonitorByteBuddyTransformer transformer : getStagemonitorByteBuddyTransformers()) { | |
agentBuilder = agentBuilder | |
.type(transformer.getMatcher()) | |
.transform(transformer.getTransformer()) | |
.asDecorator(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Type.java | |
public enum Type { A, B, C, D, E, F, G, H, I, J }; | |
// Base.java | |
public abstract class Base { | |
int i = 1; | |
final Type type; | |
public Base(Type type) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2016 Google Inc. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package veddan.physicalcores; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.io.StringWriter; | |
import java.io.UnsupportedEncodingException; | |
import java.nio.charset.Charset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.bytebuddy; | |
import net.bytebuddy.agent.ByteBuddyAgent; | |
import net.bytebuddy.agent.builder.AgentBuilder; | |
import net.bytebuddy.description.type.TypeDescription; | |
import net.bytebuddy.dynamic.ClassFileLocator; | |
import net.bytebuddy.dynamic.DynamicType; | |
import net.bytebuddy.dynamic.loading.ClassInjector; | |
import net.bytebuddy.implementation.MethodDelegation; | |
import net.bytebuddy.implementation.bind.annotation.SuperCall; |
OlderNewer