Skip to content

Commit

Permalink
Remove usages of sdk internal StringUtils class (#11547)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Jun 11, 2024
1 parent b47aca9 commit 5801ca7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package io.opentelemetry.javaagent.instrumentation.influxdb.v2_4;

import io.opentelemetry.api.internal.StringUtils;
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter;
import javax.annotation.Nullable;

Expand All @@ -22,12 +21,11 @@ public String getStatement(InfluxDbRequest request) {
public String getOperation(InfluxDbRequest request) {
if (request.getSqlStatementInfo() != null) {
String operation = request.getSqlStatementInfo().getOperation();
return StringUtils.isNullOrEmpty(operation) ? request.getSql() : operation;
return operation == null ? request.getSql() : operation;
}
return null;
}

@Nullable
@Override
public String getSystem(InfluxDbRequest request) {
return "influxdb";
Expand All @@ -43,7 +41,7 @@ public String getUser(InfluxDbRequest request) {
@Override
public String getName(InfluxDbRequest request) {
String dbName = request.getDbName();
return StringUtils.isNullOrEmpty(dbName) ? null : dbName;
return "".equals(dbName) ? null : dbName;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.internal.StringUtils;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan;
Expand Down Expand Up @@ -86,7 +85,7 @@ public static String extractServerRoute(ServerWebExchange exchange) {
*/
private static String convergeRouteId(Route route) {
String routeId = route.getId();
if (StringUtils.isNullOrEmpty(routeId)) {
if (routeId == null || routeId.isEmpty()) {
return null;
}
if (UUID_REGEX.matcher(routeId).matches()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.internal.StringUtils;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
Expand All @@ -21,6 +20,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.util.StringUtils;

public abstract class AbstractRouteMappingTest {
@TestConfiguration
Expand Down Expand Up @@ -49,7 +49,7 @@ void beforeEach() {
protected List<AttributeAssertion> buildAttributeAssertions(
String routeId, String uri, int order, int filterSize) {
List<AttributeAssertion> assertions = new ArrayList<>();
if (!StringUtils.isNullOrEmpty(routeId)) {
if (!StringUtils.isEmpty(routeId)) {
assertions.add(equalTo(AttributeKey.stringKey("spring-cloud-gateway.route.id"), routeId));
}
assertions.add(equalTo(AttributeKey.stringKey("spring-cloud-gateway.route.uri"), uri));
Expand Down

0 comments on commit 5801ca7

Please sign in to comment.