def METHOD_NAME(self, span_context, format, carrier):
    if format in (Format.HTTP_HEADERS, Format.TEXT_MAP):
        if not isinstance(carrier, dict):
            raise InvalidCarrierException("carrier for {} format should be dict-like".format(format))
        val = span_context.trace_parent.to_ascii()
        carrier[constants.TRACEPARENT_HEADER_NAME] = val
        if self._agent.config.use_elastic_traceparent_header:
            carrier[constants.TRACEPARENT_LEGACY_HEADER_NAME] = val
        return
    raise UnsupportedFormatException