Skip to content

Commit 6d9bfa2

Browse files
refactor: consolidate error handling in image generation tracing
- Replace recordImageGenerationResponseError with shared recordResponseError function Signed-off-by: Hrushikesh Patil <[email protected]>
1 parent 8146a80 commit 6d9bfa2

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

internal/tracing/openinference/openai/image_generation.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (r *ImageGenerationRecorder) RecordResponse(span trace.Span, resp *openaisd
8080

8181
// RecordResponseOnError implements the same method as defined in tracing.ImageGenerationRecorder.
8282
func (r *ImageGenerationRecorder) RecordResponseOnError(span trace.Span, statusCode int, body []byte) {
83-
recordImageGenerationResponseError(span, statusCode, string(body))
83+
recordResponseError(span, statusCode, string(body))
8484
}
8585

8686
// buildImageGenerationRequestAttributes builds OpenInference attributes from the image generation request.
@@ -139,12 +139,3 @@ func buildImageGenerationResponseAttributes(resp *openaisdk.ImagesResponse, conf
139139

140140
return attrs
141141
}
142-
143-
// recordImageGenerationResponseError records error attributes to the span.
144-
func recordImageGenerationResponseError(span trace.Span, statusCode int, body string) {
145-
span.SetStatus(codes.Error, "")
146-
span.SetAttributes(
147-
attribute.Int("http.status_code", statusCode),
148-
attribute.String("gen_ai.error.message", body),
149-
)
150-
}

0 commit comments

Comments
 (0)