-
Notifications
You must be signed in to change notification settings - Fork 5.5k
tracing: Support OpenTracing API #2017
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
Changes from 8 commits
773211e
e57a0fd
4af99ef
93ab508
ad4062a
739cd54
6270b3f
4e03f60
ab3db85
cee939f
c775ded
f1db61f
94750bd
1e255d4
725d002
961e195
ecf6df1
0803ff2
5d62c51
3ff6aaf
cc6a7e2
739bf4a
cf7896b
ce00ac6
861e87c
562746e
a9411ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,6 +238,7 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []): | |
| _com_github_fmtlib_fmt() | ||
| _com_github_gabime_spdlog() | ||
| _com_github_gcovr_gcovr() | ||
| _com_github_opentracing_opentracing_cpp() | ||
| _com_github_lightstep_lightstep_tracer_cpp() | ||
| _com_github_nodejs_http_parser() | ||
| _com_github_tencent_rapidjson() | ||
|
|
@@ -312,23 +313,36 @@ def _com_github_gcovr_gcovr(): | |
| actual = "@com_github_gcovr_gcovr//:gcovr", | ||
| ) | ||
|
|
||
| def _com_github_opentracing_opentracing_cpp(): | ||
| location = REPOSITORY_LOCATIONS[ | ||
|
Contributor
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. Please use _repository_impl("io_opentracing_cpp")
native.bind(
name = "opentracing",
actual = "@io_opentracing_cpp//:opentracing",
)You'll want to adjust the
Contributor
Author
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. Changed to use _repository_impl and matched names to keys in REPOSITORY_LOCATIONS. |
||
| "com_github_opentracing_opentracing_cpp"] | ||
| native.git_repository( | ||
| name = "io_opentracing_cpp", | ||
| remote = location["remote"], | ||
| commit = location["commit"], | ||
| ) | ||
| native.bind( | ||
| name = "opentracing", | ||
| actual = "@io_opentracing_cpp//:opentracing", | ||
| ) | ||
|
|
||
| def _com_github_lightstep_lightstep_tracer_cpp(): | ||
| location = REPOSITORY_LOCATIONS[ | ||
| "com_github_lightstep_lightstep_tracer_cpp"] | ||
| genrule_repository( | ||
| name = "com_github_lightstep_lightstep_tracer_cpp", | ||
| urls = location["urls"], | ||
| sha256 = location["sha256"], | ||
| strip_prefix = location["strip_prefix"], | ||
| patches = [ | ||
| "@envoy//bazel/external:lightstep-missing-header.patch", | ||
| ], | ||
| genrule_cmd_file = "@envoy//bazel/external:lightstep.genrule_cmd", | ||
| build_file = "@envoy//bazel/external:lightstep.BUILD", | ||
| native.git_repository( | ||
|
Contributor
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. Same here. |
||
| name = "com_lightstep_tracer_cpp", | ||
| remote = location["remote"], | ||
| commit = location["commit"], | ||
| ) | ||
| native.new_git_repository( | ||
| name = "lightstep_vendored_googleapis", | ||
| remote = location["googleapis"]["remote"], | ||
| commit = location["googleapis"]["commit"], | ||
| build_file = "@com_lightstep_tracer_cpp//:lightstep-tracer-common/third_party/googleapis/BUILD", | ||
| ) | ||
| native.bind( | ||
| name = "lightstep", | ||
| actual = "@com_github_lightstep_lightstep_tracer_cpp//:lightstep", | ||
| actual = "@com_lightstep_tracer_cpp//:lightstep_tracer", | ||
| ) | ||
|
|
||
| def _com_github_tencent_rapidjson(): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,10 +25,17 @@ REPOSITORY_LOCATIONS = dict( | |
| commit = "c0d77201039c7b119b18bc7fb991564c602dd75d", | ||
| remote = "https://github.com/gcovr/gcovr", | ||
| ), | ||
| com_github_opentracing_opentracing_cpp = dict( | ||
| commit = "713c15d40ae63185d2bec99bf3b03823967d7108", | ||
| remote = "https://github.com/opentracing/opentracing-cpp", | ||
| ), | ||
| com_github_lightstep_lightstep_tracer_cpp = dict( | ||
| sha256 = "f7477e67eca65f904c0b90a6bfec46d58cccfc998a8e75bc3259b6e93157ff84", | ||
| strip_prefix = "lightstep-tracer-cpp-0.36", | ||
| urls = ["https://github.com/lightstep/lightstep-tracer-cpp/releases/download/v0_36/lightstep-tracer-cpp-0.36.tar.gz"], | ||
| commit = "c9d9215b5c3652c7eb5640903697d9a683e1df76", | ||
| remote = "https://github.com/lightstep/lightstep-tracer-cpp", | ||
| googleapis = dict( | ||
|
Contributor
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. It's pretty confusing to have this extra level of nesting. How about giving googleapis its own location?
Contributor
Author
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. Separated out. Is it ok to build target in the same function as lightstep?
Contributor
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. I think so. The functions only exist for human readability, and it makes sense to have all the lightstep stuff in one place. |
||
| commit = "d6f78d948c53f3b400bb46996eb3084359914f9b", | ||
| remote = "https://github.com/google/googleapis", | ||
| ), | ||
| ), | ||
| com_github_nodejs_http_parser = dict( | ||
| commit = "feae95a3a69f111bc1897b9048d9acbc290992f9", # v2.7.1 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -355,7 +355,7 @@ class HeaderMap { | |
| /** | ||
| * Get a header by key. | ||
| * @param key supplies the header key. | ||
| * @return the header entry if it exsits otherwise nullptr. | ||
| * @return the header entry if it exists otherwise nullptr. | ||
| */ | ||
| virtual const HeaderEntry* get(const LowerCaseString& key) const PURE; | ||
|
|
||
|
|
@@ -384,6 +384,18 @@ class HeaderMap { | |
| */ | ||
| virtual void iterateReverse(ConstIterateCb cb, void* context) const PURE; | ||
|
|
||
| enum class Lookup { Found, NotFound, NotSupported }; | ||
|
|
||
| /** | ||
| * Lookup one of the O(1) headers by key. | ||
|
Member
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. It would be clearer to refer to these as something like "predefined inline header (see ALL_INLINE_HEADERS below)". Using the complexity alone elides the semantic info here.
Contributor
Author
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. Changed naming. |
||
| * @param key supplies the header key. | ||
| * @param entry is set to the header entry if it exists and if key is one of the O(1) headers; | ||
| * otherwise, nullptr. | ||
| * @return Lookup::Found if lookup was successful, Lookup::NotFound if the header entry doesn't | ||
| * exist, or Lookup::NotSupported if key is not one of the O(1) headers. | ||
| */ | ||
| virtual Lookup lookup(const LowerCaseString& key, const HeaderEntry** entry) const PURE; | ||
|
|
||
| /** | ||
| * Remove all instances of a header by key. | ||
| * @param key supplies the header key to remove. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -399,6 +399,23 @@ void HeaderMapImpl::iterateReverse(ConstIterateCb cb, void* context) const { | |
| } | ||
| } | ||
|
|
||
| HeaderMap::Lookup HeaderMapImpl::lookup(const LowerCaseString& key, | ||
| const HeaderEntry** entry) const { | ||
| StaticLookupEntry::EntryCb cb = ConstSingleton<StaticLookupTable>::get().find(key.get().c_str()); | ||
|
Member
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. Could we potentially have a findConst() or something which returns a ConstEntryCb so that we don't need the const_cast below?
Contributor
Author
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. Via a macro, each of the O(1) headers adds a lambda funtion that takes IMO const_cast is the better option.
Member
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. I could go either way. I think it's slightly cleaner to have the init code add a const callback and then have a fineConst(), but I'm ok with this. I would just add a comment on the tradeoff.
Contributor
Author
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. Added comment for const_cast.
Member
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: For the next person that comes along and asks "why const_cast" can you add a brief additional comment on the tradeoffs between this and ^.
Contributor
Author
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. Added explanation for choosing const_cast. |
||
| if (cb) { | ||
| StaticLookupResponse ref_lookup_response = cb(const_cast<HeaderMapImpl&>(*this)); | ||
| *entry = *ref_lookup_response.entry_; | ||
| if (*entry) { | ||
| return Lookup::Found; | ||
| } else { | ||
| return Lookup::NotFound; | ||
| } | ||
| } else { | ||
| *entry = nullptr; | ||
| return Lookup::NotSupported; | ||
| } | ||
| } | ||
|
|
||
| void HeaderMapImpl::remove(const LowerCaseString& key) { | ||
| StaticLookupEntry::EntryCb cb = ConstSingleton<StaticLookupTable>::get().find(key.get().c_str()); | ||
| if (cb) { | ||
|
|
||
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.
This target is used to pre-build the dependencies when generating the Docker image. We still want to pre-build Lightstep and all its deps since they're pretty big.
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.
Fixed.