Skip to content

Add events in SpanData#194

Merged
reyang merged 5 commits into
open-telemetry:masterfrom
nadiaciobanu:events-spandata
Jul 21, 2020
Merged

Add events in SpanData#194
reyang merged 5 commits into
open-telemetry:masterfrom
nadiaciobanu:events-spandata

Conversation

@nadiaciobanu
Copy link
Copy Markdown
Contributor

Implement AddEvent for SpanData. Currently only name and timestamp can be set due to limitations in the recordable interface. In the future, attributes should also be supported in events.

@nadiaciobanu nadiaciobanu requested a review from a team July 20, 2020 21:56
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 20, 2020

Codecov Report

Merging #194 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #194      +/-   ##
==========================================
+ Coverage   95.45%   95.51%   +0.05%     
==========================================
  Files          87       91       +4     
  Lines        2488     2521      +33     
==========================================
+ Hits         2375     2408      +33     
  Misses        113      113              
Impacted Files Coverage Δ
sdk/include/opentelemetry/sdk/trace/span_data.h 100.00% <100.00%> (ø)
sdk/test/trace/span_data_test.cc 100.00% <100.00%> (ø)
sdk/test/trace/tracer_provider_test.cc 100.00% <0.00%> (ø)
sdk/src/metrics/meter_provider.cc 100.00% <0.00%> (ø)
sdk/include/opentelemetry/sdk/metrics/meter.h 100.00% <0.00%> (ø)
...include/opentelemetry/sdk/metrics/meter_provider.h 100.00% <0.00%> (ø)
sdk/test/metrics/meter_provider_sdk_test.cc 100.00% <0.00%> (ø)

Copy link
Copy Markdown
Contributor

@pyohannes pyohannes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good, thanks!

Would you be willing to work on extending the Recordable interface by an AddEvent method that supports attributes? And probably also by an AddLink method?

There's lots of work going on in exporter development now, and having those methods sooner rather than later will spare us painful work in the future (as any update to Recordable breaks compatibility for exporters).

Comment thread sdk/include/opentelemetry/sdk/trace/span_data.h Outdated
Comment thread sdk/include/opentelemetry/sdk/trace/span_data.h Outdated
@nadiaciobanu
Copy link
Copy Markdown
Contributor Author

@pyohannes yes, that sounds good! I can add those in a future PR.

Copy link
Copy Markdown
Contributor

@pyohannes pyohannes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks.

@pyohannes pyohannes added the pr:please-merge This PR is ready to be merged by a Maintainer (rebased, CI passed, has enough valid approvals, etc.) label Jul 21, 2020
Copy link
Copy Markdown
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@reyang reyang merged commit f73f5bf into open-telemetry:master Jul 21, 2020
@ZiweiZhao
Copy link
Copy Markdown

LGTM :)

Copy link
Copy Markdown

@IlyaKobelevskiy IlyaKobelevskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor nits, but overall looks good!

Comment on lines +110 to +111
std::string name_;
core::SystemTimestamp timestamp_;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both name_ and timestamp_ can be const membes since they are only set in ctor.

* Get the name for this event
* @return the name for this event
*/
std::string GetName() const noexcept { return name_; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::string -> -> opentelemetry::nostd::string_view (for consistency with how SpanData returns string members, and it also should avoid copy).

{
public:
SpanDataEvent(std::string name, core::SystemTimestamp timestamp)
: name_(name), timestamp_(timestamp)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::string -> opentelemetry::nostd::string_view (for consistency with how SpanData sets string members).

ASSERT_EQ(data.GetDuration(), std::chrono::nanoseconds(1000000));
ASSERT_EQ(opentelemetry::nostd::get<int64_t>(data.GetAttributes().at("attr1")), 314159);
ASSERT_EQ(data.GetEvents().at(0).GetName(), "event1");
ASSERT_EQ(data.GetEvents().at(0).GetTimestamp(), now);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ASSERT_EQ can be replaced by EXPECT_EQ throughout this file.

@nadiaciobanu nadiaciobanu deleted the events-spandata branch July 23, 2020 22:34
GerHobbelt pushed a commit to GerHobbelt/opentelemetry-cpp that referenced this pull request Jun 17, 2025
…s-create-or-update-comment-digest

Update peter-evans/create-or-update-comment digest to 5a1e4b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:please-merge This PR is ready to be merged by a Maintainer (rebased, CI passed, has enough valid approvals, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants