<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def inject_trace_header(headers, entity):
 """ Extract trace id, entity id and sampling decision from the input entity and inject these information to headers. :param dict headers: http headers to inject :param Entity entity: trace entity that the trace header value generated from. """

    if not entity:
        return

    if hasattr(entity, 'type') and entity.type == 'subsegment':
        header = entity.parent_segment.get_origin_trace_header()
    else:
        header = entity.get_origin_trace_header()
    data = header.data if header else None

    to_insert = TraceHeader(
        root=entity.trace_id,
        parent=entity.id,
        sampled=entity.sampled,
        data=data,
    )

    value = to_insert.to_header_str()

    headers[http.XRAY_HEADER] = value