### Question:
RecordEventsReadableSpan implements ReadWriteSpan { @Override public void recordException(Throwable exception) { recordException(exception, null); } private  RecordEventsReadableSpan(
      SpanContext context,
      String name,
      InstrumentationLibraryInfo instrumentationLibraryInfo,
      Kind kind,
      String parentSpanId,
      boolean hasRemoteParent,
      TraceConfig traceConfig,
      SpanProcessor spanProcessor,
      Clock clock,
      Resource resource,
      @Nullable AttributesMap attributes,
      List<SpanData.Link> links,
      int totalRecordedLinks,
      long startEpochNanos); @Override SpanData toSpanData(); @Override boolean hasEnded(); @Override SpanContext getSpanContext(); @Override String getName(); @Override InstrumentationLibraryInfo getInstrumentationLibraryInfo(); @Override long getLatencyNanos(); @Override void setAttribute(String key, String value); @Override void setAttribute(String key, long value); @Override void setAttribute(String key, double value); @Override void setAttribute(String key, boolean value); @Override void setAttribute(AttributeKey<T> key, T value); @Override void addEvent(String name); @Override void addEvent(String name, long timestamp); @Override void addEvent(String name, Attributes attributes); @Override void addEvent(String name, Attributes attributes, long timestamp); @Override void setStatus(StatusCanonicalCode canonicalCode); @Override void setStatus(StatusCanonicalCode canonicalCode, @Nullable String description); @Override void recordException(Throwable exception); @Override void recordException(Throwable exception, Attributes additionalAttributes); @Override void updateName(String name); @Override void end(); @Override void end(EndSpanOptions endOptions); @Override SpanContext getContext(); @Override boolean isRecording(); @Override String toString();  }### Answer:
@Test void recordException() { IllegalStateException exception = new IllegalStateException("there was an exception"); RecordEventsReadableSpan span = createTestRootSpan(); StringWriter writer = new StringWriter(); exception.printStackTrace(new PrintWriter(writer)); String stacktrace = writer.toString(); testClock.advanceNanos(1000); long timestamp = testClock.now(); span.recordException(exception); List<Event> events = span.toSpanData().getEvents(); assertThat(events).hasSize(1); Event event = events.get(0); assertThat(event.getName()).isEqualTo("exception"); assertThat(event.getEpochNanos()).isEqualTo(timestamp); assertThat(event.getAttributes()) .isEqualTo( Attributes.newBuilder() .setAttribute(SemanticAttributes.EXCEPTION_TYPE, "java.lang.IllegalStateException") .setAttribute(SemanticAttributes.EXCEPTION_MESSAGE, "there was an exception") .setAttribute(SemanticAttributes.EXCEPTION_STACKTRACE, stacktrace) .build()); }