Merge pull request #646 from trask/dd-merge
This commit is contained in:
commit
145c6752c8
|
@ -89,6 +89,10 @@ public class GlobalIgnoresMatcher<T extends TypeDescription>
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// clojure
|
||||||
|
if (name.startsWith("clojure.") || name.contains("$fn__")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (name.startsWith("io.opentelemetry.auto.")) {
|
if (name.startsWith("io.opentelemetry.auto.")) {
|
||||||
// FIXME: We should remove this once
|
// FIXME: We should remove this once
|
||||||
|
|
|
@ -19,6 +19,7 @@ package io.opentelemetry.auto.test
|
||||||
import io.opentelemetry.auto.bootstrap.AgentClassLoader
|
import io.opentelemetry.auto.bootstrap.AgentClassLoader
|
||||||
import io.opentelemetry.auto.tooling.ClassLoaderMatcher
|
import io.opentelemetry.auto.tooling.ClassLoaderMatcher
|
||||||
import io.opentelemetry.auto.tooling.ExporterClassLoader
|
import io.opentelemetry.auto.tooling.ExporterClassLoader
|
||||||
|
import io.opentelemetry.auto.tooling.log.LogContextScopeListener
|
||||||
import io.opentelemetry.auto.util.test.AgentSpecification
|
import io.opentelemetry.auto.util.test.AgentSpecification
|
||||||
|
|
||||||
class ClassLoaderMatcherTest extends AgentSpecification {
|
class ClassLoaderMatcherTest extends AgentSpecification {
|
||||||
|
@ -60,4 +61,9 @@ class ClassLoaderMatcherTest extends AgentSpecification {
|
||||||
expect:
|
expect:
|
||||||
ExporterClassLoader.name == "io.opentelemetry.auto.tooling.ExporterClassLoader"
|
ExporterClassLoader.name == "io.opentelemetry.auto.tooling.ExporterClassLoader"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "helper class names are hardcoded in Log Instrumentations"() {
|
||||||
|
expect:
|
||||||
|
LogContextScopeListener.name == "io.opentelemetry.auto.tooling.log.LogContextScopeListener"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,10 @@ public class TextMapExtractAdapter implements HttpTextFormat.Getter<Headers> {
|
||||||
if (header == null) {
|
if (header == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new String(header.value(), StandardCharsets.UTF_8);
|
byte[] value = header.value();
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new String(value, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,10 @@ public class TextMapExtractAdapter implements HttpTextFormat.Getter<Headers> {
|
||||||
if (header == null) {
|
if (header == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new String(header.value(), StandardCharsets.UTF_8);
|
byte[] value = header.value();
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new String(value, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
|
|
||||||
import io.opentelemetry.auto.config.Config;
|
import io.opentelemetry.auto.config.Config;
|
||||||
import io.opentelemetry.auto.tooling.Instrumenter;
|
import io.opentelemetry.auto.tooling.Instrumenter;
|
||||||
import io.opentelemetry.auto.tooling.log.LogContextScopeListener;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.bytebuddy.asm.Advice;
|
import net.bytebuddy.asm.Advice;
|
||||||
|
@ -55,7 +54,7 @@ public class Log4jMDCInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] helperClassNames() {
|
public String[] helperClassNames() {
|
||||||
return new String[] {LogContextScopeListener.class.getName()};
|
return new String[] {"io.opentelemetry.auto.tooling.log.LogContextScopeListener"};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MDCContextAdvice {
|
public static class MDCContextAdvice {
|
||||||
|
|
|
@ -38,4 +38,15 @@ class Log4jMDCTest extends LogContextInjectionTestBase {
|
||||||
def get(String key) {
|
def get(String key) {
|
||||||
return MDC.get(key)
|
return MDC.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
def remove(String key) {
|
||||||
|
MDC.context
|
||||||
|
return MDC.remove(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
def clear() {
|
||||||
|
return MDC.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,4 +31,14 @@ class Log4jThreadContextTest extends LogContextInjectionTestBase {
|
||||||
def get(String key) {
|
def get(String key) {
|
||||||
return ThreadContext.get(key)
|
return ThreadContext.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
def remove(String key) {
|
||||||
|
return ThreadContext.remove(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
def clear() {
|
||||||
|
return ThreadContext.clearAll()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class MDCInjectionInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] helperClassNames() {
|
public String[] helperClassNames() {
|
||||||
return new String[] {LogContextScopeListener.class.getName()};
|
return new String[] {"io.opentelemetry.auto.tooling.log.LogContextScopeListener"};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MDCAdvice {
|
public static class MDCAdvice {
|
||||||
|
|
|
@ -12,4 +12,14 @@ class Slf4jMDCTest extends LogContextInjectionTestBase {
|
||||||
def get(String key) {
|
def get(String key) {
|
||||||
return MDC.get(key)
|
return MDC.get(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
def remove(String key) {
|
||||||
|
return MDC.remove(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
def clear() {
|
||||||
|
return MDC.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,13 @@ abstract class LogContextInjectionTestBase extends AgentTestRunner {
|
||||||
*/
|
*/
|
||||||
abstract get(String key)
|
abstract get(String key)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove from the framework-specific context the value at the given key
|
||||||
|
*/
|
||||||
|
abstract remove(String key)
|
||||||
|
|
||||||
|
abstract clear()
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ConfigUtils.updateConfig {
|
ConfigUtils.updateConfig {
|
||||||
System.setProperty("ota.logs.injection", "true")
|
System.setProperty("ota.logs.injection", "true")
|
||||||
|
@ -139,4 +146,21 @@ abstract class LogContextInjectionTestBase extends AgentTestRunner {
|
||||||
mainSpan?.end()
|
mainSpan?.end()
|
||||||
mainScope?.close()
|
mainScope?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "modify thread context after clear of context map at the beginning of new thread"() {
|
||||||
|
def t1A
|
||||||
|
final Thread thread1 = new Thread() {
|
||||||
|
@Override
|
||||||
|
void run() {
|
||||||
|
clear()
|
||||||
|
put("a", "a thread1")
|
||||||
|
t1A = get("a")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thread1.start()
|
||||||
|
thread1.join()
|
||||||
|
|
||||||
|
expect:
|
||||||
|
t1A == "a thread1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue