class TraceContext implements Recyclable {

    public static <S, D> void copyTraceContextTextHeaders(S source, TextHeaderGetter<S> headerGetter, D destination, TextHeaderSetter<D> headerSetter) {
        String w3cApmTraceParent = headerGetter.getFirstHeader(W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, source);
        if (w3cApmTraceParent != null) {
            headerSetter.setHeader(W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, w3cApmTraceParent, destination);
        }
        String elasticApmTraceParent = headerGetter.getFirstHeader(ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME, source);
        if (elasticApmTraceParent != null) {
            headerSetter.setHeader(ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME, elasticApmTraceParent, destination);
        }
        // copying only the first tracestate header
        String tracestate = headerGetter.getFirstHeader(TRACESTATE_HEADER_NAME, source);
        if (tracestate != null) {
            headerSetter.setHeader(TRACESTATE_HEADER_NAME, tracestate, destination);
        }
    }

    private  TraceContext(ElasticApmTracer tracer, Id id);

}