Commit 323c43e0 authored by Vaastav Anand's avatar Vaastav Anand

Add basic instrumentation for TextHandler

parent 740412ac
......@@ -10,6 +10,8 @@
#include "../ThriftClient.h"
#include "../logger.h"
#include "../tracing.h"
#include <xtrace/xtrace.h>
#include <xtrace/baggage.h>
namespace media_service {
......@@ -34,6 +36,16 @@ void TextHandler::UploadText(
const std::string &text,
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("TextHandler");
}
XTRACE("TextHandler::UploadText", {{"RequestID", std::to_string(req_id)}});
// Initialize a span
TextMapReader reader(carrier);
std::map<std::string, std::string> writer_text_map;
......@@ -49,19 +61,27 @@ void TextHandler::UploadText(
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();
Baggage compose_client_baggage = BRANCH_CURRENT_BAGGAGE();
try {
writer_text_map["baggage"] = compose_client_baggage.str();
compose_client->UploadText(req_id, text, 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("TextHandler::UploadText complete");
DELETE_CURRENT_BAGGAGE();
}
} //namespace media_service
......
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