class PressureMarkTransformFilter extends Filter {

    @Override
    public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException {
        // consumer side, if in provider side,loadTest always false
        SofaTracerSpan currentSpan = SofaTraceContextHolder.getSofaTraceContext().getCurrentSpan();
        boolean loadTest = TracerUtils.isLoadTest(currentSpan);
        if (loadTest) {
            Map<String, String> metaHolder = MetadataHolder.getMetaHolder();
            metaHolder.put(HEAD_KEY_TRAFFIC_TYPE.name(), PRESSURE);
        }

        // provider side ,if in consumer side, metadata == null
        Metadata metadata = TracingContextKey.getKeyMetadata().get();
        if (metadata != null) {
            String s = metadata.get(HEAD_KEY_TRAFFIC_TYPE);
            if (PRESSURE.equals(s)) {
                currentSpan.getSofaTracerSpanContext().setBizBaggageItem(MARK, T);
            }
        }
        try {
            return invoker.invoke(request);
        } finally {
            MetadataHolder.clear();
        }
    }

}