first commit
This commit is contained in:
102
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/ConsumeMessageContext.cpp
vendored
Normal file
102
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/ConsumeMessageContext.cpp
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ConsumeMessageContext.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "DefaultMQPushConsumerImpl.h"
|
||||
|
||||
namespace rocketmq {
|
||||
ConsumeMessageContext::ConsumeMessageContext() {
|
||||
m_defaultMQPushConsumer = NULL;
|
||||
// m_traceContext = NULL;
|
||||
}
|
||||
ConsumeMessageContext::~ConsumeMessageContext() {
|
||||
m_traceContext.reset();
|
||||
}
|
||||
std::string ConsumeMessageContext::getConsumerGroup() {
|
||||
return m_consumerGroup;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setConsumerGroup(const std::string& mConsumerGroup) {
|
||||
m_consumerGroup = mConsumerGroup;
|
||||
}
|
||||
|
||||
bool ConsumeMessageContext::getSuccess() {
|
||||
return m_success;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setSuccess(bool mSuccess) {
|
||||
m_success = mSuccess;
|
||||
}
|
||||
|
||||
std::vector<MQMessageExt> ConsumeMessageContext::getMsgList() {
|
||||
return m_msgList;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setMsgList(std::vector<MQMessageExt> mMsgList) {
|
||||
m_msgList = mMsgList;
|
||||
}
|
||||
|
||||
std::string ConsumeMessageContext::getStatus() {
|
||||
return m_status;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setStatus(const std::string& mStatus) {
|
||||
m_status = mStatus;
|
||||
}
|
||||
|
||||
int ConsumeMessageContext::getMsgIndex() {
|
||||
return m_msgIndex;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setMsgIndex(int mMsgIndex) {
|
||||
m_msgIndex = mMsgIndex;
|
||||
}
|
||||
|
||||
MQMessageQueue ConsumeMessageContext::getMessageQueue() {
|
||||
return m_messageQueue;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setMessageQueue(const MQMessageQueue& mMessageQueue) {
|
||||
m_messageQueue = mMessageQueue;
|
||||
}
|
||||
|
||||
DefaultMQPushConsumerImpl* ConsumeMessageContext::getDefaultMQPushConsumer() {
|
||||
return m_defaultMQPushConsumer;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setDefaultMQPushConsumer(DefaultMQPushConsumerImpl* mDefaultMqPushConsumer) {
|
||||
m_defaultMQPushConsumer = mDefaultMqPushConsumer;
|
||||
}
|
||||
|
||||
std::shared_ptr<TraceContext> ConsumeMessageContext::getTraceContext() {
|
||||
return m_traceContext;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setTraceContext(TraceContext* mTraceContext) {
|
||||
m_traceContext.reset(mTraceContext);
|
||||
}
|
||||
|
||||
std::string ConsumeMessageContext::getNameSpace() {
|
||||
return m_nameSpace;
|
||||
}
|
||||
|
||||
void ConsumeMessageContext::setNameSpace(const std::string& mNameSpace) {
|
||||
m_nameSpace = mNameSpace;
|
||||
}
|
||||
} // namespace rocketmq
|
||||
86
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/ConsumeMessageContext.h
vendored
Normal file
86
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/ConsumeMessageContext.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __ROCKETMQ_CONSUME_MESSAGE_CONTEXT_H__
|
||||
#define __ROCKETMQ_CONSUME_MESSAGE_CONTEXT_H__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "MQMessageExt.h"
|
||||
#include "MQMessageQueue.h"
|
||||
#include "TraceBean.h"
|
||||
#include "TraceContant.h"
|
||||
#include "TraceContext.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class DefaultMQPushConsumerImpl;
|
||||
class ConsumeMessageContext {
|
||||
public:
|
||||
ConsumeMessageContext();
|
||||
|
||||
virtual ~ConsumeMessageContext();
|
||||
|
||||
std::string getConsumerGroup();
|
||||
|
||||
void setConsumerGroup(const std::string& mConsumerGroup);
|
||||
|
||||
bool getSuccess();
|
||||
|
||||
void setSuccess(bool mSuccess);
|
||||
|
||||
std::vector<MQMessageExt> getMsgList();
|
||||
|
||||
void setMsgList(std::vector<MQMessageExt> mMsgList);
|
||||
|
||||
std::string getStatus();
|
||||
|
||||
void setStatus(const std::string& mStatus);
|
||||
|
||||
int getMsgIndex();
|
||||
|
||||
void setMsgIndex(int mMsgIndex);
|
||||
|
||||
MQMessageQueue getMessageQueue();
|
||||
|
||||
void setMessageQueue(const MQMessageQueue& mMessageQueue);
|
||||
|
||||
DefaultMQPushConsumerImpl* getDefaultMQPushConsumer();
|
||||
|
||||
void setDefaultMQPushConsumer(DefaultMQPushConsumerImpl* mDefaultMqPushConsumer);
|
||||
|
||||
std::shared_ptr<TraceContext> getTraceContext();
|
||||
|
||||
void setTraceContext(TraceContext* mTraceContext);
|
||||
|
||||
std::string getNameSpace();
|
||||
|
||||
void setNameSpace(const std::string& mNameSpace);
|
||||
|
||||
private:
|
||||
std::string m_consumerGroup;
|
||||
bool m_success;
|
||||
std::vector<MQMessageExt> m_msgList;
|
||||
std::string m_status;
|
||||
int m_msgIndex;
|
||||
MQMessageQueue m_messageQueue;
|
||||
DefaultMQPushConsumerImpl* m_defaultMQPushConsumer;
|
||||
// TraceContext* m_traceContext;
|
||||
std::shared_ptr<TraceContext> m_traceContext;
|
||||
std::string m_nameSpace;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
31
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/ConsumeMessageHook.h
vendored
Normal file
31
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/ConsumeMessageHook.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __ROCKETMQ_COUNSUME_MESSAGE_RPC_HOOK_H__
|
||||
#define __ROCKETMQ_COUNSUME_MESSAGE_RPC_HOOK_H__
|
||||
|
||||
#include <string>
|
||||
#include "ConsumeMessageContext.h"
|
||||
namespace rocketmq {
|
||||
class ConsumeMessageHook {
|
||||
public:
|
||||
virtual ~ConsumeMessageHook() {}
|
||||
virtual std::string getHookName() = 0;
|
||||
virtual void executeHookBefore(ConsumeMessageContext* context) = 0;
|
||||
virtual void executeHookAfter(ConsumeMessageContext* context) = 0;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
115
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/SendMessageContext.cpp
vendored
Normal file
115
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/SendMessageContext.cpp
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "SendMessageContext.h"
|
||||
#include <string>
|
||||
|
||||
namespace rocketmq {
|
||||
SendMessageContext::SendMessageContext() {}
|
||||
|
||||
SendMessageContext::~SendMessageContext() {
|
||||
m_defaultMQProducer = NULL;
|
||||
}
|
||||
|
||||
std::string SendMessageContext::getProducerGroup() {
|
||||
return m_producerGroup;
|
||||
}
|
||||
|
||||
void SendMessageContext::setProducerGroup(const std::string& mProducerGroup) {
|
||||
m_producerGroup = mProducerGroup;
|
||||
}
|
||||
|
||||
MQMessage* SendMessageContext::getMessage() {
|
||||
return &m_message;
|
||||
}
|
||||
|
||||
void SendMessageContext::setMessage(const MQMessage& mMessage) {
|
||||
m_message = mMessage;
|
||||
}
|
||||
|
||||
TraceMessageType SendMessageContext::getMsgType() {
|
||||
return m_msgType;
|
||||
}
|
||||
|
||||
void SendMessageContext::setMsgType(TraceMessageType mMsgType) {
|
||||
m_msgType = mMsgType;
|
||||
}
|
||||
|
||||
MQMessageQueue* SendMessageContext::getMessageQueue() {
|
||||
return &m_messageQueue;
|
||||
}
|
||||
|
||||
void SendMessageContext::setMessageQueue(const MQMessageQueue& mMq) {
|
||||
m_messageQueue = mMq;
|
||||
}
|
||||
|
||||
std::string SendMessageContext::getBrokerAddr() {
|
||||
return m_brokerAddr;
|
||||
}
|
||||
|
||||
void SendMessageContext::setBrokerAddr(const std::string& mBrokerAddr) {
|
||||
m_brokerAddr = mBrokerAddr;
|
||||
}
|
||||
|
||||
std::string SendMessageContext::getBornHost() {
|
||||
return m_bornHost;
|
||||
}
|
||||
|
||||
void SendMessageContext::setBornHost(const std::string& mBornHost) {
|
||||
m_bornHost = mBornHost;
|
||||
}
|
||||
|
||||
CommunicationMode SendMessageContext::getCommunicationMode() {
|
||||
return m_communicationMode;
|
||||
}
|
||||
|
||||
void SendMessageContext::setCommunicationMode(CommunicationMode mCommunicationMode) {
|
||||
m_communicationMode = mCommunicationMode;
|
||||
}
|
||||
|
||||
DefaultMQProducerImpl* SendMessageContext::getDefaultMqProducer() {
|
||||
return m_defaultMQProducer;
|
||||
}
|
||||
|
||||
void SendMessageContext::setDefaultMqProducer(DefaultMQProducerImpl* mDefaultMqProducer) {
|
||||
m_defaultMQProducer = mDefaultMqProducer;
|
||||
}
|
||||
|
||||
SendResult* SendMessageContext::getSendResult() {
|
||||
return &m_sendResult;
|
||||
}
|
||||
|
||||
void SendMessageContext::setSendResult(const SendResult& mSendResult) {
|
||||
m_sendResult = mSendResult;
|
||||
}
|
||||
|
||||
TraceContext* SendMessageContext::getTraceContext() {
|
||||
return m_traceContext;
|
||||
}
|
||||
|
||||
void SendMessageContext::setTraceContext(TraceContext* mTraceContext) {
|
||||
m_traceContext = mTraceContext;
|
||||
}
|
||||
|
||||
std::string SendMessageContext::getNameSpace() {
|
||||
return m_nameSpace;
|
||||
}
|
||||
|
||||
void SendMessageContext::setNameSpace(const std::string& mNameSpace) {
|
||||
m_nameSpace = mNameSpace;
|
||||
}
|
||||
} // namespace rocketmq
|
||||
96
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/SendMessageContext.h
vendored
Normal file
96
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/SendMessageContext.h
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __ROCKETMQ_SEND_MESSAGE_CONTEXT_H__
|
||||
#define __ROCKETMQ_SEND_MESSAGE_CONTEXT_H__
|
||||
|
||||
#include <string>
|
||||
#include "CommunicationMode.h"
|
||||
#include "MQMessage.h"
|
||||
#include "MQMessageQueue.h"
|
||||
#include "SendResult.h"
|
||||
#include "TraceBean.h"
|
||||
#include "TraceContant.h"
|
||||
#include "TraceContext.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class DefaultMQProducerImpl;
|
||||
class SendMessageContext {
|
||||
public:
|
||||
SendMessageContext();
|
||||
|
||||
virtual ~SendMessageContext();
|
||||
|
||||
std::string getProducerGroup();
|
||||
|
||||
void setProducerGroup(const std::string& mProducerGroup);
|
||||
|
||||
MQMessage* getMessage();
|
||||
|
||||
void setMessage(const MQMessage& mMessage);
|
||||
|
||||
TraceMessageType getMsgType();
|
||||
|
||||
void setMsgType(TraceMessageType mMsgType);
|
||||
|
||||
MQMessageQueue* getMessageQueue();
|
||||
|
||||
void setMessageQueue(const MQMessageQueue& mMq);
|
||||
|
||||
std::string getBrokerAddr();
|
||||
|
||||
void setBrokerAddr(const std::string& mBrokerAddr);
|
||||
|
||||
std::string getBornHost();
|
||||
|
||||
void setBornHost(const std::string& mBornHost);
|
||||
|
||||
CommunicationMode getCommunicationMode();
|
||||
|
||||
void setCommunicationMode(CommunicationMode mCommunicationMode);
|
||||
|
||||
DefaultMQProducerImpl* getDefaultMqProducer();
|
||||
|
||||
void setDefaultMqProducer(DefaultMQProducerImpl* mDefaultMqProducer);
|
||||
|
||||
SendResult* getSendResult();
|
||||
|
||||
void setSendResult(const SendResult& mSendResult);
|
||||
|
||||
TraceContext* getTraceContext();
|
||||
|
||||
void setTraceContext(TraceContext* mTraceContext);
|
||||
|
||||
std::string getNameSpace();
|
||||
|
||||
void setNameSpace(const std::string& mNameSpace);
|
||||
|
||||
private:
|
||||
std::string m_producerGroup;
|
||||
MQMessage m_message;
|
||||
TraceMessageType m_msgType;
|
||||
MQMessageQueue m_messageQueue;
|
||||
std::string m_brokerAddr;
|
||||
std::string m_bornHost;
|
||||
CommunicationMode m_communicationMode;
|
||||
DefaultMQProducerImpl* m_defaultMQProducer;
|
||||
SendResult m_sendResult;
|
||||
TraceContext* m_traceContext;
|
||||
std::string m_nameSpace;
|
||||
};
|
||||
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
31
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/SendMessageHook.h
vendored
Normal file
31
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/SendMessageHook.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __ROCKETMQ_SEND_MESSAGE_RPC_HOOK_H__
|
||||
#define __ROCKETMQ_SEND_MESSAGE_RPC_HOOK_H__
|
||||
|
||||
#include <string>
|
||||
#include "SendMessageContext.h"
|
||||
namespace rocketmq {
|
||||
class SendMessageHook {
|
||||
public:
|
||||
virtual ~SendMessageHook() {}
|
||||
virtual std::string getHookName() = 0;
|
||||
virtual void executeHookBefore(SendMessageContext* context) = 0;
|
||||
virtual void executeHookAfter(SendMessageContext* context) = 0;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
121
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceBean.cpp
vendored
Normal file
121
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceBean.cpp
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "TraceBean.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace rocketmq {
|
||||
TraceBean::TraceBean()
|
||||
: m_topic("null"),
|
||||
m_msgId("null"),
|
||||
m_offsetMsgId("null"),
|
||||
m_tags("null"),
|
||||
m_keys("null"),
|
||||
m_storeHost("null"),
|
||||
m_clientHost("null") {}
|
||||
|
||||
TraceBean::~TraceBean() {}
|
||||
|
||||
const std::string& TraceBean::getTopic() const {
|
||||
return m_topic;
|
||||
}
|
||||
|
||||
void TraceBean::setTopic(const std::string& topic) {
|
||||
m_topic = topic;
|
||||
}
|
||||
|
||||
const std::string& TraceBean::getMsgId() const {
|
||||
return m_msgId;
|
||||
}
|
||||
|
||||
void TraceBean::setMsgId(const std::string& msgId) {
|
||||
m_msgId = msgId;
|
||||
}
|
||||
|
||||
const std::string& TraceBean::getOffsetMsgId() const {
|
||||
return m_offsetMsgId;
|
||||
}
|
||||
|
||||
void TraceBean::setOffsetMsgId(const std::string& offsetMsgId) {
|
||||
m_offsetMsgId = offsetMsgId;
|
||||
}
|
||||
|
||||
const std::string& TraceBean::getTags() const {
|
||||
return m_tags;
|
||||
}
|
||||
|
||||
void TraceBean::setTags(const std::string& tags) {
|
||||
m_tags = tags;
|
||||
}
|
||||
|
||||
const std::string& TraceBean::getKeys() const {
|
||||
return m_keys;
|
||||
}
|
||||
|
||||
void TraceBean::setKeys(const std::string& keys) {
|
||||
m_keys = keys;
|
||||
}
|
||||
|
||||
const std::string& TraceBean::getStoreHost() const {
|
||||
return m_storeHost;
|
||||
}
|
||||
|
||||
void TraceBean::setStoreHost(const std::string& storeHost) {
|
||||
m_storeHost = storeHost;
|
||||
}
|
||||
|
||||
const std::string& TraceBean::getClientHost() const {
|
||||
return m_clientHost;
|
||||
}
|
||||
|
||||
void TraceBean::setClientHost(const std::string& clientHost) {
|
||||
m_clientHost = clientHost;
|
||||
}
|
||||
|
||||
TraceMessageType TraceBean::getMsgType() const {
|
||||
return m_msgType;
|
||||
}
|
||||
|
||||
void TraceBean::setMsgType(TraceMessageType msgType) {
|
||||
m_msgType = msgType;
|
||||
}
|
||||
|
||||
long long int TraceBean::getStoreTime() const {
|
||||
return m_storeTime;
|
||||
}
|
||||
|
||||
void TraceBean::setStoreTime(long long int storeTime) {
|
||||
m_storeTime = storeTime;
|
||||
}
|
||||
|
||||
int TraceBean::getRetryTimes() const {
|
||||
return m_retryTimes;
|
||||
}
|
||||
|
||||
void TraceBean::setRetryTimes(int retryTimes) {
|
||||
m_retryTimes = retryTimes;
|
||||
}
|
||||
|
||||
int TraceBean::getBodyLength() const {
|
||||
return m_bodyLength;
|
||||
}
|
||||
|
||||
void TraceBean::setBodyLength(int bodyLength) {
|
||||
m_bodyLength = bodyLength;
|
||||
}
|
||||
} // namespace rocketmq
|
||||
89
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceBean.h
vendored
Normal file
89
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceBean.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ROCKETMQ_TRACE_BEAN_H__
|
||||
#define __ROCKETMQ_TRACE_BEAN_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "TraceContant.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class TraceBean {
|
||||
public:
|
||||
TraceBean();
|
||||
virtual ~TraceBean();
|
||||
|
||||
const std::string& getTopic() const;
|
||||
|
||||
void setTopic(const std::string& topic);
|
||||
|
||||
const std::string& getMsgId() const;
|
||||
|
||||
void setMsgId(const std::string& msgId);
|
||||
|
||||
const std::string& getOffsetMsgId() const;
|
||||
|
||||
void setOffsetMsgId(const std::string& offsetMsgId);
|
||||
|
||||
const std::string& getTags() const;
|
||||
|
||||
void setTags(const std::string& tags);
|
||||
|
||||
const std::string& getKeys() const;
|
||||
|
||||
void setKeys(const std::string& keys);
|
||||
|
||||
const std::string& getStoreHost() const;
|
||||
|
||||
void setStoreHost(const std::string& storeHost);
|
||||
|
||||
const std::string& getClientHost() const;
|
||||
|
||||
void setClientHost(const std::string& clientHost);
|
||||
|
||||
TraceMessageType getMsgType() const;
|
||||
|
||||
void setMsgType(TraceMessageType msgType);
|
||||
|
||||
long long int getStoreTime() const;
|
||||
|
||||
void setStoreTime(long long int storeTime);
|
||||
|
||||
int getRetryTimes() const;
|
||||
|
||||
void setRetryTimes(int retryTimes);
|
||||
|
||||
int getBodyLength() const;
|
||||
|
||||
void setBodyLength(int bodyLength);
|
||||
|
||||
private:
|
||||
std::string m_topic;
|
||||
std::string m_msgId;
|
||||
std::string m_offsetMsgId;
|
||||
std::string m_tags;
|
||||
std::string m_keys;
|
||||
std::string m_storeHost;
|
||||
std::string m_clientHost;
|
||||
TraceMessageType m_msgType;
|
||||
long long m_storeTime;
|
||||
int m_retryTimes;
|
||||
int m_bodyLength;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
30
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContant.cpp
vendored
Normal file
30
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContant.cpp
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "TraceContant.h"
|
||||
#include <string>
|
||||
|
||||
namespace rocketmq {
|
||||
std::string TraceContant::GROUP_NAME = "_INNER_TRACE_PRODUCER";
|
||||
std::string TraceContant::TRACE_TOPIC = "rmq_sys_TRACE_DATA_";
|
||||
std::string TraceContant::DEFAULT_REDION = "DEFAULT_REGION";
|
||||
char TraceContant::CONTENT_SPLITOR = 1;
|
||||
char TraceContant::FIELD_SPLITOR = 2;
|
||||
std::string TraceContant::TRACE_TYPE_PUB = "Pub";
|
||||
std::string TraceContant::TRACE_TYPE_BEFORE = "SubBefore";
|
||||
std::string TraceContant::TRACE_TYPE_AFTER = "SubAfter";
|
||||
} // namespace rocketmq
|
||||
47
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContant.h
vendored
Normal file
47
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContant.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ROCKETMQ_TRACE_CONTANT_H_
|
||||
#define __ROCKETMQ_TRACE_CONTANT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace rocketmq {
|
||||
class TraceContant {
|
||||
public:
|
||||
static std::string GROUP_NAME;
|
||||
static std::string TRACE_TOPIC;
|
||||
static std::string DEFAULT_REDION;
|
||||
static char CONTENT_SPLITOR;
|
||||
static char FIELD_SPLITOR;
|
||||
static std::string TRACE_TYPE_PUB;
|
||||
static std::string TRACE_TYPE_BEFORE;
|
||||
static std::string TRACE_TYPE_AFTER;
|
||||
};
|
||||
enum TraceMessageType {
|
||||
TRACE_NORMAL_MSG = 0,
|
||||
TRACE_TRANS_HALF_MSG,
|
||||
TRACE_TRANS_COMMIT_MSG,
|
||||
TRACE_DELAY_MSG,
|
||||
};
|
||||
enum TraceType {
|
||||
Pub, // for send message
|
||||
SubBefore, // for consume message before
|
||||
SubAfter, // for consum message after
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif //
|
||||
113
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContext.cpp
vendored
Normal file
113
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContext.cpp
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "TraceContext.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "StringIdMaker.h"
|
||||
#include "UtilAll.h"
|
||||
|
||||
namespace rocketmq {
|
||||
TraceContext::TraceContext() : m_timeStamp(UtilAll::currentTimeMillis()) {
|
||||
m_requestId = StringIdMaker::getInstance().createUniqID();
|
||||
}
|
||||
|
||||
TraceContext::TraceContext(const std::string& mGroupName) : m_groupName(mGroupName) {}
|
||||
|
||||
TraceContext::~TraceContext() {}
|
||||
|
||||
TraceMessageType TraceContext::getMsgType() const {
|
||||
return m_msgType;
|
||||
}
|
||||
|
||||
void TraceContext::setMsgType(TraceMessageType msgType) {
|
||||
m_msgType = msgType;
|
||||
}
|
||||
|
||||
TraceType TraceContext::getTraceType() const {
|
||||
return m_traceType;
|
||||
}
|
||||
|
||||
void TraceContext::setTraceType(TraceType traceType) {
|
||||
m_traceType = traceType;
|
||||
}
|
||||
|
||||
long long int TraceContext::getTimeStamp() const {
|
||||
return m_timeStamp;
|
||||
}
|
||||
|
||||
void TraceContext::setTimeStamp(long long int timeStamp) {
|
||||
m_timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
const string& TraceContext::getRegionId() const {
|
||||
return m_regionId;
|
||||
}
|
||||
|
||||
void TraceContext::setRegionId(const string& regionId) {
|
||||
m_regionId = regionId;
|
||||
}
|
||||
|
||||
const string& TraceContext::getGroupName() const {
|
||||
return m_groupName;
|
||||
}
|
||||
|
||||
void TraceContext::setGroupName(const string& groupName) {
|
||||
m_groupName = groupName;
|
||||
}
|
||||
|
||||
int TraceContext::getCostTime() const {
|
||||
return m_costTime;
|
||||
}
|
||||
|
||||
void TraceContext::setCostTime(int costTime) {
|
||||
m_costTime = costTime;
|
||||
}
|
||||
|
||||
bool TraceContext::getStatus() const {
|
||||
return m_status;
|
||||
}
|
||||
|
||||
void TraceContext::setStatus(bool isSuccess) {
|
||||
m_status = isSuccess;
|
||||
}
|
||||
|
||||
const string& TraceContext::getRequestId() const {
|
||||
return m_requestId;
|
||||
}
|
||||
|
||||
void TraceContext::setRequestId(const string& requestId) {
|
||||
m_requestId = requestId;
|
||||
}
|
||||
|
||||
int TraceContext::getTraceBeanIndex() const {
|
||||
return m_traceBeanIndex;
|
||||
}
|
||||
|
||||
void TraceContext::setTraceBeanIndex(int traceBeanIndex) {
|
||||
m_traceBeanIndex = traceBeanIndex;
|
||||
}
|
||||
|
||||
const vector<TraceBean>& TraceContext::getTraceBeans() const {
|
||||
return m_traceBeans;
|
||||
}
|
||||
|
||||
void TraceContext::setTraceBean(const TraceBean& traceBean) {
|
||||
m_traceBeans.push_back(traceBean);
|
||||
}
|
||||
} // namespace rocketmq
|
||||
88
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContext.h
vendored
Normal file
88
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceContext.h
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ROCKETMQ_TRACE_CONTEXT_H__
|
||||
#define __ROCKETMQ_TRACE_CONTEXT_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "TraceBean.h"
|
||||
#include "TraceContant.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class TraceContext {
|
||||
public:
|
||||
TraceContext();
|
||||
|
||||
TraceContext(const std::string& mGroupName);
|
||||
|
||||
virtual ~TraceContext();
|
||||
|
||||
TraceMessageType getMsgType() const;
|
||||
|
||||
void setMsgType(TraceMessageType msgType);
|
||||
|
||||
TraceType getTraceType() const;
|
||||
|
||||
void setTraceType(TraceType traceType);
|
||||
|
||||
long long int getTimeStamp() const;
|
||||
|
||||
void setTimeStamp(long long int timeStamp);
|
||||
|
||||
const std::string& getRegionId() const;
|
||||
|
||||
void setRegionId(const std::string& regionId);
|
||||
|
||||
const std::string& getGroupName() const;
|
||||
|
||||
void setGroupName(const std::string& groupName);
|
||||
|
||||
int getCostTime() const;
|
||||
|
||||
void setCostTime(int costTime);
|
||||
|
||||
bool getStatus() const;
|
||||
|
||||
void setStatus(bool isSuccess);
|
||||
|
||||
const std::string& getRequestId() const;
|
||||
|
||||
void setRequestId(const std::string& requestId);
|
||||
|
||||
int getTraceBeanIndex() const;
|
||||
|
||||
void setTraceBeanIndex(int traceBeanIndex);
|
||||
|
||||
const std::vector<TraceBean>& getTraceBeans() const;
|
||||
|
||||
void setTraceBean(const TraceBean& traceBean);
|
||||
|
||||
private:
|
||||
TraceMessageType m_msgType;
|
||||
TraceType m_traceType;
|
||||
long long m_timeStamp;
|
||||
std::string m_regionId;
|
||||
std::string m_groupName;
|
||||
int m_costTime;
|
||||
bool m_status;
|
||||
std::string m_requestId;
|
||||
int m_traceBeanIndex;
|
||||
std::vector<TraceBean> m_traceBeans;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
38
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceTransferBean.cpp
vendored
Normal file
38
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceTransferBean.cpp
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "TraceTransferBean.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace rocketmq {
|
||||
std::string TraceTransferBean::getTransData() {
|
||||
return m_transData;
|
||||
}
|
||||
|
||||
void TraceTransferBean::setTransData(const std::string& transData) {
|
||||
m_transData = transData;
|
||||
}
|
||||
|
||||
std::vector<std::string> TraceTransferBean::getTransKey() {
|
||||
return m_transKey;
|
||||
}
|
||||
|
||||
void TraceTransferBean::setTransKey(const std::string& transkey) {
|
||||
m_transKey.push_back(transkey);
|
||||
}
|
||||
} // namespace rocketmq
|
||||
40
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceTransferBean.h
vendored
Normal file
40
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceTransferBean.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ROCKETMQ_TRACE_TRANSFER_BEAN_H__
|
||||
#define __ROCKETMQ_TRACE_TRANSFER_BEAN_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace rocketmq {
|
||||
class TraceTransferBean {
|
||||
public:
|
||||
std::string getTransData();
|
||||
|
||||
void setTransData(const std::string& transData);
|
||||
|
||||
std::vector<std::string> getTransKey();
|
||||
|
||||
void setTransKey(const std::string& transkey);
|
||||
|
||||
private:
|
||||
std::string m_transData;
|
||||
std::vector<std::string> m_transKey;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
124
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceUtil.cpp
vendored
Normal file
124
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceUtil.cpp
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "TraceUtil.h"
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "TraceContant.h"
|
||||
|
||||
namespace rocketmq {
|
||||
std::string TraceUtil::CovertTraceTypeToString(TraceType type) {
|
||||
switch (type) {
|
||||
case Pub:
|
||||
return TraceContant::TRACE_TYPE_PUB;
|
||||
case SubBefore:
|
||||
return TraceContant::TRACE_TYPE_BEFORE;
|
||||
case SubAfter:
|
||||
return TraceContant::TRACE_TYPE_AFTER;
|
||||
default:
|
||||
return TraceContant::TRACE_TYPE_PUB;
|
||||
}
|
||||
}
|
||||
|
||||
TraceTransferBean TraceUtil::CovertTraceContextToTransferBean(TraceContext* ctx) {
|
||||
std::ostringstream ss;
|
||||
std::vector<TraceBean> beans = ctx->getTraceBeans();
|
||||
switch (ctx->getTraceType()) {
|
||||
case Pub: {
|
||||
std::vector<TraceBean>::iterator it = beans.begin();
|
||||
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getTimeStamp() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getRegionId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getGroupName() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getTopic() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getMsgId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getTags() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getKeys() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getStoreHost() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getBodyLength() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getCostTime() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getMsgType() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getOffsetMsgId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << (ctx->getStatus() ? "true" : "false") << TraceContant::FIELD_SPLITOR;
|
||||
} break;
|
||||
|
||||
case SubBefore: {
|
||||
std::vector<TraceBean>::iterator it = beans.begin();
|
||||
for (; it != beans.end(); ++it) {
|
||||
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getTimeStamp() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getRegionId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getGroupName() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getRequestId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getMsgId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getRetryTimes() << TraceContant::CONTENT_SPLITOR;
|
||||
// this is a bug caused by broker.
|
||||
std::string defaultKey = "dKey";
|
||||
if (!it->getKeys().empty()) {
|
||||
defaultKey = it->getKeys();
|
||||
}
|
||||
ss << defaultKey << TraceContant::FIELD_SPLITOR;
|
||||
}
|
||||
} break;
|
||||
|
||||
case SubAfter: {
|
||||
std::vector<TraceBean>::iterator it = beans.begin();
|
||||
ss << TraceUtil::CovertTraceTypeToString(ctx->getTraceType()) << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getRequestId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << it->getMsgId() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << ctx->getCostTime() << TraceContant::CONTENT_SPLITOR;
|
||||
ss << (ctx->getStatus() ? "true" : "false") << TraceContant::CONTENT_SPLITOR;
|
||||
// this is a bug caused by broker.
|
||||
std::string defaultKey = "dKey";
|
||||
if (!it->getKeys().empty()) {
|
||||
defaultKey = it->getKeys();
|
||||
}
|
||||
ss << defaultKey << TraceContant::FIELD_SPLITOR;
|
||||
} break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TraceTransferBean transferBean;
|
||||
transferBean.setTransData(ss.str());
|
||||
|
||||
switch (ctx->getTraceType()) {
|
||||
case Pub:
|
||||
case SubAfter: {
|
||||
std::vector<TraceBean>::iterator it = beans.begin();
|
||||
transferBean.setTransKey(it->getMsgId());
|
||||
if (it->getKeys() != "") {
|
||||
transferBean.setTransKey(it->getKeys());
|
||||
}
|
||||
} break;
|
||||
case SubBefore: {
|
||||
std::vector<TraceBean>::iterator it = beans.begin();
|
||||
for (; it != beans.end(); ++it) {
|
||||
transferBean.setTransKey((*it).getMsgId());
|
||||
if ((*it).getKeys() != "") {
|
||||
transferBean.setTransKey((*it).getKeys());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return transferBean;
|
||||
}
|
||||
} // namespace rocketmq
|
||||
33
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceUtil.h
vendored
Normal file
33
source/third_party/rocketmq-client-cpp-2.2.0-source-release/src/trace/TraceUtil.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ROCKETMQ_TRACE_UTIL_H_
|
||||
#define __ROCKETMQ_TRACE_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
#include "TraceContant.h"
|
||||
#include "TraceContext.h"
|
||||
#include "TraceTransferBean.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class TraceUtil {
|
||||
public:
|
||||
static std::string CovertTraceTypeToString(TraceType type);
|
||||
static TraceTransferBean CovertTraceContextToTransferBean(TraceContext* ctx);
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif //
|
||||
Reference in New Issue
Block a user