Bump errorProneVersion from 2.17.0 to 2.18.0 (#7532)
Bumps `errorProneVersion` from 2.17.0 to 2.18.0. Updates `error_prone_annotations` from 2.17.0 to 2.18.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/google/error-prone/releases">error_prone_annotations's releases</a>.</em></p> <blockquote> <h2>Error Prone 2.18.0</h2> <p>New Checkers:</p> <ul> <li><a href="https://errorprone.info/bugpattern/InjectOnBugCheckers"><code>InjectOnBugCheckers</code></a></li> <li><a href="https://errorprone.info/bugpattern/LabelledBreakTarget"><code>LabelledBreakTarget</code></a></li> <li><a href="https://errorprone.info/bugpattern/UnusedLabel"><code>UnusedLabel</code></a></li> <li><a href="https://errorprone.info/bugpattern/YodaCondition"><code>YodaCondition</code></a></li> </ul> <p>Fixes issues: <a href="https://github-redirect.dependabot.com/google/error-prone/issues/1650">#1650</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/2706">#2706</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3404">#3404</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3493">#3493</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3504">#3504</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3519">#3519</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3579">#3579</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3610">#3610</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3632">#3632</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3638">#3638</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3645">#3645</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3646">#3646</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3652">#3652</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3690">#3690</a></p> <p><strong>Full Changelog</strong>: <a href="https://github.com/google/error-prone/compare/v2.17.0...v2.18.0">https://github.com/google/error-prone/compare/v2.17.0...v2.18.0</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="34730decfe
"><code>34730de</code></a> Release Error Prone 2.18.0</li> <li><a href="ee1e7778d3
"><code>ee1e777</code></a> Remove <code>DoNoCall</code> flags for checking <code>Thread.run</code> and various <code>getClass</code> meth...</li> <li><a href="bb9ede9f25
"><code>bb9ede9</code></a> Delete dependabot.yml</li> <li><a href="7f459e14cd
"><code>7f459e1</code></a> Refaster: support method invocation type argument inlining</li> <li><a href="a57309b018
"><code>a57309b</code></a> Add a check to reverse Yoda conditions.</li> <li><a href="181f9918bc
"><code>181f991</code></a> Use <code>ASTHelpers.enclosingClass</code>.</li> <li><a href="360ed99da2
"><code>360ed99</code></a> Don't generate a "Suppression" section that recommends `@SuppressWarnings("Ch...</li> <li><a href="c06c7b8b6e
"><code>c06c7b8</code></a> Look for infinite recursion in the first statement of multi-statement methods.</li> <li><a href="0f5753f67b
"><code>0f5753f</code></a> Reverse Yoda conditions in EP.</li> <li><a href="f36a502b5f
"><code>f36a502</code></a> Make MemoizeConstantVisitorStateLookups check suppressible</li> <li>Additional commits viewable in <a href="https://github.com/google/error-prone/compare/v2.17.0...v2.18.0">compare view</a></li> </ul> </details> <br /> Updates `error_prone_core` from 2.17.0 to 2.18.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/google/error-prone/releases">error_prone_core's releases</a>.</em></p> <blockquote> <h2>Error Prone 2.18.0</h2> <p>New Checkers:</p> <ul> <li><a href="https://errorprone.info/bugpattern/InjectOnBugCheckers"><code>InjectOnBugCheckers</code></a></li> <li><a href="https://errorprone.info/bugpattern/LabelledBreakTarget"><code>LabelledBreakTarget</code></a></li> <li><a href="https://errorprone.info/bugpattern/UnusedLabel"><code>UnusedLabel</code></a></li> <li><a href="https://errorprone.info/bugpattern/YodaCondition"><code>YodaCondition</code></a></li> </ul> <p>Fixes issues: <a href="https://github-redirect.dependabot.com/google/error-prone/issues/1650">#1650</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/2706">#2706</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3404">#3404</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3493">#3493</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3504">#3504</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3519">#3519</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3579">#3579</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3610">#3610</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3632">#3632</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3638">#3638</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3645">#3645</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3646">#3646</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3652">#3652</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3690">#3690</a></p> <p><strong>Full Changelog</strong>: <a href="https://github.com/google/error-prone/compare/v2.17.0...v2.18.0">https://github.com/google/error-prone/compare/v2.17.0...v2.18.0</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="34730decfe
"><code>34730de</code></a> Release Error Prone 2.18.0</li> <li><a href="ee1e7778d3
"><code>ee1e777</code></a> Remove <code>DoNoCall</code> flags for checking <code>Thread.run</code> and various <code>getClass</code> meth...</li> <li><a href="bb9ede9f25
"><code>bb9ede9</code></a> Delete dependabot.yml</li> <li><a href="7f459e14cd
"><code>7f459e1</code></a> Refaster: support method invocation type argument inlining</li> <li><a href="a57309b018
"><code>a57309b</code></a> Add a check to reverse Yoda conditions.</li> <li><a href="181f9918bc
"><code>181f991</code></a> Use <code>ASTHelpers.enclosingClass</code>.</li> <li><a href="360ed99da2
"><code>360ed99</code></a> Don't generate a "Suppression" section that recommends `@SuppressWarnings("Ch...</li> <li><a href="c06c7b8b6e
"><code>c06c7b8</code></a> Look for infinite recursion in the first statement of multi-statement methods.</li> <li><a href="0f5753f67b
"><code>0f5753f</code></a> Reverse Yoda conditions in EP.</li> <li><a href="f36a502b5f
"><code>f36a502</code></a> Make MemoizeConstantVisitorStateLookups check suppressible</li> <li>Additional commits viewable in <a href="https://github.com/google/error-prone/compare/v2.17.0...v2.18.0">compare view</a></li> </ul> </details> <br /> Updates `error_prone_test_helpers` from 2.17.0 to 2.18.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/google/error-prone/releases">error_prone_test_helpers's releases</a>.</em></p> <blockquote> <h2>Error Prone 2.18.0</h2> <p>New Checkers:</p> <ul> <li><a href="https://errorprone.info/bugpattern/InjectOnBugCheckers"><code>InjectOnBugCheckers</code></a></li> <li><a href="https://errorprone.info/bugpattern/LabelledBreakTarget"><code>LabelledBreakTarget</code></a></li> <li><a href="https://errorprone.info/bugpattern/UnusedLabel"><code>UnusedLabel</code></a></li> <li><a href="https://errorprone.info/bugpattern/YodaCondition"><code>YodaCondition</code></a></li> </ul> <p>Fixes issues: <a href="https://github-redirect.dependabot.com/google/error-prone/issues/1650">#1650</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/2706">#2706</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3404">#3404</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3493">#3493</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3504">#3504</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3519">#3519</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3579">#3579</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3610">#3610</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3632">#3632</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3638">#3638</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3645">#3645</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3646">#3646</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3652">#3652</a>, <a href="https://github-redirect.dependabot.com/google/error-prone/issues/3690">#3690</a></p> <p><strong>Full Changelog</strong>: <a href="https://github.com/google/error-prone/compare/v2.17.0...v2.18.0">https://github.com/google/error-prone/compare/v2.17.0...v2.18.0</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="34730decfe
"><code>34730de</code></a> Release Error Prone 2.18.0</li> <li><a href="ee1e7778d3
"><code>ee1e777</code></a> Remove <code>DoNoCall</code> flags for checking <code>Thread.run</code> and various <code>getClass</code> meth...</li> <li><a href="bb9ede9f25
"><code>bb9ede9</code></a> Delete dependabot.yml</li> <li><a href="7f459e14cd
"><code>7f459e1</code></a> Refaster: support method invocation type argument inlining</li> <li><a href="a57309b018
"><code>a57309b</code></a> Add a check to reverse Yoda conditions.</li> <li><a href="181f9918bc
"><code>181f991</code></a> Use <code>ASTHelpers.enclosingClass</code>.</li> <li><a href="360ed99da2
"><code>360ed99</code></a> Don't generate a "Suppression" section that recommends `@SuppressWarnings("Ch...</li> <li><a href="c06c7b8b6e
"><code>c06c7b8</code></a> Look for infinite recursion in the first statement of multi-statement methods.</li> <li><a href="0f5753f67b
"><code>0f5753f</code></a> Reverse Yoda conditions in EP.</li> <li><a href="f36a502b5f
"><code>f36a502</code></a> Make MemoizeConstantVisitorStateLookups check suppressible</li> <li>Additional commits viewable in <a href="https://github.com/google/error-prone/compare/v2.17.0...v2.18.0">compare view</a></li> </ul> </details> <br /> You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
This commit is contained in:
parent
13be0e2307
commit
f335861136
|
@ -38,7 +38,7 @@ val DEPENDENCY_BOMS = listOf(
|
|||
|
||||
val autoServiceVersion = "1.0.1"
|
||||
val autoValueVersion = "1.10.1"
|
||||
val errorProneVersion = "2.17.0"
|
||||
val errorProneVersion = "2.18.0"
|
||||
val byteBuddyVersion = "1.12.20"
|
||||
val asmVersion = "9.4"
|
||||
val jmhVersion = "1.36"
|
||||
|
|
|
@ -62,7 +62,7 @@ public final class InternalNetClientAttributesExtractor<REQUEST, RESPONSE> {
|
|||
}
|
||||
|
||||
String sockFamily = getter.sockFamily(request, response);
|
||||
if (sockFamily != null && !SemanticAttributes.NetSockFamilyValues.INET.equals(sockFamily)) {
|
||||
if (sockFamily != null && !sockFamily.equals(SemanticAttributes.NetSockFamilyValues.INET)) {
|
||||
internalSet(attributes, SemanticAttributes.NET_SOCK_FAMILY, sockFamily);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public final class InternalNetServerAttributesExtractor<REQUEST> {
|
|||
|
||||
if (setSockFamily) {
|
||||
String sockFamily = getter.sockFamily(request);
|
||||
if (sockFamily != null && !SemanticAttributes.NetSockFamilyValues.INET.equals(sockFamily)) {
|
||||
if (sockFamily != null && !sockFamily.equals(SemanticAttributes.NetSockFamilyValues.INET)) {
|
||||
internalSet(attributes, SemanticAttributes.NET_SOCK_FAMILY, sockFamily);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class HttpSpanDecorator extends BaseSpanDecorator {
|
|||
}
|
||||
|
||||
static boolean shouldSetPathAsName(CamelDirection camelDirection) {
|
||||
return CamelDirection.INBOUND.equals(camelDirection);
|
||||
return camelDirection == CamelDirection.INBOUND;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -44,7 +44,7 @@ class MessagingSpanDecorator extends BaseSpanDecorator {
|
|||
public String getOperationName(
|
||||
Exchange exchange, Endpoint endpoint, CamelDirection camelDirection) {
|
||||
|
||||
if ("mqtt".equals(component)) {
|
||||
if (component.equals("mqtt")) {
|
||||
return stripSchemeAndOptions(endpoint);
|
||||
}
|
||||
return getDestination(exchange, endpoint);
|
||||
|
|
|
@ -59,7 +59,7 @@ class CustomJodaModule extends SimpleModule {
|
|||
|
||||
@Override
|
||||
public DateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||
if (JsonTokenId.ID_STRING != p.getCurrentTokenId()) {
|
||||
if (p.getCurrentTokenId() != JsonTokenId.ID_STRING) {
|
||||
throw new IllegalArgumentException("Only stream input is accepted");
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public class MessageServiceImpl extends RemoteServiceServlet implements MessageS
|
|||
|
||||
@Override
|
||||
public String sendMessage(String message) throws IOException {
|
||||
if (message == null || "Error".equals(message)) {
|
||||
if (message == null || message.equals("Error")) {
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public final class OperationNameUtil {
|
|||
}
|
||||
|
||||
public static String getSessionMethodOperationName(String methodName) {
|
||||
if ("fireLock".equals(methodName)) {
|
||||
if (methodName.equals("fireLock")) {
|
||||
return "Session.lock";
|
||||
}
|
||||
return "Session." + methodName;
|
||||
|
|
|
@ -43,11 +43,10 @@ public class GetOutputStreamContext implements ImplicitContextKeyed {
|
|||
String requestMethod) {
|
||||
GetOutputStreamContext getOutputStreamContext = context.get(KEY);
|
||||
String connectionClassName = connectionClass.getName();
|
||||
if ("sun.net.www.protocol.http.HttpURLConnection".equals(connectionClassName)
|
||||
&& "getOutputStream".equals(methodName)
|
||||
&& "POST"
|
||||
.equals(
|
||||
requestMethod) // To be sure that getOutputStream has transformed GET into POST if
|
||||
if (connectionClassName.equals("sun.net.www.protocol.http.HttpURLConnection")
|
||||
&& methodName.equals("getOutputStream")
|
||||
&& requestMethod.equals(
|
||||
"POST") // To be sure that getOutputStream has transformed GET into POST if
|
||||
// the method raised an exception
|
||||
) {
|
||||
getOutputStreamContext.outputStreamMethodOfSunConnectionCalled = true;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class TestInstrumentationModule2 extends InstrumentationModule {
|
|||
|
||||
@Override
|
||||
public boolean isHelperClass(String className) {
|
||||
return "instrumentation.TestFailableCallable".equals(className);
|
||||
return className.equals("instrumentation.TestFailableCallable");
|
||||
}
|
||||
|
||||
public static class TestTypeInstrumentation implements TypeInstrumentation {
|
||||
|
|
|
@ -82,8 +82,8 @@ public class InnerClassLambdaMetafactoryInstrumentation implements TypeInstrumen
|
|||
// This transformation uses ASM instead of Byte-Buddy advice because advice allows adding
|
||||
// code to the start and end of the method, but here we are modifying a call in the middle of
|
||||
// the method.
|
||||
if (("spinInnerClass".equals(name) || "generateInnerClass".equals(name))
|
||||
&& "()Ljava/lang/Class;".equals(descriptor)) {
|
||||
if ((name.equals("spinInnerClass") || name.equals("generateInnerClass"))
|
||||
&& descriptor.equals("()Ljava/lang/Class;")) {
|
||||
mv =
|
||||
new MethodVisitor(api, mv) {
|
||||
@Override
|
||||
|
@ -93,8 +93,8 @@ public class InnerClassLambdaMetafactoryInstrumentation implements TypeInstrumen
|
|||
// if current instruction is a call to ASM ClassWriter.toByteArray() insert call to
|
||||
// our lambda transformer
|
||||
if (opcode == Opcodes.INVOKEVIRTUAL
|
||||
&& "toByteArray".equals(name)
|
||||
&& "()[B".equals(descriptor)) {
|
||||
&& name.equals("toByteArray")
|
||||
&& descriptor.equals("()[B")) {
|
||||
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
||||
mv.visitFieldInsn(
|
||||
Opcodes.GETFIELD, slashClassName, "lambdaClassName", "Ljava/lang/String;");
|
||||
|
|
|
@ -70,9 +70,9 @@ public class ClassInstrumentation implements TypeInstrumentation {
|
|||
public MethodVisitor visitMethod(
|
||||
int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions);
|
||||
if ("getInterfaces".equals(name)
|
||||
&& ("()[Ljava/lang/Class;".equals(descriptor)
|
||||
|| "(Z)[Ljava/lang/Class;".equals(descriptor))) {
|
||||
if (name.equals("getInterfaces")
|
||||
&& (descriptor.equals("()[Ljava/lang/Class;")
|
||||
|| descriptor.equals("(Z)[Ljava/lang/Class;"))) {
|
||||
mv =
|
||||
new MethodVisitor(api, mv) {
|
||||
@Override
|
||||
|
@ -82,12 +82,12 @@ public class ClassInstrumentation implements TypeInstrumentation {
|
|||
// filter the result of call to getInterfaces0, which is used on hotspot, and
|
||||
// J9VMInternals.getInterfaces which is used on openj9
|
||||
if (((opcode == Opcodes.INVOKEVIRTUAL || opcode == Opcodes.INVOKESPECIAL)
|
||||
&& "getInterfaces0".equals(name)
|
||||
&& "()[Ljava/lang/Class;".equals(descriptor))
|
||||
&& name.equals("getInterfaces0")
|
||||
&& descriptor.equals("()[Ljava/lang/Class;"))
|
||||
|| (opcode == Opcodes.INVOKESTATIC
|
||||
&& "getInterfaces".equals(name)
|
||||
&& "java/lang/J9VMInternals".equals(owner)
|
||||
&& "(Ljava/lang/Class;)[Ljava/lang/Class;".equals(descriptor))) {
|
||||
&& name.equals("getInterfaces")
|
||||
&& owner.equals("java/lang/J9VMInternals")
|
||||
&& descriptor.equals("(Ljava/lang/Class;)[Ljava/lang/Class;"))) {
|
||||
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
||||
mv.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
|
|
|
@ -24,7 +24,7 @@ public final class JaxrsContextPath {
|
|||
|
||||
@Nullable
|
||||
public static Context init(Context context, String path) {
|
||||
if (path == null || path.isEmpty() || "/".equals(path)) {
|
||||
if (path == null || path.isEmpty() || path.equals("/")) {
|
||||
return null;
|
||||
}
|
||||
// normalize path to have a leading slash and no trailing slash
|
||||
|
|
|
@ -10,7 +10,7 @@ public final class JaxrsPathUtil {
|
|||
|
||||
public static String normalizePath(String path) {
|
||||
// ensure that non-empty path starts with /
|
||||
if (path == null || "/".equals(path)) {
|
||||
if (path == null || path.equals("/")) {
|
||||
path = "";
|
||||
} else if (!path.startsWith("/")) {
|
||||
path = "/" + path;
|
||||
|
|
|
@ -7,7 +7,7 @@ public class TomeeArquillianJaxWsTest extends AbstractArquillianJaxWsTest {
|
|||
|
||||
@Override
|
||||
protected String getServicePath(String service) {
|
||||
if ("EjbHelloService".equals(service)) {
|
||||
if (service.equals("EjbHelloService")) {
|
||||
service = "webservices/EjbHelloServiceImpl";
|
||||
}
|
||||
return service;
|
||||
|
|
|
@ -7,7 +7,7 @@ public class WildflyArquillianJaxWsTest extends AbstractArquillianJaxWsTest {
|
|||
|
||||
@Override
|
||||
protected String getServicePath(String service) {
|
||||
if ("EjbHelloService".equals(service)) {
|
||||
if (service.equals("EjbHelloService")) {
|
||||
service = "EjbHelloService/EjbHelloServiceImpl";
|
||||
}
|
||||
return service;
|
||||
|
|
|
@ -21,6 +21,7 @@ import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
|
|||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
@ -57,7 +58,9 @@ public class JbossExtLogRecordInstrumentation implements TypeInstrumentation {
|
|||
@Advice.This ExtLogRecord record,
|
||||
@Advice.Argument(0) String key,
|
||||
@Advice.Return(readOnly = false) String value) {
|
||||
if (TRACE_ID.equals(key) || SPAN_ID.equals(key) || TRACE_FLAGS.equals(key)) {
|
||||
if (Objects.equals(key, TRACE_ID)
|
||||
|| Objects.equals(key, SPAN_ID)
|
||||
|| Objects.equals(key, TRACE_FLAGS)) {
|
||||
if (value != null) {
|
||||
// Assume already instrumented event if traceId/spanId/sampled is present.
|
||||
return;
|
||||
|
|
|
@ -9,6 +9,7 @@ package io.opentelemetry.instrumentation.jmx.engine;
|
|||
// because it needs to access package-private methods from a number of classes.
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
|
||||
import io.opentelemetry.instrumentation.jmx.yaml.JmxConfig;
|
||||
import io.opentelemetry.instrumentation.jmx.yaml.JmxRule;
|
||||
|
@ -16,10 +17,9 @@ import io.opentelemetry.instrumentation.jmx.yaml.Metric;
|
|||
import io.opentelemetry.instrumentation.jmx.yaml.RuleParser;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -28,7 +28,7 @@ class RuleParserTest {
|
|||
private static RuleParser parser;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() throws Exception {
|
||||
static void setup() {
|
||||
parser = RuleParser.get();
|
||||
assertThat(parser == null).isFalse();
|
||||
}
|
||||
|
@ -68,28 +68,26 @@ class RuleParserTest {
|
|||
|
||||
@Test
|
||||
void testConf2() throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(CONF2.getBytes(Charset.forName("UTF-8")));
|
||||
InputStream is = new ByteArrayInputStream(CONF2.getBytes(StandardCharsets.UTF_8));
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config != null).isTrue();
|
||||
assertThat(config).isNotNull();
|
||||
|
||||
List<JmxRule> defs = config.getRules();
|
||||
assertThat(defs.size() == 2).isTrue();
|
||||
assertThat(defs).hasSize(2);
|
||||
|
||||
JmxRule def1 = defs.get(0);
|
||||
assertThat(def1.getBeans().size() == 2).isTrue();
|
||||
assertThat(def1.getMetricAttribute().size() == 2).isTrue();
|
||||
assertThat(def1.getBeans()).hasSize(2);
|
||||
assertThat(def1.getMetricAttribute()).hasSize(2);
|
||||
|
||||
Map<String, Metric> attr = def1.getMapping();
|
||||
assertThat(attr == null).isFalse();
|
||||
assertThat(attr.size() == 4).isTrue();
|
||||
assertThat(attr).hasSize(4);
|
||||
|
||||
Metric m1 = attr.get("ATTRIBUTE1");
|
||||
assertThat(m1 == null).isFalse();
|
||||
assertThat("METRIC_NAME1".equals(m1.getMetric())).isTrue();
|
||||
assertThat(m1.getMetricType() == MetricInfo.Type.GAUGE).isTrue();
|
||||
assertThat("UNIT1".equals(m1.getUnit())).isTrue();
|
||||
assertThat(m1.getMetricAttribute() == null).isFalse();
|
||||
assertThat(m1.getMetricAttribute().size() == 1).isTrue();
|
||||
assertThat("const(CONSTANT)".equals(m1.getMetricAttribute().get("LABEL_KEY3"))).isTrue();
|
||||
assertThat(m1).isNotNull();
|
||||
assertThat(m1.getMetric()).isEqualTo("METRIC_NAME1");
|
||||
assertThat(m1.getMetricType()).isEqualTo(MetricInfo.Type.GAUGE);
|
||||
assertThat(m1.getUnit()).isEqualTo("UNIT1");
|
||||
assertThat(m1.getMetricAttribute()).containsExactly(entry("LABEL_KEY3", "const(CONSTANT)"));
|
||||
}
|
||||
|
||||
private static final String CONF3 =
|
||||
|
@ -105,23 +103,21 @@ class RuleParserTest {
|
|||
|
||||
@Test
|
||||
void testConf3() throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(CONF3.getBytes(Charset.forName("UTF-8")));
|
||||
InputStream is = new ByteArrayInputStream(CONF3.getBytes(StandardCharsets.UTF_8));
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config != null).isTrue();
|
||||
assertThat(config).isNotNull();
|
||||
|
||||
List<JmxRule> defs = config.getRules();
|
||||
assertThat(defs.size() == 1).isTrue();
|
||||
assertThat(defs).hasSize(1);
|
||||
|
||||
JmxRule def1 = defs.get(0);
|
||||
assertThat(def1.getBean() == null).isFalse();
|
||||
assertThat(def1.getMetricAttribute() == null).isTrue();
|
||||
Map<String, Metric> attr = def1.getMapping();
|
||||
assertThat(attr.size() == 5).isTrue();
|
||||
assertThat(def1.getBean()).isNotNull();
|
||||
assertThat(def1.getMetricAttribute()).isNull();
|
||||
|
||||
Set<String> keys = attr.keySet();
|
||||
assertThat(keys.contains("ATTRIBUTE33")).isTrue();
|
||||
assertThat(attr.get("ATTRIBUTE33") == null).isTrue();
|
||||
assertThat(attr.get("ATTRIBUTE34") == null).isFalse();
|
||||
Map<String, Metric> attr = def1.getMapping();
|
||||
assertThat(attr).hasSize(5).containsKey("ATTRIBUTE33");
|
||||
assertThat(attr.get("ATTRIBUTE33")).isNull();
|
||||
assertThat(attr.get("ATTRIBUTE34")).isNotNull();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -153,35 +149,35 @@ class RuleParserTest {
|
|||
|
||||
@Test
|
||||
void testConf4() throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(CONF4.getBytes(Charset.forName("UTF-8")));
|
||||
InputStream is = new ByteArrayInputStream(CONF4.getBytes(StandardCharsets.UTF_8));
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config != null).isTrue();
|
||||
assertThat(config).isNotNull();
|
||||
|
||||
List<JmxRule> defs = config.getRules();
|
||||
assertThat(defs.size() == 1).isTrue();
|
||||
assertThat(defs).hasSize(1);
|
||||
|
||||
MetricDef metricDef = defs.get(0).buildMetricDef();
|
||||
assertThat(metricDef == null).isFalse();
|
||||
assertThat(metricDef.getMetricExtractors().length == 3).isTrue();
|
||||
assertThat(metricDef).isNotNull();
|
||||
assertThat(metricDef.getMetricExtractors()).hasSize(3);
|
||||
|
||||
MetricExtractor m1 = metricDef.getMetricExtractors()[0];
|
||||
BeanAttributeExtractor a1 = m1.getMetricValueExtractor();
|
||||
assertThat("A.b".equals(a1.getAttributeName())).isTrue();
|
||||
assertThat(m1.getAttributes().length == 3).isTrue();
|
||||
assertThat(m1.getMetricValueExtractor().getAttributeName()).isEqualTo("A.b");
|
||||
assertThat(m1.getAttributes()).hasSize(3);
|
||||
|
||||
MetricInfo mb1 = m1.getInfo();
|
||||
assertThat("PREFIX.METRIC_NAME1".equals(mb1.getMetricName())).isTrue();
|
||||
assertThat("DESCRIPTION1".equals(mb1.getDescription())).isTrue();
|
||||
assertThat("UNIT1".equals(mb1.getUnit())).isTrue();
|
||||
assertThat(MetricInfo.Type.COUNTER == mb1.getType()).isTrue();
|
||||
assertThat(mb1.getMetricName()).isEqualTo("PREFIX.METRIC_NAME1");
|
||||
assertThat(mb1.getDescription()).isEqualTo("DESCRIPTION1");
|
||||
assertThat(mb1.getUnit()).isEqualTo("UNIT1");
|
||||
assertThat(mb1.getType()).isEqualTo(MetricInfo.Type.COUNTER);
|
||||
|
||||
MetricExtractor m3 = metricDef.getMetricExtractors()[2];
|
||||
BeanAttributeExtractor a3 = m3.getMetricValueExtractor();
|
||||
assertThat("ATTRIBUTE3".equals(a3.getAttributeName())).isTrue();
|
||||
assertThat(m3.getMetricValueExtractor().getAttributeName()).isEqualTo("ATTRIBUTE3");
|
||||
|
||||
MetricInfo mb3 = m3.getInfo();
|
||||
assertThat("PREFIX.ATTRIBUTE3".equals(mb3.getMetricName())).isTrue();
|
||||
assertThat(mb3.getMetricName()).isEqualTo("PREFIX.ATTRIBUTE3");
|
||||
// syntax extension - defining a default unit and type
|
||||
assertThat(MetricInfo.Type.UPDOWNCOUNTER == mb3.getType()).isTrue();
|
||||
assertThat("DEFAULT_UNIT".equals(mb3.getUnit())).isTrue();
|
||||
assertThat(mb3.getType()).isEqualTo(MetricInfo.Type.UPDOWNCOUNTER);
|
||||
assertThat(mb3.getUnit()).isEqualTo("DEFAULT_UNIT");
|
||||
}
|
||||
|
||||
private static final String CONF5 = // minimal valid definition
|
||||
|
@ -193,25 +189,25 @@ class RuleParserTest {
|
|||
|
||||
@Test
|
||||
void testConf5() throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(CONF5.getBytes(Charset.forName("UTF-8")));
|
||||
InputStream is = new ByteArrayInputStream(CONF5.getBytes(StandardCharsets.UTF_8));
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config != null).isTrue();
|
||||
assertThat(config).isNotNull();
|
||||
|
||||
List<JmxRule> defs = config.getRules();
|
||||
assertThat(defs.size() == 1).isTrue();
|
||||
assertThat(defs).hasSize(1);
|
||||
|
||||
MetricDef metricDef = defs.get(0).buildMetricDef();
|
||||
assertThat(metricDef == null).isFalse();
|
||||
assertThat(metricDef.getMetricExtractors().length == 1).isTrue();
|
||||
assertThat(metricDef).isNotNull();
|
||||
assertThat(metricDef.getMetricExtractors()).hasSize(1);
|
||||
|
||||
MetricExtractor m1 = metricDef.getMetricExtractors()[0];
|
||||
BeanAttributeExtractor a1 = m1.getMetricValueExtractor();
|
||||
assertThat("ATTRIBUTE".equals(a1.getAttributeName())).isTrue();
|
||||
assertThat(m1.getAttributes().length == 0).isTrue();
|
||||
assertThat(m1.getMetricValueExtractor().getAttributeName()).isEqualTo("ATTRIBUTE");
|
||||
assertThat(m1.getAttributes()).isEmpty();
|
||||
|
||||
MetricInfo mb1 = m1.getInfo();
|
||||
assertThat("ATTRIBUTE".equals(mb1.getMetricName())).isTrue();
|
||||
assertThat(MetricInfo.Type.GAUGE == mb1.getType()).isTrue();
|
||||
assertThat(null == mb1.getUnit()).isTrue();
|
||||
assertThat(mb1.getMetricName()).isEqualTo("ATTRIBUTE");
|
||||
assertThat(mb1.getType()).isEqualTo(MetricInfo.Type.GAUGE);
|
||||
assertThat(mb1.getUnit()).isNull();
|
||||
}
|
||||
|
||||
private static final String CONF6 = // merging metric attribute sets with same keys
|
||||
|
@ -227,26 +223,25 @@ class RuleParserTest {
|
|||
|
||||
@Test
|
||||
void testConf6() throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(CONF6.getBytes(Charset.forName("UTF-8")));
|
||||
InputStream is = new ByteArrayInputStream(CONF6.getBytes(StandardCharsets.UTF_8));
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config != null).isTrue();
|
||||
assertThat(config).isNotNull();
|
||||
|
||||
List<JmxRule> defs = config.getRules();
|
||||
assertThat(defs.size() == 1).isTrue();
|
||||
assertThat(defs).hasSize(1);
|
||||
|
||||
MetricDef metricDef = defs.get(0).buildMetricDef();
|
||||
assertThat(metricDef == null).isFalse();
|
||||
assertThat(metricDef.getMetricExtractors().length == 1).isTrue();
|
||||
assertThat(metricDef).isNotNull();
|
||||
assertThat(metricDef.getMetricExtractors()).hasSize(1);
|
||||
|
||||
MetricExtractor m1 = metricDef.getMetricExtractors()[0];
|
||||
BeanAttributeExtractor a1 = m1.getMetricValueExtractor();
|
||||
assertThat("ATTRIBUTE".equals(a1.getAttributeName())).isTrue();
|
||||
assertThat(m1.getMetricValueExtractor().getAttributeName()).isEqualTo("ATTRIBUTE");
|
||||
// MetricAttribute set at the metric level should override the one set at the definition level
|
||||
assertThat(m1.getAttributes().length == 1).isTrue();
|
||||
assertThat(m1.getAttributes()).hasSize(1);
|
||||
assertThat(m1.getInfo().getMetricName()).isEqualTo("ATTRIBUTE");
|
||||
|
||||
MetricAttribute l1 = m1.getAttributes()[0];
|
||||
assertThat("value2".equals(l1.acquireAttributeValue(null, null))).isTrue();
|
||||
MetricInfo mb1 = m1.getInfo();
|
||||
assertThat("ATTRIBUTE".equals(mb1.getMetricName())).isTrue();
|
||||
assertThat(l1.acquireAttributeValue(null, null)).isEqualTo("value2");
|
||||
}
|
||||
|
||||
private static final String CONF7 =
|
||||
|
@ -262,56 +257,54 @@ class RuleParserTest {
|
|||
|
||||
@Test
|
||||
void testConf7() throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(CONF7.getBytes(Charset.forName("UTF-8")));
|
||||
InputStream is = new ByteArrayInputStream(CONF7.getBytes(StandardCharsets.UTF_8));
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config != null).isTrue();
|
||||
assertThat(config).isNotNull();
|
||||
|
||||
List<JmxRule> defs = config.getRules();
|
||||
assertThat(defs.size() == 1).isTrue();
|
||||
assertThat(defs).hasSize(1);
|
||||
|
||||
MetricDef metricDef = defs.get(0).buildMetricDef();
|
||||
assertThat(metricDef == null).isFalse();
|
||||
assertThat(metricDef.getMetricExtractors().length == 1).isTrue();
|
||||
assertThat(metricDef).isNotNull();
|
||||
assertThat(metricDef.getMetricExtractors()).hasSize(1);
|
||||
|
||||
// Test that the MBean attribute is correctly parsed
|
||||
MetricExtractor m1 = metricDef.getMetricExtractors()[0];
|
||||
BeanAttributeExtractor a1 = m1.getMetricValueExtractor();
|
||||
assertThat("ATTRIBUTE".equals(a1.getAttributeName())).isTrue();
|
||||
assertThat(m1.getAttributes().length == 2).isTrue();
|
||||
MetricInfo mb1 = m1.getInfo();
|
||||
assertThat("ATTRIBUTE".equals(mb1.getMetricName())).isTrue();
|
||||
assertThat(m1.getMetricValueExtractor().getAttributeName()).isEqualTo("ATTRIBUTE");
|
||||
assertThat(m1.getAttributes()).hasSize(2);
|
||||
assertThat(m1.getInfo().getMetricName()).isEqualTo("ATTRIBUTE");
|
||||
}
|
||||
|
||||
private static final String EMPTY_CONF = "---\n";
|
||||
|
||||
@Test
|
||||
void testEmptyConf() throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(EMPTY_CONF.getBytes(Charset.forName("UTF-8")));
|
||||
InputStream is = new ByteArrayInputStream(EMPTY_CONF.getBytes(StandardCharsets.UTF_8));
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config == null).isTrue();
|
||||
assertThat(config).isNull();
|
||||
}
|
||||
|
||||
/*
|
||||
* Negative tests
|
||||
*/
|
||||
|
||||
private static void runNegativeTest(String yaml) throws Exception {
|
||||
InputStream is = new ByteArrayInputStream(yaml.getBytes(Charset.forName("UTF-8")));
|
||||
private static void runNegativeTest(String yaml) {
|
||||
InputStream is = new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
Assertions.assertThrows(
|
||||
Exception.class,
|
||||
() -> {
|
||||
JmxConfig config = parser.loadConfig(is);
|
||||
assertThat(config != null).isTrue();
|
||||
assertThat(config).isNotNull();
|
||||
|
||||
List<JmxRule> defs = config.getRules();
|
||||
assertThat(defs.size() == 1).isTrue();
|
||||
assertThat(defs).hasSize(1);
|
||||
defs.get(0).buildMetricDef();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoBeans() throws Exception {
|
||||
void testNoBeans() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules: # no bean\n"
|
||||
|
@ -322,7 +315,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testInvalidObjectName() throws Exception {
|
||||
void testInvalidObjectName() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules:\n"
|
||||
|
@ -334,7 +327,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testEmptyMapping() throws Exception {
|
||||
void testEmptyMapping() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n "
|
||||
+ "rules:\n"
|
||||
|
@ -344,7 +337,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testInvalidAttributeName() throws Exception {
|
||||
void testInvalidAttributeName() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules:\n"
|
||||
|
@ -356,7 +349,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testInvalidTag() throws Exception {
|
||||
void testInvalidTag() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules:\n"
|
||||
|
@ -370,7 +363,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testInvalidType() throws Exception {
|
||||
void testInvalidType() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules:\n"
|
||||
|
@ -383,7 +376,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testInvalidTagFromAttribute() throws Exception {
|
||||
void testInvalidTagFromAttribute() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules:\n"
|
||||
|
@ -397,7 +390,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testEmptyTagFromAttribute() throws Exception {
|
||||
void testEmptyTagFromAttribute() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules:\n"
|
||||
|
@ -411,7 +404,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testEmptyTagFromParameter() throws Exception {
|
||||
void testEmptyTagFromParameter() {
|
||||
String yaml =
|
||||
"--- # keep stupid spotlessJava at bay\n"
|
||||
+ "rules:\n"
|
||||
|
@ -425,7 +418,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testEmptyPrefix() throws Exception {
|
||||
void testEmptyPrefix() {
|
||||
String yaml =
|
||||
"---\n"
|
||||
+ "rules:\n"
|
||||
|
@ -438,7 +431,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testTypoInMetric() throws Exception {
|
||||
void testTypoInMetric() {
|
||||
String yaml =
|
||||
"---\n"
|
||||
+ "rules:\n"
|
||||
|
@ -450,7 +443,7 @@ class RuleParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testMessedUpSyntax() throws Exception {
|
||||
void testMessedUpSyntax() {
|
||||
String yaml =
|
||||
"---\n"
|
||||
+ "rules:\n"
|
||||
|
|
|
@ -89,7 +89,7 @@ public final class KafkaTelemetry {
|
|||
(proxy, method, args) -> {
|
||||
// Future<RecordMetadata> send(ProducerRecord<K, V> record)
|
||||
// Future<RecordMetadata> send(ProducerRecord<K, V> record, Callback callback)
|
||||
if ("send".equals(method.getName())
|
||||
if (method.getName().equals("send")
|
||||
&& method.getParameterCount() >= 1
|
||||
&& method.getParameterTypes()[0] == ProducerRecord.class) {
|
||||
ProducerRecord<K, V> record = (ProducerRecord<K, V>) args[0];
|
||||
|
@ -124,7 +124,7 @@ public final class KafkaTelemetry {
|
|||
}
|
||||
// ConsumerRecords<K, V> poll(long timeout)
|
||||
// ConsumerRecords<K, V> poll(Duration duration)
|
||||
if ("poll".equals(method.getName()) && result instanceof ConsumerRecords) {
|
||||
if (method.getName().equals("poll") && result instanceof ConsumerRecords) {
|
||||
buildAndFinishSpan((ConsumerRecords) result);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -56,10 +56,9 @@ public class LettuceFluxTerminationRunnable implements Consumer<Signal<?>>, Runn
|
|||
|
||||
@Override
|
||||
public void accept(Signal<?> signal) {
|
||||
if (SignalType.ON_COMPLETE.equals(signal.getType())
|
||||
|| SignalType.ON_ERROR.equals(signal.getType())) {
|
||||
if (signal.getType() == SignalType.ON_COMPLETE || signal.getType() == SignalType.ON_ERROR) {
|
||||
finishSpan(/* isCommandCancelled= */ false, signal.getThrowable());
|
||||
} else if (SignalType.ON_NEXT.equals(signal.getType())) {
|
||||
} else if (signal.getType() == SignalType.ON_NEXT) {
|
||||
++numResults;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.opentelemetry.instrumentation.api.util.VirtualField;
|
|||
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
|
||||
import java.util.Objects;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
@ -50,7 +51,9 @@ public class LoggingEventInstrumentation implements TypeInstrumentation {
|
|||
@Advice.This LoggingEvent event,
|
||||
@Advice.Argument(0) String key,
|
||||
@Advice.Return(readOnly = false) Object value) {
|
||||
if (TRACE_ID.equals(key) || SPAN_ID.equals(key) || TRACE_FLAGS.equals(key)) {
|
||||
if (Objects.equals(key, TRACE_ID)
|
||||
|| Objects.equals(key, SPAN_ID)
|
||||
|| Objects.equals(key, TRACE_FLAGS)) {
|
||||
if (value != null) {
|
||||
// Assume already instrumented event if traceId/spanId/sampled is present.
|
||||
return;
|
||||
|
|
|
@ -111,7 +111,7 @@ public abstract class AbstractNetty41ClientTest
|
|||
protected Set<AttributeKey<?>> httpAttributes(URI uri) {
|
||||
String uriString = uri.toString();
|
||||
// http://localhost:61/ => unopened port, https://192.0.2.1/ => non routable address
|
||||
if ("http://localhost:61/".equals(uriString) || "https://192.0.2.1/".equals(uriString)) {
|
||||
if (uriString.equals("http://localhost:61/") || uriString.equals("https://192.0.2.1/")) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<AttributeKey<?>> attributes = super.httpAttributes(uri);
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.netty.handler.ssl.SslContext;
|
|||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -100,9 +101,9 @@ public class Netty41ClientExtension implements BeforeAllCallback, AfterAllCallba
|
|||
}
|
||||
|
||||
public Bootstrap getBootstrap(URI uri) {
|
||||
if ("https".equals(uri.getScheme())) {
|
||||
if (Objects.equals(uri.getScheme(), "https")) {
|
||||
return httpsBootstrap;
|
||||
} else if ("/read-timeout".equals(uri.getPath())) {
|
||||
} else if (Objects.equals(uri.getPath(), "/read-timeout")) {
|
||||
return readTimeoutBootstrap;
|
||||
}
|
||||
return httpBootstrap;
|
||||
|
|
|
@ -102,9 +102,10 @@ public class OkHttp2Test extends AbstractHttpClientTest<Request> {
|
|||
|
||||
// flavor is extracted from the response, and those URLs cause exceptions (= null
|
||||
// response)
|
||||
if ("http://localhost:61/".equals(uri.toString())
|
||||
|| "https://192.0.2.1/".equals(uri.toString())
|
||||
|| resolveAddress("/read-timeout").toString().equals(uri.toString())) {
|
||||
String uriString = uri.toString();
|
||||
if (uriString.equals("http://localhost:61/")
|
||||
|| uriString.equals("https://192.0.2.1/")
|
||||
|| uriString.equals(resolveAddress("/read-timeout").toString())) {
|
||||
attributes.remove(SemanticAttributes.HTTP_FLAVOR);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,8 +120,8 @@ public abstract class AbstractOkHttp3Test extends AbstractHttpClientTest<Request
|
|||
|
||||
// flavor is extracted from the response, and those URLs cause exceptions (= null
|
||||
// response)
|
||||
if ("http://localhost:61/".equals(uri.toString())
|
||||
|| "https://192.0.2.1/".equals(uri.toString())
|
||||
if (uri.toString().equals("http://localhost:61/")
|
||||
|| uri.toString().equals("https://192.0.2.1/")
|
||||
|| resolveAddress("/read-timeout").toString().equals(uri.toString())) {
|
||||
attributes.remove(SemanticAttributes.HTTP_FLAVOR);
|
||||
}
|
||||
|
|
|
@ -111,8 +111,8 @@ abstract class AbstractReactorNettyHttpClientTest
|
|||
(uri, exception) -> {
|
||||
if (exception.getClass().getName().endsWith("ReactiveException")) {
|
||||
// unopened port or non routable address
|
||||
if ("http://localhost:61/".equals(uri.toString())
|
||||
|| "https://192.0.2.1/".equals(uri.toString())) {
|
||||
if (uri.toString().equals("http://localhost:61/")
|
||||
|| uri.toString().equals("https://192.0.2.1/")) {
|
||||
exception = exception.getCause();
|
||||
}
|
||||
}
|
||||
|
@ -124,8 +124,8 @@ abstract class AbstractReactorNettyHttpClientTest
|
|||
|
||||
protected Set<AttributeKey<?>> getHttpAttributes(URI uri) {
|
||||
// unopened port or non routable address
|
||||
if ("http://localhost:61/".equals(uri.toString())
|
||||
|| "https://192.0.2.1/".equals(uri.toString())) {
|
||||
if (uri.toString().equals("http://localhost:61/")
|
||||
|| uri.toString().equals("https://192.0.2.1/")) {
|
||||
return emptySet();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -71,14 +72,15 @@ public final class JarServiceNameDetector implements ConditionalResourceProvider
|
|||
Map<String, String> resourceAttributes = config.getMap("otel.resource.attributes");
|
||||
return serviceName == null
|
||||
&& !resourceAttributes.containsKey(ResourceAttributes.SERVICE_NAME.getKey())
|
||||
&& "unknown_service:java".equals(existing.getAttribute(ResourceAttributes.SERVICE_NAME));
|
||||
&& Objects.equals(
|
||||
existing.getAttribute(ResourceAttributes.SERVICE_NAME), "unknown_service:java");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Path getJarPathFromProcessHandle() {
|
||||
String[] javaArgs = getProcessHandleArguments.get();
|
||||
for (int i = 0; i < javaArgs.length; ++i) {
|
||||
if ("-jar".equals(javaArgs[i]) && (i < javaArgs.length - 1)) {
|
||||
if (javaArgs[i].equals("-jar") && (i < javaArgs.length - 1)) {
|
||||
return Paths.get(javaArgs[i + 1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class JarServiceNameDetectorTest {
|
|||
@ArgumentsSource(SunCommandLineProvider.class)
|
||||
void createResource_sunCommandLine(String commandLine, Path jarPath) {
|
||||
Function<String, String> getProperty =
|
||||
key -> "sun.java.command".equals(key) ? commandLine : null;
|
||||
key -> key.equals("sun.java.command") ? commandLine : null;
|
||||
Predicate<Path> fileExists = jarPath::equals;
|
||||
|
||||
JarServiceNameDetector serviceNameProvider =
|
||||
|
|
|
@ -69,7 +69,7 @@ public class RmiClientContextInstrumentation implements TypeInstrumentation {
|
|||
(builder, typeDescription, classLoader, javaModule, protectionDomain) -> {
|
||||
if (JavaModule.isSupported()
|
||||
&& classLoader == null
|
||||
&& "sun.rmi.transport.StreamRemoteCall".equals(typeDescription.getName())
|
||||
&& typeDescription.getName().equals("sun.rmi.transport.StreamRemoteCall")
|
||||
&& javaModule != null) {
|
||||
Instrumentation instrumentation = InstrumentationHolder.getInstrumentation();
|
||||
ClassInjector.UsingInstrumentation.redefineModule(
|
||||
|
|
|
@ -86,7 +86,7 @@ final class RocketMqInstrumenterFactory {
|
|||
.addAttributesExtractor(RocketMqConsumerProcessAttributeExtractor.INSTANCE)
|
||||
.setSpanStatusExtractor(
|
||||
(spanStatusBuilder, messageView, consumeResult, error) -> {
|
||||
if (error != null || ConsumeResult.FAILURE.equals(consumeResult)) {
|
||||
if (error != null || consumeResult == ConsumeResult.FAILURE) {
|
||||
spanStatusBuilder.setStatus(StatusCode.ERROR);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -80,7 +81,7 @@ public final class MappingResolver {
|
|||
if (matcher.match(path)) {
|
||||
String mapping = matcher.getMapping();
|
||||
// for jsp return servlet path
|
||||
if ("/*.jsp".equals(mapping) || "/*.jspx".equals(mapping)) {
|
||||
if (Objects.equals(mapping, "/*.jsp") || Objects.equals(mapping, "/*.jspx")) {
|
||||
return servletPath;
|
||||
}
|
||||
return mapping;
|
||||
|
|
|
@ -106,7 +106,8 @@ public class SpringBootServiceNameDetector implements ConditionalResourceProvide
|
|||
Map<String, String> resourceAttributes = config.getMap("otel.resource.attributes");
|
||||
return serviceName == null
|
||||
&& !resourceAttributes.containsKey(ResourceAttributes.SERVICE_NAME.getKey())
|
||||
&& "unknown_service:java".equals(resource.getAttribute(ResourceAttributes.SERVICE_NAME));
|
||||
&& Objects.equals(
|
||||
resource.getAttribute(ResourceAttributes.SERVICE_NAME), "unknown_service:java");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.lang.invoke.MethodType;
|
|||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
|
@ -242,7 +243,8 @@ final class TracingChannelInterceptor implements ExecutorChannelInterceptor {
|
|||
}
|
||||
|
||||
try {
|
||||
return "output".equals(channelGetAttributeMh.invoke(messageChannel, "type"));
|
||||
String type = (String) channelGetAttributeMh.invoke(messageChannel, "type");
|
||||
return Objects.equals(type, "output");
|
||||
} catch (Throwable throwable) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class TestWebSpringBootApp {
|
|||
return controller(
|
||||
INDEXED_CHILD,
|
||||
() -> {
|
||||
INDEXED_CHILD.collectSpanAttributes(name -> "id".equals(name) ? id : null);
|
||||
INDEXED_CHILD.collectSpanAttributes(name -> name.equals("id") ? id : null);
|
||||
return INDEXED_CHILD.getBody();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.code.CodeAttributesExtr
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.util.SpanNames;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.ExperimentalConfig;
|
||||
import java.util.Objects;
|
||||
|
||||
public class VaadinSingletons {
|
||||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.vaadin-14.2";
|
||||
|
@ -85,7 +86,7 @@ public class VaadinSingletons {
|
|||
RpcInvocationHandler rpcInvocationHandler = rpcRequest.getRpcInvocationHandler();
|
||||
String spanName =
|
||||
SpanNames.fromMethod(rpcInvocationHandler.getClass(), rpcRequest.getMethodName());
|
||||
if ("event".equals(rpcInvocationHandler.getRpcType())) {
|
||||
if (Objects.equals(rpcInvocationHandler.getRpcType(), "event")) {
|
||||
String eventType = rpcRequest.getJsonObject().getString("event");
|
||||
if (eventType != null) {
|
||||
// append event type to make span name more descriptive
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.security.CodeSource;
|
|||
import java.security.Permission;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Objects;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
@ -123,7 +124,7 @@ public class AgentClassLoader extends URLClassLoader {
|
|||
|
||||
private static int getJavaVersion() {
|
||||
String javaSpecVersion = System.getProperty("java.specification.version");
|
||||
if ("1.8".equals(javaSpecVersion)) {
|
||||
if (Objects.equals(javaSpecVersion, "1.8")) {
|
||||
return 8;
|
||||
}
|
||||
return Integer.parseInt(javaSpecVersion);
|
||||
|
@ -133,7 +134,7 @@ public class AgentClassLoader extends URLClassLoader {
|
|||
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
// ContextStorageOverride is meant for library instrumentation we don't want it to apply to our
|
||||
// bundled grpc
|
||||
if ("io.grpc.override.ContextStorageOverride".equals(name)) {
|
||||
if (Objects.equals(name, "io.grpc.override.ContextStorageOverride")) {
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public final class InstrumentedTaskClasses {
|
|||
// to exclude them here too.
|
||||
ClassLoader taskClassLoader = taskClass.getClassLoader();
|
||||
if (taskClassLoader != null
|
||||
&& AGENT_CLASSLOADER_NAME.equals(taskClassLoader.getClass().getName())) {
|
||||
&& taskClassLoader.getClass().getName().equals(AGENT_CLASSLOADER_NAME)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -109,7 +109,7 @@ public class AgentStarterImpl implements AgentStarter {
|
|||
Class<?> classBeingRedefined,
|
||||
ProtectionDomain protectionDomain,
|
||||
byte[] classfileBuffer) {
|
||||
if (!"sun/launcher/LauncherHelper".equals(className)) {
|
||||
if (!className.equals("sun/launcher/LauncherHelper")) {
|
||||
return null;
|
||||
}
|
||||
transformed = true;
|
||||
|
@ -121,7 +121,7 @@ public class AgentStarterImpl implements AgentStarter {
|
|||
public MethodVisitor visitMethod(
|
||||
int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions);
|
||||
if ("checkAndLoadMain".equals(name)) {
|
||||
if (name.equals("checkAndLoadMain")) {
|
||||
return new MethodVisitor(api, mv) {
|
||||
@Override
|
||||
public void visitCode() {
|
||||
|
|
|
@ -31,7 +31,7 @@ class RemappingUrlStreamHandler extends URLStreamHandler {
|
|||
@Override
|
||||
protected URLConnection openConnection(URL url) throws IOException {
|
||||
String file = url.getFile();
|
||||
if ("/".equals(file)) {
|
||||
if (file.equals("/")) {
|
||||
// "/" is used as the default url of the jar
|
||||
// This is called by the SecureClassLoader trying to obtain permissions
|
||||
// nullInputStream() is not available until Java 11
|
||||
|
|
|
@ -119,10 +119,10 @@ final class VirtualFieldImplementationsGenerator {
|
|||
@Override
|
||||
public MethodVisitor visitMethod(
|
||||
int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||
if ("realGet".equals(name)) {
|
||||
if (name.equals("realGet")) {
|
||||
generateRealGetMethod(name);
|
||||
return null;
|
||||
} else if ("realPut".equals(name)) {
|
||||
} else if (name.equals("realPut")) {
|
||||
generateRealPutMethod(name);
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
@ -274,7 +274,7 @@ public class AgentCachingPoolStrategy implements AgentBuilder.PoolStrategy {
|
|||
return existingResolution;
|
||||
}
|
||||
|
||||
if (OBJECT_NAME.equals(className)) {
|
||||
if (className.equals(OBJECT_NAME)) {
|
||||
return OBJECT_RESOLUTION;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ public class AgentCachingPoolStrategy implements AgentBuilder.PoolStrategy {
|
|||
|
||||
@Override
|
||||
public TypePool.Resolution register(String className, TypePool.Resolution resolution) {
|
||||
if (OBJECT_NAME.equals(className)) {
|
||||
if (className.equals(OBJECT_NAME)) {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ interface HelperReferenceWrapper {
|
|||
private boolean isOverrideable(MethodRef method) {
|
||||
return !(method.getFlags().contains(OwnershipFlag.STATIC)
|
||||
|| method.getFlags().contains(VisibilityFlag.PRIVATE)
|
||||
|| CONSTRUCTOR_INTERNAL_NAME.equals(method.getName()));
|
||||
|| method.getName().equals(CONSTRUCTOR_INTERNAL_NAME));
|
||||
}
|
||||
|
||||
private Method toMethod(MethodRef method) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.HashSet;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
|
@ -570,8 +571,9 @@ final class ReferenceCollectingClassVisitor extends ClassVisitor {
|
|||
Type ownerType = Type.getType("L" + owner + ";");
|
||||
|
||||
// remember used context classes if this is an VirtualField.find() call
|
||||
if ("io.opentelemetry.instrumentation.api.util.VirtualField".equals(ownerType.getClassName())
|
||||
&& "find".equals(name)
|
||||
if (Objects.equals(
|
||||
ownerType.getClassName(), "io.opentelemetry.instrumentation.api.util.VirtualField")
|
||||
&& Objects.equals(name, "find")
|
||||
&& methodType.getDescriptor().equals(getVirtualFieldDescriptor)) {
|
||||
// in case of invalid scenario (not using .class ref directly) don't store anything and
|
||||
// clear the last LDC <class> stack
|
||||
|
|
|
@ -137,15 +137,15 @@ final class MuzzleCodeGenerator implements AsmVisitorWrapper {
|
|||
@Override
|
||||
public MethodVisitor visitMethod(
|
||||
int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||
if (MUZZLE_REFERENCES_METHOD_NAME.equals(name)) {
|
||||
if (name.equals(MUZZLE_REFERENCES_METHOD_NAME)) {
|
||||
generateReferencesMethod = false;
|
||||
logMethodAlreadyExistsMessage(MUZZLE_REFERENCES_METHOD_NAME);
|
||||
}
|
||||
if (MUZZLE_HELPER_CLASSES_METHOD_NAME.equals(name)) {
|
||||
if (name.equals(MUZZLE_HELPER_CLASSES_METHOD_NAME)) {
|
||||
generateHelperClassNamesMethod = false;
|
||||
logMethodAlreadyExistsMessage(MUZZLE_HELPER_CLASSES_METHOD_NAME);
|
||||
}
|
||||
if (MUZZLE_VIRTUAL_FIELDS_METHOD_NAME.equals(name)) {
|
||||
if (name.equals(MUZZLE_VIRTUAL_FIELDS_METHOD_NAME)) {
|
||||
generateVirtualFieldsMethod = false;
|
||||
logMethodAlreadyExistsMessage(MUZZLE_VIRTUAL_FIELDS_METHOD_NAME);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class MethodRef {
|
|||
}
|
||||
|
||||
public boolean isConstructor() {
|
||||
return "<init>".equals(name);
|
||||
return name.equals("<init>");
|
||||
}
|
||||
|
||||
MethodRef merge(MethodRef anotherMethod) {
|
||||
|
|
|
@ -7,6 +7,7 @@ package io.opentelemetry.smoketest;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import org.testcontainers.containers.output.OutputFrame;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public interface TestContainerManager {
|
|||
void stopTarget();
|
||||
|
||||
static boolean useWindowsContainers() {
|
||||
return !"1".equals(System.getenv("USE_LINUX_CONTAINERS"))
|
||||
return !Objects.equals(System.getenv("USE_LINUX_CONTAINERS"), "1")
|
||||
&& System.getProperty("os.name").toLowerCase().contains("windows");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -588,7 +589,7 @@ public abstract class AbstractHttpClientTest<REQUEST> {
|
|||
span.hasName("callback")
|
||||
.hasKind(SpanKind.INTERNAL)
|
||||
.hasParent(trace.getSpan(0)));
|
||||
boolean jdk8 = "1.8".equals(System.getProperty("java.specification.version"));
|
||||
boolean jdk8 = Objects.equals(System.getProperty("java.specification.version"), "1.8");
|
||||
if (jdk8) {
|
||||
// on some netty based http clients order of `CONNECT` and `callback` spans isn't
|
||||
// guaranteed when running on jdk8
|
||||
|
@ -967,7 +968,9 @@ public abstract class AbstractHttpClientTest<REQUEST> {
|
|||
assertThat(attrs)
|
||||
.containsEntry(
|
||||
SemanticAttributes.NET_SOCK_PEER_PORT,
|
||||
"https".equals(uri.getScheme()) ? server.httpsPort() : server.httpPort());
|
||||
Objects.equals(uri.getScheme(), "https")
|
||||
? server.httpsPort()
|
||||
: server.httpPort());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue