@@ -182,6 +182,49 @@ void testRecordActionableError_logsErrorInfo() {
182182 attributesMap .get (ObservabilityAttributes .ERROR_METADATA_ATTRIBUTE_PREFIX + "test_key" ));
183183 }
184184
185+ @ Test
186+ void testRecordActionableError_logsExceptionDetails () {
187+ ApiTracerContext context = ApiTracerContext .empty ();
188+ LoggingTracer tracer = new LoggingTracer (context );
189+
190+ Exception error = new RuntimeException ("test error message" );
191+ tracer .recordActionableError (error );
192+
193+ Map <String , ?> attributesMap = getAttributesMap ();
194+
195+ assertTrue (attributesMap != null && !attributesMap .isEmpty ());
196+ assertEquals (
197+ "java.lang.RuntimeException" ,
198+ attributesMap .get (ObservabilityAttributes .EXCEPTION_TYPE_ATTRIBUTE ));
199+ assertEquals ("test error message" , attributesMap .get ("exception.message" ));
200+ }
201+
202+ @ Test
203+ void testRecordActionableError_logsHttpStatus () {
204+ ApiTracerContext context =
205+ ApiTracerContext .empty ().toBuilder ().setTransport (ApiTracerContext .Transport .HTTP ).build ();
206+ LoggingTracer tracer = new LoggingTracer (context );
207+
208+ Exception error =
209+ ApiExceptionFactory .createException (
210+ "test error message" ,
211+ new RuntimeException ("cause" ),
212+ FakeStatusCode .of (StatusCode .Code .INVALID_ARGUMENT ),
213+ false );
214+
215+ tracer .recordActionableError (error );
216+
217+ Map <String , ?> attributesMap = getAttributesMap ();
218+
219+ assertTrue (attributesMap != null && !attributesMap .isEmpty ());
220+ assertEquals (
221+ "INVALID_ARGUMENT" ,
222+ attributesMap .get (ObservabilityAttributes .RPC_RESPONSE_STATUS_ATTRIBUTE ));
223+ assertEquals (
224+ 400L ,
225+ attributesMap .get (ObservabilityAttributes .HTTP_RESPONSE_STATUS_ATTRIBUTE ));
226+ }
227+
185228 private Map <String , ?> getAttributesMap () {
186229 if (!testLogger .getMDCMap ().isEmpty ()) {
187230 return testLogger .getMDCMap ();
0 commit comments