Commit 01ddee03 authored by Vaastav Anand's avatar Vaastav Anand

Add instrumentation for UniqueIdHandler

parent df65b049
......@@ -19,6 +19,8 @@
#include "../ThriftClient.h"
#include "../logger.h"
#include "../tracing.h"
#include <xtrace/xtrace.h>
#include <xtrace/baggage.h>
// Custom Epoch (January 1, 2018 Midnight GMT = 2018-01-01T00:00:00Z)
#define CUSTOM_EPOCH 1514764800000
......@@ -75,6 +77,15 @@ void UniqueIdHandler::UploadUniqueId(
int64_t req_id,
const std::map<std::string, std::string> & carrier) {
std::map<std::string, std::string>::const_iterator baggage_it = carrier.find("baggage");
if (baggage_it != carrier.end()) {
SET_CURRENT_BAGGAGE(Baggage::deserialize(baggage_it->second));
}
if (!XTrace::IsTracing()) {
XTrace::StartTrace("UniqueIdHandler");
}
XTRACE("UniqueIdHandler::UploadUniqueId", {{"RequestID", std::to_string(req_id)}});
// Initialize a span
TextMapReader reader(carrier);
std::map<std::string, std::string> writer_text_map;
......@@ -117,25 +128,31 @@ void UniqueIdHandler::UploadUniqueId(
int64_t review_id = stoul(review_id_str, nullptr, 16) & 0x7FFFFFFFFFFFFFFF;
LOG(debug) << "The review_id of the request "
<< req_id << " is " << review_id;
XTRACE("The review_id of the request " + std::to_string(req_id) + " is " + std::to_string(review_id));
auto compose_client_wrapper = _compose_client_pool->Pop();
if (!compose_client_wrapper) {
ServiceException se;
se.errorCode = ErrorCode::SE_THRIFT_CONN_ERROR;
se.message = "Failed to connected to compose-review-service";
XTRACE("Failed to connect to compose-review-service");
throw se;
}
auto compose_client = compose_client_wrapper->GetClient();
try {
writer_text_map["baggage"] = BRANCH_CURRENT_BAGGAGE().str();
compose_client->UploadUniqueId(req_id, review_id, writer_text_map);
} catch (...) {
_compose_client_pool->Push(compose_client_wrapper);
LOG(error) << "Failed to upload movie_id to compose-review-service";
XTRACE("Failed to upload movie_id to compose-review-service");
throw;
}
_compose_client_pool->Push(compose_client_wrapper);
span->Finish();
XTRACE("UniqueIdHandler::UploadUniqueId complete");
DELETE_CURRENT_BAGGAGE();
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment