use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.
the class OrderlyTraceContextInterceptor method doBefore.
@Override
public void doBefore(Advice advice) throws Throwable {
try {
MessageQueue messageQueue = getMessageQueue(advice.getTarget());
String consumeGroup = getConsumeGroup(advice.getTarget());
ConsumeMessageContext consumeMessageContext = new ConsumeMessageContext();
consumeMessageContext.setConsumerGroup(consumeGroup);
consumeMessageContext.setMq(messageQueue);
consumeMessageContext.setSuccess(false);
OrderlyTraceContexts.set(consumeMessageContext);
} catch (PradarException e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (PressureMeasureError e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (Throwable e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(e);
}
}
}
use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.
the class OrderlyTraceAfterInterceptor method doAfter.
@Override
public void doAfter(Advice advice) throws Throwable {
try {
ConsumeOrderlyStatus status = (ConsumeOrderlyStatus) advice.getParameterArray()[1];
ConsumeMessageContext consumeMessageContext = OrderlyTraceContexts.get();
if (consumeMessageContext == null || consumeMessageContext.getMsgList() == null) {
return;
}
consumeMessageContext.setSuccess(ConsumeOrderlyStatus.SUCCESS == status || ConsumeOrderlyStatus.COMMIT == status);
consumeMessageContext.setStatus(status.name());
hook.consumeMessageAfter(consumeMessageContext);
} catch (PradarException e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (PressureMeasureError e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (Throwable e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(e);
}
} finally {
OrderlyTraceContexts.remove();
}
}
use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.
the class ConcurrentlyTraceInterceptor method doAfter.
@Override
public void doAfter(Advice advice) throws Throwable {
try {
ConsumeMessageContext consumeMessageContext = contextThreadLocal.get();
if (consumeMessageContext == null) {
return;
}
consumeMessageContext.setSuccess(true);
consumeMessageContext.setStatus("CONSUME_SUCCESS");
hook.consumeMessageAfter(consumeMessageContext);
} catch (PradarException e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (PressureMeasureError e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (Throwable e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(e);
}
} finally {
contextThreadLocal.remove();
}
}
use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.
the class PulsarTraceProducerInterceptor method doBefore.
@Override
public void doBefore(Advice advice) {
Object[] args = advice.getParameterArray();
String methodName = advice.getBehaviorName();
Object target = advice.getTarget();
try {
if (!(target instanceof org.apache.pulsar.client.impl.ProducerImpl) && methodName.equals("sendAsync")) {
return;
}
ProducerImpl producer = (ProducerImpl) target;
if (args == null || args.length != 2) {
return;
}
Object messageObj = args[0];
MessageImpl<?> message = null;
if (messageObj instanceof MessageImpl) {
message = (MessageImpl<?>) messageObj;
}
if (messageObj instanceof TopicMessageImpl) {
TopicMessageImpl<?> topicMessage = (TopicMessageImpl<?>) messageObj;
message = (MessageImpl<?>) topicMessage.getMessage();
}
if (message == null) {
return;
}
MQTraceBean traceBean = new MQTraceBean();
traceBean.setTopic(Pradar.addClusterTestPrefix(producer.getTopic()));
traceBean.setKeys(message.getKey());
traceBean.setBodyLength(message.getData().length);
traceBean.setClusterTest(String.valueOf(Pradar.isClusterTest()));
ArrayList<MQTraceBean> traceBeans = new ArrayList<MQTraceBean>(1);
traceBeans.add(traceBean);
MQTraceContext mqTraceContext = new MQTraceContext();
mqTraceContext.setMqType(MQType.PULSAR);
mqTraceContext.setGroup(producer.getProducerName() + ":" + producer.getTopic());
mqTraceContext.setTraceBeans(traceBeans);
MQSendMessageTraceLog.sendMessageBefore(mqTraceContext);
PulsarApi.MessageMetadata.Builder builder = message.getMessageBuilder();
for (Map.Entry<String, String> entry : traceBean.getContext().entrySet()) {
builder.addProperties(org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).build());
}
threadLocal.set(mqTraceContext);
} catch (PradarException e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (PressureMeasureError e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw e;
}
} catch (Throwable e) {
LOGGER.error("", e);
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(e);
}
}
}
use of com.pamirs.pradar.exception.PradarException in project LinkAgent by shulieTech.
the class SpringConsumerMetaDataBuilder method tryBuild.
@Override
public ConsumerMetaData tryBuild(ConsumerDetail consumerDetail) {
Consumer consumer = consumerDetail.getConsumer();
String consumerTag = consumerDetail.getConsumerTag();
if (!consumer.getClass().getName().equals("org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$InternalConsumer")) {
return null;
}
try {
return highVersion(consumer, consumerTag);
} catch (Throwable e) {
logger.warn("[RabbitMQ] get ConsumerMetaData from spring rabbitmq fail, try lowVersion");
try {
return lowVersion(consumer, consumerTag);
} catch (Throwable ie) {
throw new PradarException("spring rabbitmq 版本不支持!", ie);
}
}
}
Aggregations