Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
cld
systems
DeathStarBench
Commits
323c43e0
Commit
323c43e0
authored
Oct 09, 2019
by
Vaastav Anand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic instrumentation for TextHandler
parent
740412ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
mediaMicroservices/src/TextService/TextHandler.h
mediaMicroservices/src/TextService/TextHandler.h
+20
-0
No files found.
mediaMicroservices/src/TextService/TextHandler.h
View file @
323c43e0
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment