-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lightstep gPRC generation for tracing #98
Changes from 19 commits
a7dcc0d
47669b9
4b57e24
6e28c33
e2b92ca
1319bf6
a90fcf1
b02fb42
786e16a
46444b6
a3fc5ea
f1a2bcc
95a5924
445c289
05e80a2
de1a15d
b6a88fe
a467a8f
57115eb
19ed4a0
640d49a
aa005c0
44a1fec
9320a07
d6f8353
6327e6f
91ef68b
371b06c
914c48b
a2b45d1
189e1d5
0c9d9be
912b6b8
f3a80f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ add_library( | |
grpc/common.cc | ||
grpc/http1_bridge_filter.cc | ||
grpc/rpc_channel_impl.cc | ||
grpc/utility.cc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think just add this code to common.cc, probably don't need a new source file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good, moving that to common. |
||
http/access_log/access_log_formatter.cc | ||
http/access_log/access_log_impl.cc | ||
http/async_client_impl.cc | ||
|
@@ -113,6 +114,7 @@ endif() | |
include_directories(${ENVOY_LIBEVENT_INCLUDE_DIR}) | ||
include_directories(${ENVOY_NGHTTP2_INCLUDE_DIR}) | ||
include_directories(SYSTEM ${ENVOY_OPENSSL_INCLUDE_DIR}) | ||
include_directories(SYSTEM ${ENVOY_LIGHTSTEP_TRACER_INCLUDE_DIR}) | ||
|
||
set_target_properties(envoy-common PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT | ||
"../precompiled/precompiled.h") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,4 +92,10 @@ class StringUtil { | |
*/ | ||
static bool startsWith(const std::string& source, const std::string& start, | ||
bool case_sensitive = true); | ||
|
||
/** | ||
* @return original @param input string if it's not empty or @param default_value otherwise. | ||
*/ | ||
static const std::string& valueOrDefault(const std::string& input, | ||
const std::string& default_value = "-"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: having a default param of "-" for a common utility function is a little strange, I would just have no default param. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "common.h" | ||
#include "utility.h" | ||
|
||
#include "common/http/headers.h" | ||
|
||
namespace Grpc { | ||
|
||
Buffer::InstancePtr Utility::serializeBody(const google::protobuf::Message& message) { | ||
// http://www.grpc.io/docs/guides/wire.html | ||
Buffer::InstancePtr body(new Buffer::OwnedImpl()); | ||
uint8_t compressed = 0; | ||
body->add(&compressed, sizeof(compressed)); | ||
uint32_t size = htonl(message.ByteSize()); | ||
body->add(&size, sizeof(size)); | ||
body->add(message.SerializeAsString()); | ||
|
||
return body; | ||
} | ||
|
||
Http::MessagePtr Utility::prepareHeaders(const std::string& upstream_cluster, | ||
const std::string& service_full_name, | ||
const std::string& method_name) { | ||
Http::MessagePtr message(new Http::RequestMessageImpl()); | ||
message->headers().addViaMoveValue(Http::Headers::get().Scheme, "http"); | ||
message->headers().addViaMoveValue(Http::Headers::get().Method, "POST"); | ||
message->headers().addViaMoveValue(Http::Headers::get().Path, | ||
fmt::format("/{}/{}", service_full_name, method_name)); | ||
message->headers().addViaCopy(Http::Headers::get().Host, upstream_cluster); | ||
message->headers().addViaCopy(Http::Headers::get().ContentType, Common::GRPC_CONTENT_TYPE); | ||
|
||
return message; | ||
} | ||
|
||
} // Grpc |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include "common/http/message_impl.h" | ||
|
||
#include "google/protobuf/message.h" | ||
|
||
namespace Grpc { | ||
|
||
class Utility { | ||
public: | ||
static Buffer::InstancePtr serializeBody(const google::protobuf::Message& message); | ||
static Http::MessagePtr prepareHeaders(const std::string& upstream_cluster, | ||
const std::string& service_full_name, | ||
const std::string& method_name); | ||
}; | ||
|
||
} // Grpc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed