Skip to content

Commit e7923be

Browse files
committed
Fix suggestions
1 parent 3b1acdc commit e7923be

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1/AbstractObservationVectorStoreInterceptor.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,24 @@ public class AbstractObservationVectorStoreInterceptor implements InstanceMethod
4646
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
4747
MethodInterceptResult result) throws Throwable {
4848
SearchRequest request = (SearchRequest) allArguments[0];
49-
VectorStoreObservationContext context = createObservationContext(objInst, request);
50-
String dataSourceId = resolveDataSourceId(context, objInst);
49+
String dataSourceId = objInst.getClass().getSimpleName();
50+
51+
try {
52+
VectorStoreObservationContext context =
53+
createObservationContext(objInst, request);
54+
55+
String resolved =
56+
resolveDataSourceId(context, objInst);
57+
58+
if (StringUtils.hasText(resolved)) {
59+
dataSourceId = resolved;
60+
}
61+
} catch (Throwable ignored) {
62+
63+
}
5164

5265
AbstractSpan span = ContextManager.createExitSpan(Constants.RETRIEVAL + "/" + dataSourceId, dataSourceId);
66+
5367
SpanLayer.asGenAI(span);
5468
span.setComponent(ComponentsDefine.SPRING_AI);
5569
Tags.GEN_AI_OPERATION_NAME.set(span, Constants.RETRIEVAL);

apm-sniffer/apm-sdk-plugin/spring-plugins/spring-ai-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/ai/v1/common/ErrorTypeResolver.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import javax.net.ssl.SSLHandshakeException;
2626
import java.net.SocketTimeoutException;
27-
import java.net.UnknownHostException;
2827
import java.security.cert.CertPathValidatorException;
2928
import java.security.cert.CertificateException;
3029
import java.util.concurrent.TimeoutException;
@@ -47,13 +46,10 @@ private static String resolve(Throwable throwable) {
4746
if (matches(throwable, ErrorTypeResolver::isTimeout)) {
4847
return TIMEOUT;
4948
}
50-
if (matches(throwable, UnknownHostException.class::isInstance)) {
51-
return UnknownHostException.class.getName();
52-
}
5349
if (matches(throwable, ErrorTypeResolver::isCertificateInvalid)) {
5450
return SERVER_CERTIFICATE_INVALID;
5551
}
56-
return OTHER;
52+
return throwable.getClass().getName();
5753
}
5854

5955
private static boolean isTimeout(Throwable throwable) {

0 commit comments

Comments
 (0)