### Question:
ElasticApmTracer implements Tracer { @Override @Nullable public Transaction startRootTransaction(@Nullable ClassLoader initiatingClassLoader) { return startRootTransaction(sampler, -1, initiatingClassLoader); } ElasticApmTracer(ConfigurationRegistry configurationRegistry, Reporter reporter, ObjectPoolFactory poolFactory, ApmServerClient apmServerClient, MetaData metaData); @Override @Nullable Transaction startRootTransaction(@Nullable ClassLoader initiatingClassLoader); @Override @Nullable Transaction startRootTransaction(Sampler sampler, long epochMicros, @Nullable ClassLoader initiatingClassLoader); @Override @Nullable Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter<C> textHeadersGetter, @Nullable ClassLoader initiatingClassLoader); @Override @Nullable Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter<C> textHeadersGetter, Sampler sampler,
                                                 long epochMicros, @Nullable ClassLoader initiatingClassLoader); @Override @Nullable Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter<C> binaryHeadersGetter, @Nullable ClassLoader initiatingClassLoader); @Override @Nullable Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter<C> binaryHeadersGetter,
                                                 Sampler sampler, long epochMicros, @Nullable ClassLoader initiatingClassLoader); Transaction noopTransaction(); @Override @Nullable Transaction currentTransaction(); Span startSpan(TraceContext.ChildContextCreator<T> childContextCreator, T parentContext); Span startSpan(AbstractSpan<?> parent, long epochMicros); Span startSpan(TraceContext.ChildContextCreator<T> childContextCreator, T parentContext, long epochMicros); @Override void captureAndReportException(@Nullable Throwable e, ClassLoader initiatingClassLoader); @Override @Nullable String captureAndReportException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan<?> parent); @Override @Nullable ErrorCapture captureException(@Nullable Throwable e, @Nullable AbstractSpan<?> parent, @Nullable ClassLoader initiatingClassLoader); ConfigurationRegistry getConfigurationRegistry(); T getConfig(Class<T> configProvider); void endTransaction(Transaction transaction); void endSpan(Span span); void endError(ErrorCapture error); void recycle(Transaction transaction); void recycle(Span span); void recycle(ErrorCapture error); synchronized void stop(); Reporter getReporter(); Sampler getSampler(); ObjectPoolFactory getObjectPoolFactory(); @Override @Nullable AbstractSpan<?> getActive(); @Nullable @Override Span getActiveSpan(); @Nullable @Override Span getActiveExitSpan(); void registerSpanListener(ActivationListener activationListener); List<ActivationListener> getActivationListeners(); synchronized void start(boolean premain); synchronized void onStressDetected(); synchronized void onStressRelieved(); @Override boolean isRunning(); @Override TracerState getState(); @Nullable T getLifecycleListener(Class<T> listenerClass); void activate(AbstractSpan<?> span); void deactivate(AbstractSpan<?> span); MetricRegistry getMetricRegistry(); @Override void overrideServiceNameForClassLoader(@Nullable ClassLoader classLoader, @Nullable String serviceName); void resetServiceNameOverrides(); ApmServerClient getApmServerClient(); MetaData getMetaData(); ScheduledThreadPoolExecutor getSharedSingleThreadedPool();  }### Answer:
@Test void testCaptureExceptionAndGetErrorId() { Transaction transaction = tracerImpl.startRootTransaction(getClass().getClassLoader()); String errorId = transaction.captureExceptionAndGetErrorId(new Exception("test")); transaction.end(); assertThat(reporter.getErrors()).hasSize(1); assertThat(errorId).isNotNull(); ErrorCapture error = reporter.getFirstError(); assertThat(error.getTraceContext().getId().toString()).isEqualTo(errorId); }