diff --git a/lib/integrations/llm_base_service.rb b/lib/integrations/llm_base_service.rb index e8811121f..ca9459fc8 100644 --- a/lib/integrations/llm_base_service.rb +++ b/lib/integrations/llm_base_service.rb @@ -164,6 +164,6 @@ class Integrations::LlmBaseService end def build_error_response_from_exception(error, messages) - { error: error.message, error_code: 500, request_messages: messages } + { error: error.message, request_messages: messages } end end diff --git a/lib/integrations/llm_instrumentation_helpers.rb b/lib/integrations/llm_instrumentation_helpers.rb index 1fc73f3f0..c03e3e9c7 100644 --- a/lib/integrations/llm_instrumentation_helpers.rb +++ b/lib/integrations/llm_instrumentation_helpers.rb @@ -32,10 +32,8 @@ module Integrations::LlmInstrumentationHelpers error = result[:error] || result['error'] return if error.blank? - error_code = result[:error_code] || result['error_code'] span.set_attribute(ATTR_GEN_AI_RESPONSE_ERROR, error.to_json) - span.set_attribute(ATTR_GEN_AI_RESPONSE_ERROR_CODE, error_code) if error_code - span.status = OpenTelemetry::Trace::Status.error("API Error: #{error_code}") + span.status = OpenTelemetry::Trace::Status.error(error.to_s.truncate(1000)) end def set_metadata_attributes(span, params) diff --git a/spec/lib/integrations/llm_instrumentation_spec.rb b/spec/lib/integrations/llm_instrumentation_spec.rb index f567a91b7..97a45a414 100644 --- a/spec/lib/integrations/llm_instrumentation_spec.rb +++ b/spec/lib/integrations/llm_instrumentation_spec.rb @@ -200,17 +200,15 @@ RSpec.describe Integrations::LlmInstrumentation do result = instance.instrument_llm_call(params) do { - error: { message: 'API rate limit exceeded' }, - error_code: 'rate_limit_exceeded' + error: 'API rate limit exceeded' } end - expect(result[:error_code]).to eq('rate_limit_exceeded') + expect(result[:error]).to eq('API rate limit exceeded') expect(mock_span).to have_received(:set_attribute) - .with('gen_ai.response.error', '{"message":"API rate limit exceeded"}') - expect(mock_span).to have_received(:set_attribute).with('gen_ai.response.error_code', 'rate_limit_exceeded') + .with('gen_ai.response.error', '"API rate limit exceeded"') expect(mock_span).to have_received(:status=).with(mock_status) - expect(OpenTelemetry::Trace::Status).to have_received(:error).with('API Error: rate_limit_exceeded') + expect(OpenTelemetry::Trace::Status).to have_received(:error).with('API rate limit exceeded') end end