Skip to content

Commit cbd0649

Browse files
committed
Check empty
1 parent cf7b818 commit cbd0649

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/genai/GenAiAttributesExtractor.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ public void onEnd(
9999
REQUEST request,
100100
@Nullable RESPONSE response,
101101
@Nullable Throwable error) {
102-
internalSet(
103-
attributes,
104-
GEN_AI_RESPONSE_FINISH_REASONS,
105-
getter.getResponseFinishReasons(request, response));
102+
List<String> finishReaspons = getter.getResponseFinishReasons(request, response);
103+
if (finishReaspons != null && !finishReaspons.isEmpty()) {
104+
attributes.put(GEN_AI_RESPONSE_FINISH_REASONS, finishReaspons);
105+
}
106106
internalSet(attributes, GEN_AI_RESPONSE_ID, getter.getResponseId(request, response));
107107
internalSet(attributes, GEN_AI_RESPONSE_MODEL, getter.getResponseModel(request, response));
108108
internalSet(

0 commit comments

Comments
 (0)