Zipkin exporter #471
Conversation
Codecov Report
@@ Coverage Diff @@
## main #471 +/- ##
==========================================
+ Coverage 94.22% 94.34% +0.12%
==========================================
Files 187 189 +2
Lines 8882 8949 +67
==========================================
+ Hits 8369 8443 +74
+ Misses 513 506 -7
|
|
|
||
| const int kAttributeValueSize = 14; | ||
|
|
||
| void Recordable::SetIds(trace::TraceId trace_id, |
There was a problem hiding this comment.
Is this function reusable by other exporters, would they use the same field names? id , parentId, traceId - should this be moved into common utility function within the SDK?
@mishal23 - you need to borrow this same code for ETW exporter, to populate the actual IDs in your PR.
There was a problem hiding this comment.
@maxgolov - Not sure if we can move it to common. As different exporters expect these fields in different formats. E.g, Zipkin (json) as hex chars of 16/32 length, Jaeger (binary thrift) as uint64_t.
There was a problem hiding this comment.
The implementation of Recordable is exporter specific. As exporter could choose different underlying storage, agree that it is unnecessary to provide a common implementation.
Co-authored-by: Max Golovanov <max.golovanov+github@gmail.com>
| /** | ||
| * Create an ZipkinExporter using the given options. | ||
| */ | ||
| ZipkinExporter(const ZipkinExporterOptions &options); |
There was a problem hiding this comment.
Use explicit for all 1 arguments constructor. I think it is a bad practice to rely on converting constructors (https://en.cppreference.com/w/cpp/language/converting_constructor) in general unless explicitly wanted to have this behavior like std::string_view.
/cc @maxgolov @lalitb @g-easy @jsuereth I see that in other places you do not use explicit, what is the overall rule?
There was a problem hiding this comment.
Agree. Will fix it. We follow google c++ style guide:
(https://google.github.io/styleguide/cppguide.html#Implicit_Conversions):
Do not define implicit conversions. Use the explicit keyword for conversion operators and single-argument constructors.
Also, would be good to add cpplint CI check to catch these error.
There was a problem hiding this comment.
This is fixed for zipkin. Will have separate PR for adding explicit keyword at other places.
| find_package(CURL REQUIRED) | ||
| if(CURL_FOUND) | ||
| add_compile_definitions(WITH_CURL) | ||
| endif() |
There was a problem hiding this comment.
If this REQUIRED argument is given, we can remove the if condition, as configuration will abort anyway if CURL is not found.
There was a problem hiding this comment.
Thank you. Have removed the REQUIRED argument, as it should be possible to run zipkin with other http client libraries.
| /** | ||
| * The Zipkin exporter exports span data in JSON format as expected by Zipkin | ||
| */ | ||
| class ZipkinExporter final : public trace_sdk::SpanExporter, public http_client::EventHandler |
There was a problem hiding this comment.
Why do you derive from EventHandler here?
There was a problem hiding this comment.
Good catch. It is not needed, and so removed.
| { | ||
| return sdk::trace::ExportResult::kFailure; | ||
| } | ||
| auto session = http_session_manager_->CreateSession(url_parser_.host_, url_parser_.port_); |
There was a problem hiding this comment.
Why do we create a new session for each call to Export? I see sessions are stored in the session manager. When are those sessions cleaned up? Will this cause an implicit memory leak (all past sessions being kept in the session manager)?
There was a problem hiding this comment.
Session object is confusing, as there is no actual session created for HTTP ( being stateless). I have simplified the http client library as part of #448 , and using that here:
HttpClientSync httpClient;
auto result = httpClient.Post(url, data, headers); // GET request
if (result){
auto response = result.GetResponse();
} else {
std::cout << result.GetSessionState();
}
Thanks for the snippet @Muchene . though I am not able to reproduce the issue, the problem could be related to order of member initialization. For now, I have changed the order of member variable definition in ZipkinExporter to be in consistent with the order of their initialization in constructor initializers. Hopefully it helps. Do let me know once you try it again. |
|
@lalitb Will try and let you know. One more thing
|
@Muchene - Thanks for reporting the issue. Have chaged the annotations to array now as expected by Zipkin Server. Please let know if you still see any issues here. |
|
@open-telemetry/cpp-approvers - For this PR, all the comments have been resolved, and any incremental change can be applied later. It's planned to be merged today eod unless there are any concerns raised. |
| @@ -1,3 +1,17 @@ | |||
| # Copyright 2021, OpenTelemetry Authors | |||
There was a problem hiding this comment.
Somehow I haven't noticed this before...
Do we need to include the actual year, or we can do something simpler like https://github.com/open-telemetry/opentelemetry-dotnet/blob/381908c089aac4fa9a2056d6bbf465b9853b81b8/src/OpenTelemetry/AssemblyInfo.cs#L2?
There was a problem hiding this comment.
Not sure where I copied from. Have fixed it now. Thanks for the comment.
| attribute[key.data()].push_back(val); | ||
| } | ||
| } | ||
| else if (nostd::holds_alternative<nostd::span<const nostd::string_view>>(value)) |
There was a problem hiding this comment.
Just curious about the perf implication of these if-else checks, not sure if a small jump table would make it faster. Not a blocker for this PR though.
There was a problem hiding this comment.
Yes, we are doing these variant checks at multiple places, would be better to use dispatch table throughout. Will add a ticket for same.
|
|
||
| } // namespace zipkin | ||
| } // namespace exporter | ||
| OPENTELEMETRY_END_NAMESPACE No newline at end of file |
There was a problem hiding this comment.
nit: I noticed some files have missed the blank line before EOF.
There was a problem hiding this comment.
Good catch. Have added blank line at all missing places.
…_exporter.h Co-authored-by: Reiley Yang <reyang@microsoft.com>
…_exporter.h Co-authored-by: Reiley Yang <reyang@microsoft.com>
…and-patch-dependencies Update otel/opentelemetry-collector Docker tag to v0.133.0
Implementation of zipkin exporter based on mapping defined here:
https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk_exporters/zipkin.md
The code is ready for review while I am adding below changes in this PR:
A separate PR would be raised to add an example for how to run it against zipkin server ( under
examples/zipkin)The PR is dependent on merging of below two PRs and currently includes those changes also to enable it build successfully:
1 Sending sync request through http_client: #448
2. Http client factory: #445