census-instrumentation / opencensus-cpp Goto Github PK
View Code? Open in Web Editor NEWA stats collection and distributed tracing framework
Home Page: https://opencensus.io/
License: Apache License 2.0
A stats collection and distributed tracing framework
Home Page: https://opencensus.io/
License: Apache License 2.0
We want to integrate support for exporting stats to Prometheus as well as Stackdriver. Prometheus uses a pull model--clients expose stats on an HTTP endpoint that the server scrapes--which will require an extension to the StatsExporter API. For exposing stats, I see two sensible options:
The second minimizes our dependencies, but duplicates formatting code from the existing client library and makes it difficult for applications using the Prometheus client directly to integrate the two--they would have to implement their own Exposer combining the two sources of metrics. I prefer the first--if we use the existing client library and make the PrometheusExporter a custom Collectable, users can use the default Exposer for out-of-the-box export (supporting combining Opencensus and native Prometheus metrics), while still having the option of writing their own handler (using the client's formatters) to avoid running the Prometheus client's default server.
I think it is better to use absl::Span for the AttributesRef definition because can be constructed from a initializer_list as well as from a vector or array.
This may be useful for cases where the attributes are determined at runtime.
I found BucketBoundaries when construction is through internal will make a copy, here to move construction will be better
BucketBoundaries(absl::Span<const double> lower_boundaries)
: lower_boundaries_(lower_boundaries.begin(), lower_boundaries.end()) {}
// The lower bound of each bucket, excluding the underflow bucket but
// including the overflow bucket.
std::vector<double> lower_boundaries_;
Call:
std::vector<double> boundaries(num_finite_buckets + 1);
for (int i = 0; i <= num_finite_buckets; ++i) {
..........
}
return BucketBoundaries(boundaries);
replace
BucketBoundaries(std::vector<double>&& lower_boundaries)
std::vector<double> boundaries(num_finite_buckets + 1);
for (int i = 0; i <= num_finite_buckets; ++i) {
..........
}
return BucketBoundaries(std::move(boundaries));
Because Context has a default move assignment operator but its data member Span explicitly deletes it.
Example build failure:
INFO: From Compiling external/io_opencensus_cpp/opencensus/stats/internal/recording.cc:
Step #4: In file included from external/io_opencensus_cpp/opencensus/stats/internal/recording.cc:21:
Step #4: In file included from external/io_opencensus_cpp/opencensus/tags/context_util.h:18:
Step #4: external/io_opencensus_cpp/opencensus/context/context.h:52:12: warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted]
Step #4: Context& operator=(Context&&) = default;
Step #4: ^
Step #4: external/io_opencensus_cpp/opencensus/context/context.h:76:27: note: move assignment operator of 'Context' is implicitly deleted because field 'span_' has a deleted move assignment operator
Step #4: opencensus::trace::Span span_;
Step #4: ^
Step #4: external/io_opencensus_cpp/opencensus/trace/span.h:121:9: note: 'operator=' has been explicitly marked deleted here
Step #4: Span& operator=(Span&&) = delete;
Step #4: ^
Step #4: 1 warning generated.
Currently the google/ directly copies all the protos from googleapis repo. We should not do that and probably build from head.
I am working on another iteration on the website that shows users each concept and usage in the various languages and so far for Spans I can't seem to find any reference of SpanKind in this project.
SpanKind is defined at https://github.com/census-instrumentation/opencensus-proto/blob/99162e4df59df7e6f54a8a33b80f0020627d8405/src/opencensus/proto/trace/v1/trace.proto#L88-L106
Thank you.
Abseil-cpp or other Google project has support on cmake (using add_subdirectory). Is there any plan for opencensus-cpp?
Ideally, the Register method for the StackdriverExporter would return a Status object. Looking at the code, this may not be trivial to implement since the registration is actually handled in a separate thread. Even so, it would still be useful to allow client code to block until registration is complete (either successful or unsuccessful) and take some action based on the result.
Similar to grpc-java and grpc
The documentation says "A sampling decision from a ParentSpan is ALWAYS inherited by all its regardless of the trace configuration. This ensures continuity of traces – for example, if a parent were sampled but one of its children were not, we’d then lose parts of the trace, and vice versa if the parent weren’t sampled yet one of its children were, we wouldn’t know where the span began" https://opencensus.io/tracing/sampling/
However, looking at the code, the sampler doesn't take into consideration of parent span context.
https://github.com/census-instrumentation/opencensus-cpp/blob/master/opencensus/trace/internal/sampler.cc#L57
So I don't think the rule is enforced.
Hello,
With Visual Studio 2017 (15.5.6) I noticed a failing test even in debug mode:
TEST(AttributeValueTest, StringValue) {
AttributeValue attr(absl::StrCat("hello", " ", "world"));
EXPECT_EQ(AttributeValue::Type::kString, attr.type());
EXPECT_EQ("hello world", attr.string_value());
}
The temporary AttributeValueRef
that was used to construct the AttributeValue
contained a string_view
which content pointer pointer into glibberish memory. When I changed the test to the following:
TEST(AttributeValueTest, StringValue) {
std::string value = absl::StrCat("hello", " ", "world");
AttributeValue attr(value);
EXPECT_EQ(AttributeValue::Type::kString, attr.type());
EXPECT_EQ("hello world", attr.string_value());
}
I noticed that before the string_view
was created a temporary std::string
got created, too. But instead of being kept alive until the AttributeValue
was constructed, it gets deleted right before entry of AttributeValueRef
ctor. Starting from that the string view points into free'd memory.
I thing the following AttributeValueRef code is to blame (or Visual Studio 2017)
template <typename T, typename std::enable_if<std::is_constructible<
absl::string_view, T>::value>::type* = nullptr>
AttributeValueRef(T string_value)
: string_value_(absl::string_view(string_value)), type_(Type::kString) {}
If I change the signature to AttributeValueRef(const T& string_value)
, the error is gone. I'm no C++ language lawyer but AFAIR temporaries are best passed as const&
.
See the their documentation here https://grpc.io/grpc/cpp/namespacegrpc.html
There is a race condition between checking stats in the main thread and recording them in the server thread, which is leading to Travis failures. (2% flaky on my workstation, possibly more in Travis.)
Followup for #200
This is a followup to #92 which added the Attribute.
Is this expected behavior?
Because it works for opencensus-node and opencensus-python.
I figured out this happens because grpc instrumentation always looks for span context and makes a invalid context when there is no such context found from header.
Add an example of propagating trace information over a gRPC call.
In opencensus/exporters/stats/stackdriver/stackdriver_exporter.h, we require the user to set a different opencensus_task
for every process exporting to Stackdriver. This should be an implementation detail that the library takes care of.
Hello there, I was just going over the examples here in order to instrument a C++ app and noticed that the examples have comments talking about
The website too seems to have discrepencies https://opencensus.io/cpp.html
Please update these or if possible post them as plain values.
Probably use appveyor for that.
Our build is presently cluttered with warnings that functions that return from a switch on an enum. Absl uses a return outside the enum to suppress these warnings; I think we should either follow suit (possibly with an assert(false)
) or add build options to silence the warning.
I find this issue while working on grpc/grpc#15853.
I register the measures following the recommendation like
::opencensus::stats::MeasureInt64 MeasureStartCount() {
static const ::opencensus::stats::MeasureInt64 start_count =
::opencensus::stats::MeasureInt64::Register(
kMeasureStartCount, kMeasureStartCount, kMeasureStartCount);
return start_count;
}
This works fine when I build with bazel build -c dbg //test/...
But if I build with -c opt
, the log shows that (1) I am attempting to register again, (2) and the data view may give me some wrong data (data fetched is 24 for a recording of value 1).
[ RUN ] ServerLoadReportingEnd2endTest.BasicReport
D0623 13:37:14.313988446 242908 ev_posix.cc:145] Using polling engine: epollex
D0623 13:37:14.314029956 242908 dns_resolver.cc:339] Using native dns resolver
D0623 13:37:14.316311692 242908 ev_posix.cc:145] Using polling engine: epollex
D0623 13:37:14.316343875 242908 dns_resolver.cc:339] Using native dns resolver
I0623 13:37:14.316864980 242908 server_builder.cc:273] Synchronous server. Num CQs: 1, Min pollers: 1, Max Pollers: 2, CQ timeout (msec): 10000
D0623 13:37:14.317355586 242950 load_reporter_async_service_impl.cc:78] [LRS 0x482e70] Starting a fetch-and-sample...
D0623 13:37:14.317411990 242950 load_reporter.cc:490] [LR 0x47fe40] Starts fetching Census view data and sampling LB feedback record.
D0623 13:37:14.317422571 242950 load_reporter.cc:190] [CVP 0x47ff80] Starts fetching Census view data.
D0623 13:37:14.317437870 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/start_count).
D0623 13:37:14.317450829 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/end_count).
D0623 13:37:14.317461294 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_sent).
D0623 13:37:14.317471768 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_received).
D0623 13:37:14.317481978 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/latency_ms).
D0623 13:37:14.317492947 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_count).
D0623 13:37:14.317503341 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_value).
D0623 13:37:14.317708765 242950 load_reporter_async_service_impl.cc:70] [LRS 0x482e70] Next fetch-and-sample scheduled.
D0623 13:37:14.317972062 242908 dns_resolver.cc:280] Start resolving.
I0623 13:37:14.319444295 242948 subchannel.cc:608] New connected subchannel at 0x7ffff0005840 for subchannel 0x7ffff0003e40
I0623 13:37:14.320059301 242908 server_load_reporting_end2end_test.cc:137] Initial request sent.
Attempt to register measure with already-registered name: name: "grpc.io/lb/start_count"; units: "grpc.io/lb/start_count"; description: "grpc.io/lb/start_count"; type: int64
I0623 13:37:15.318668918 242950 server_load_reporting_filter.cc:263] START RECORD 1
D0623 13:37:15.318829598 242950 load_reporter_async_service_impl.cc:78] [LRS 0x482e70] Starting a fetch-and-sample...
D0623 13:37:15.318846352 242950 load_reporter.cc:490] [LR 0x47fe40] Starts fetching Census view data and sampling LB feedback record.
D0623 13:37:15.318859150 242950 load_reporter.cc:190] [CVP 0x47ff80] Starts fetching Census view data.
D0623 13:37:15.318877675 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/start_count).
D0623 13:37:15.318889608 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/end_count).
D0623 13:37:15.318900901 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_sent).
D0623 13:37:15.318913587 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_received).
D0623 13:37:15.318924346 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/latency_ms).
D0623 13:37:15.318935930 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_count).
D0623 13:37:15.318949934 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_value).
D0623 13:37:15.319142178 242950 load_reporter_async_service_impl.cc:70] [LRS 0x482e70] Next fetch-and-sample scheduled.
I0623 13:37:15.319305055 242950 load_reporter_async_service_impl.cc:161] [LRS 0x482e70] Call request delivered (lb_id_: 00000000, handler: 0x7fffe8001960). Start reading the initial request...
I0623 13:37:15.319530627 242950 load_data_store.cc:256] [PerHostStore 0x7fffe8000e80] Re-assigned orphaned store (0x7fffe800b6b0) with original LB ID of <INVALID_LBID_238dsb234890rb> to new receiver 00000000
I0623 13:37:15.319561315 242950 load_reporter.cc:376] [LR 0x47fe40] Report stream created (host: localhost:12746, LB ID: 00000000, load key: LOAD_KEY).
I0623 13:37:15.319572060 242950 load_reporter_async_service_impl.cc:196] [LRS 0x482e70] Initial request received. Start load reporting (load balanced host: localhost:12746, interval: 5000 ms, lb_id_: 00000000, handler: 0x7fffe8001960)...
I0623 13:37:15.319682745 242950 load_reporter_async_service_impl.cc:281] [LRS 0x482e70] Sending load report (lb_id_: 00000000, handler: 0x7fffe8001960, loads count: 0)...
D0623 13:37:15.319710483 242950 load_reporter_async_service_impl.cc:247] [LRS 0x482e70] Next load report scheduled (lb_id_: 00000000, handler: 0x7fffe8001960).
I0623 13:37:15.319819823 242908 server_load_reporting_end2end_test.cc:141] Initial response received (lb_id: 00000000).
D0623 13:37:15.320015339 242908 dns_resolver.cc:280] Start resolving.
I0623 13:37:15.320557951 242950 server_load_reporting_filter.cc:263] START RECORD 1
Attempt to register measure with already-registered name: name: "grpc.io/lb/other_call_metric"; units: "grpc.io/lb/other_call_metric"; description: "grpc.io/lb/other_call_metric"; type: double
Attempt to register measure with already-registered name: name: "grpc.io/lb/end_count"; units: "grpc.io/lb/end_count"; description: "grpc.io/lb/end_count"; type: int64
Attempt to register measure with already-registered name: name: "grpc.io/lb/bytes_sent"; units: "grpc.io/lb/bytes_sent"; description: "grpc.io/lb/bytes_sent"; type: int64
Attempt to register measure with already-registered name: name: "grpc.io/lb/bytes_received"; units: "grpc.io/lb/bytes_received"; description: "grpc.io/lb/bytes_received"; type: int64
Attempt to register measure with already-registered name: name: "grpc.io/lb/latency_ms"; units: "grpc.io/lb/latency_ms"; description: "grpc.io/lb/latency_ms"; type: int64
D0623 13:37:16.320333762 242950 load_reporter_async_service_impl.cc:78] [LRS 0x482e70] Starting a fetch-and-sample...
D0623 13:37:16.320367867 242950 load_reporter.cc:490] [LR 0x47fe40] Starts fetching Census view data and sampling LB feedback record.
D0623 13:37:16.320377374 242950 load_reporter.cc:190] [CVP 0x47ff80] Starts fetching Census view data.
D0623 13:37:16.320395659 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/start_count).
D0623 13:37:16.320403838 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/end_count).
D0623 13:37:16.320414540 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_sent).
D0623 13:37:16.320425090 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_received).
D0623 13:37:16.320434589 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/latency_ms).
D0623 13:37:16.320447617 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_count).
D0623 13:37:16.320457110 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_value).
D0623 13:37:16.320647817 242950 load_reporter_async_service_impl.cc:70] [LRS 0x482e70] Next fetch-and-sample scheduled.
D0623 13:37:17.321343602 242950 load_reporter_async_service_impl.cc:78] [LRS 0x482e70] Starting a fetch-and-sample...
D0623 13:37:17.321377090 242950 load_reporter.cc:490] [LR 0x47fe40] Starts fetching Census view data and sampling LB feedback record.
D0623 13:37:17.321387571 242950 load_reporter.cc:190] [CVP 0x47ff80] Starts fetching Census view data.
D0623 13:37:17.321406578 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/start_count).
D0623 13:37:17.321420644 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/end_count).
D0623 13:37:17.321436103 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_sent).
D0623 13:37:17.321460326 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_received).
D0623 13:37:17.321474007 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/latency_ms).
D0623 13:37:17.321487261 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_count).
D0623 13:37:17.321501110 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_value).
D0623 13:37:17.321731319 242950 load_reporter_async_service_impl.cc:70] [LRS 0x482e70] Next fetch-and-sample scheduled.
D0623 13:37:18.322311673 242950 load_reporter_async_service_impl.cc:78] [LRS 0x482e70] Starting a fetch-and-sample...
D0623 13:37:18.322347372 242950 load_reporter.cc:490] [LR 0x47fe40] Starts fetching Census view data and sampling LB feedback record.
D0623 13:37:18.322360432 242950 load_reporter.cc:190] [CVP 0x47ff80] Starts fetching Census view data.
D0623 13:37:18.322386536 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/start_count).
D0623 13:37:18.322398547 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/end_count).
D0623 13:37:18.322409583 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_sent).
D0623 13:37:18.322420434 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_received).
D0623 13:37:18.322431306 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/latency_ms).
D0623 13:37:18.322442936 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_count).
D0623 13:37:18.322454099 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_value).
I0623 13:37:18.322466875 242950 load_reporter.cc:396] START_COUNT GOT 1
D0623 13:37:18.322608830 242950 load_data_store.cc:146] [PerBalancerStore 0x7fffe800b6b0] Load data merged (Key: [lb_id_=<INVALID_LBID_238dsb234890rb>, lb_tag_=, user_id_=, client_ip_hex_=00000000000000000000000000000001], Value: [start_count_=1, ok_count_=0, error_count_=0, bytes_sent_=0, bytes_recv_=0, latency_ms_=0]).
I0623 13:37:18.322626284 242950 load_reporter.cc:396] START_COUNT GOT 24
D0623 13:37:18.322645735 242950 load_data_store.cc:146] [PerBalancerStore 0x7fffe8001760] Load data merged (Key: [lb_id_=00000000, lb_tag_=LB_TAG, user_id_=, client_ip_hex_=00000000000000000000000000000001], Value: [start_count_=24, ok_count_=0, error_count_=0, bytes_sent_=0, bytes_recv_=0, latency_ms_=0]).
D0623 13:37:18.322805456 242950 load_reporter_async_service_impl.cc:70] [LRS 0x482e70] Next fetch-and-sample scheduled.
D0623 13:37:19.323293284 242950 load_reporter_async_service_impl.cc:78] [LRS 0x482e70] Starting a fetch-and-sample...
D0623 13:37:19.323324559 242950 load_reporter.cc:490] [LR 0x47fe40] Starts fetching Census view data and sampling LB feedback record.
D0623 13:37:19.323335550 242950 load_reporter.cc:190] [CVP 0x47ff80] Starts fetching Census view data.
D0623 13:37:19.323355241 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/start_count).
D0623 13:37:19.323365399 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/end_count).
D0623 13:37:19.323375394 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_sent).
D0623 13:37:19.323385084 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/bytes_received).
D0623 13:37:19.323394732 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/latency_ms).
D0623 13:37:19.323404314 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_count).
D0623 13:37:19.323414000 242950 load_reporter.cc:197] [CVP 0x47ff80] Fetched view data (view: grpc.io/lb_view/other_call_metric_value).
D0623 13:37:19.323586229 242950 load_reporter_async_service_impl.cc:70] [LRS 0x482e70] Next fetch-and-sample scheduled.
I0623 13:37:20.320542192 242950 load_reporter_async_service_impl.cc:281] [LRS 0x482e70] Sending load report (lb_id_: 00000000, handler: 0x7fffe8001960, loads count: 4)...
D0623 13:37:20.320607894 242950 load_reporter_async_service_impl.cc:247] [LRS 0x482e70] Next load report scheduled (lb_id_: 00000000, handler: 0x7fffe8001960).
test/cpp/end2end/server_load_reporting_end2end_test.cc:146: Failure
Expected: response.load().size()
Which is: 4
To be equal to: 3
I0623 13:37:20.321082956 242950 load_reporter_async_service_impl.cc:291] [LRS 0x482e70] Shutting down the handler (lb_id_: 00000000, handler: 0x7fffe8001960, reason: OnReadDone).
D0623 13:37:20.321106585 242950 load_data_store.cc:166] [PerBalancerStore 0x7fffe8001760] Suspended.
D0623 13:37:20.321116969 242950 load_data_store.cc:166] [PerBalancerStore 0x7fffe800b6b0] Suspended.
I0623 13:37:20.321128956 242950 load_reporter.cc:385] [LR 0x47fe40] Report stream closed (host: localhost:12746, LB ID: 00000000).
I0623 13:37:20.321171552 242950 load_reporter_async_service_impl.cc:334] [LRS 0x482e70] Load reporting call is notified done (handler: 0x7fffe8001960, is_cancelled: 1).
I0623 13:37:20.321293431 242950 load_reporter_async_service_impl.cc:291] [LRS 0x482e70] Shutting down the handler (lb_id_: , handler: 0x7fffe800bcc0, reason: OnRequestDelivered).
I0623 13:37:20.321577390 242950 load_reporter_async_service_impl.cc:75] [LRS 0x482e70] Fetch-and-sample is stopped.
[ FAILED ] ServerLoadReportingEnd2endTest.BasicReport (6008 ms)
When I tried to debug this issue with logging each access to the measures, this issue disappears... 😞
Any idea or suggestion? Thanks!
Jaeger is a good opentracing impl, have plan to support jaeger exporter?
I wanna construct a span tree in client side, first of all, I use StartSpan("name") to create a root span, and then I pass it to another function, then it can be used to create a child span as StartSpan("name", &root_span), but I don't wanna change the signature of my functions, so I need to store Span in another structure, but in its implementation, Span can't be copyed or moved. Then I think I can store SpanContext in the structure and using it to construct a new Span, but in local I can only use StartSpan which don't accept SpanContext as parameter, I'm so confused how to use opencensus effectively to achieve all these goals. Another problem is that when I pass the local Span's context to server side, then I use StartSpanWithRemoteParent to construct a new Span, but then I need to pass it to other server side functions to create more spans, now I should use StartSpanWithRemoteParent again, or I should use StartSpan, that would cause the same problem above. Hopefully, I have made it clear for you guys to understand what the problem is. Anyone knows the solution to solve these problems, thank you all.
The specs are defined here. We need to:
Similar to the Java version, it'd be quite useful for the stackdriver exporter in cpp to implement the metric name prefix as well.
i have such a scene to trace: process_a send data to process_b, I need to track the entire process of sending data until it is accepted by process_b. the two process communicate with share memory.
now create root_span at process_a and sent the Spancontext to process_b, and create child_span with root_span's SpanContext .but this still can't track the process of delivery. i want to end the root_span in process_b, but how to do this?
Anyone knows the solution to solve this problems, thank you!!
Currently, opencensus-cpp uses multiple upstream libraries, including abseil, gmock, gtest, prometheus-cpp. However, when we pulled in these dependent libraries, we pulled off from master
. As a user of opencensus-cpp, if I want to build opencensus-cpp library from scratch, I may get different result from time to time.
Therefore, I suggest locking down the version for both bazel and CMake for each opencensus-cpp release.
for bazel, an example is the Bazel's absl dependent:
from
urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"],
to
urls = ["https://github.com/abseil/abseil-cpp/archive/20180600.zip"],
for Cmake's absl dependent, from
GIT_TAG "master"
to
GIT_TAG "20180600"
I'm getting this error when OpenCensus tries to export a LastValue metric:
CreateTimeSeries request failed: INVALID_ARGUMENT: Field timeSeries[0].points[0].interval.start had an invalid value of "2019-03-31T19:17:03.270968-07:00": The start time must be equal to the end time (2019-03-31T19:17:08.271862-07:00) for the gauge metric 'custom.googleapis.com/opencensus/REDACTED'.
No idea what is happening--these should be (and up til yesterday were) filtered by the "| grep -v :_" filter, and running the commands in the .travis script still works locally for me.
Firstly, thank you for the great work on OpenCensus-CPP!
I kindly would like to ask if perhaps someone could run and publish some benchmarks on the wiki. I ask because I have been talking to companies and almost all their tech and developers would like to know what the overhead is when traced vs untraced. I believe the wiki would be a great place to publish such values and those could be updated by anyone, without having to make a pull request or distract the folks watching and maintaining this repo.
Now if use opencensus::RegisterGrpcPlugin()
, the filter is affected for every channel.
Does is support for register grpc filter for which channel i want to use?
Followup on #200: add check under !NDEBUG to WithContext to make sure it's allocated and deallocated in the same thread.
Is there any plan for building opencensus-cpp by using make/cmake, the build tool bazel is strange to me, I've spent a lot of time to figure out how to build it correctly...But it seems still confusing...Any chance that I can use the familiar work flow to just make and build it into a library...Thanks...
Experimental CMake support was added in PR #238 to address issue #86. This issue is to track followup work from the PR:
Is there a recommended way to terminate short lived programs? I am thinking of examples, tests, or batch processes that may have completed their work but want to give OpenCensus time to complete its work before shutting down.
Context is an object that holds information (such as Span and TagMap) specific to an operation (such as an RPC) and propagates it implicitly to child operations, function calls, etc.
Work that needs to be done:
Record()
that uses the current TagMap. #225The current MSVC version specified is 19, but I don't think that is easy to deduce by everybody. (see https://devblogs.microsoft.com/cppblog/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/)
MSVC 2017 has versions x..y.z where x is MSVC 2015, 2017 etc, y is the update number and z is the bugfix/patch-number.
I'm testing on MSVC 2017 15.9.7 (latest update and patch version)
I have a start at https://github.com/isturdy/opencensus-cpp/tree/travis-os-x. Failing to compile gRPC, predictably.
We don't currently have an API for adding/removing/replacing tags.
OpenCensus Go: https://github.com/census-instrumentation/opencensus-go/blob/ae36bd8445ff9cde752c94cf0d4f3f9dced1facc/tag/map.go
In the constructor, a span adds itself to the running span store. However, it is only removed from there in End(). Since a span has no user-defined destructor, this leads to a memory leak if End() is not called on the span.
I'd like to build with prometheus-exporter with CMake, which should be part of #244
I plan to add prometheus-exporter into CMake support on https://github.com/StevenYCChou/opencensus-cpp/tree/ycchou-add-prometheus-exporter-cmake .
I tempted to build only prometheus-cpp's core library, but when I pass
-DENABLE_PUSH=OFF -DENABLE_PULL=OFF -DENABLE_COMPRESSION=OFF -DENABLE_TESTING=OFF
through CMAKE_ARGS
, it doesn't really disable testing and compression for build time. The error message is:
% cmake CMakeLists.txt
-- Dependency: abseil
-- Configuring done
-- Generating done
-- Build files have been written to: /Codes/opencensus-cpp/abseil-download
[100%] Built target abseil_project
-- Configuring done
-- Generating done
-- Build files have been written to: /Codes/opencensus-cpp/prometheus-download
[100%] Built target prometheus_cpp_project
-- Could NOT find GoogleBenchmark (missing: GoogleBenchmark_LIBRARY GoogleBenchmark_INCLUDE_DIR)
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.10/Modules/FindZLIB.cmake:112 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
prometheus-src/pull/CMakeLists.txt:9 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Codes/opencensus-cpp/CMakeFiles/CMakeOutput.log".
See also "/Codes/opencensus-cpp/CMakeFiles/CMakeError.log".
Am I doing anything wrong?
bazel build //examples/grpc/...:all
INFO: Invocation ID: d03519eb-4a29-427c-b063-751b4799b838
ERROR: /home/vagrant/opencensus-cpp/opencensus/copts.bzl:24:1: file '@com_google_absl//absl:copts/configure_copts.bzl' does not contain symbol 'LLVM_FLAGS'
ERROR: /home/vagrant/opencensus-cpp/opencensus/copts.bzl:37:35: Traceback (most recent call last):
File "/home/vagrant/opencensus-cpp/opencensus/copts.bzl", line 36
select({"//opencensus:llvm_compiler": (...)})
File "/home/vagrant/opencensus-cpp/opencensus/copts.bzl", line 37, in select
LLVM_FLAGS
name 'LLVM_FLAGS' is not defined
ERROR: /home/vagrant/opencensus-cpp/opencensus/copts.bzl:42:14: name 'DEFAULT_COPTS' is not defined
ERROR: error loading package 'examples/grpc': Extension file 'opencensus/copts.bzl' has errors
INFO: Elapsed time: 0.276s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
currently loading: examples/grpc
there is an error within opencensus/copts.bzl
In this code below
we can see that we have 3 different cases that all have returns but the default case doesn't
Compiling code with it with -Wreturn-type
gives a bunch of warnings
INFO: From Compiling opencensus/exporters/stats/stackdriver/internal/stackdriver_utils.cc:
opencensus/exporters/stats/stackdriver/internal/stackdriver_utils.cc: In function 'google::api::MetricDescriptor::ValueType opencensus::exporters::stats::{anonymous}::GetValueType(const opencensus::stats::ViewDescriptor&)':
opencensus/exporters/stats/stackdriver/internal/stackdriver_utils.cc:86:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
opencensus/exporters/stats/stackdriver/internal/stackdriver_utils.cc: In function 'std::vector<google::monitoring::v3::TimeSeries> opencensus::exporters::stats::MakeTimeSeries(const opencensus::stats::ViewDescriptor&, const opencensus::stats::ViewData&, absl::string_view)':
opencensus/exporters/stats/stackdriver/internal/stackdriver_utils.cc:200:1: warning: control reaches end of non-void function [-Wreturn-type]
}
and in other places in the code.
In other languages such as Go that code wouldn't compile
Right now, tag keys are strings, and use string semantics. This has performance implications--we need to copy/hash/check equality frequently during aggregation.
We recommend that all keys be static constants to control visibility and avoid typos. Registering tag keys in the same way as measures (e.g. static const opencensus::stats::TagKey method = opencensus::stats::RegisterTagKey("method");
) would encourage these best practices and offer performance benefits throughout the library.
What about installation target in cmake?
Similar to https://github.com/grpc/grpc/blob/master/CMakeLists.txt
if (gRPC_INSTALL) install(EXPORT gRPCTargets DESTINATION ${gRPC_INSTALL_CMAKEDIR} NAMESPACE gRPC:: ) endif()
I'm seeing 50%ile latency at 2.5+ seconds (<1qps) to the BatchWriteSpans endpoint for the Stackdriver exporter. Unless this is abnormal (I didn't check to see if there was anything contributing to the high latency like large request size) then the deadline should at least be override-able from client code.
http_archive
rules in WORKSPACE all reference master and don't include a sha256. This leads to non-reproducible builds.
Request specific versions instead and include sha256's as described in the Bazel docs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.