/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <C> void inject(SpanContext spanContext, Format<C> format, C carrier) { if ((format == null) || (carrier == null)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Context can not be injected, both format and carrier must be provided."); } return; } if (spanContext instanceof SpanContextImpl) { Propagator<C> propagator = (Propagator<C>) propagators.get(format); if (null != propagator) { propagator.inject((SpanContextImpl) spanContext, carrier); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Context can not be injected, propagator does not exists for the format " + format.toString() + "."); } } } }
@Test public void happyPath() { tracer.registerPropagator(Format.Builtin.TEXT_MAP, propagator); tracer.inject(context, Format.Builtin.TEXT_MAP, carrier); verify(propagator).inject(context, carrier); verifyNoMoreInteractions(propagator); }