Skip to content

Support logging elapsed time on tracers#1186

Merged
anoop-sysd merged 1 commit intodevfrom
tracer-timing
Aug 3, 2018
Merged

Support logging elapsed time on tracers#1186
anoop-sysd merged 1 commit intodevfrom
tracer-timing

Conversation

@gnosek
Copy link
Contributor

@gnosek gnosek commented Aug 2, 2018

Apart from having the tracers in the first place, allow setting
a timeout, after which we log a message to bring our attention
to the problem in the first place.

Apart from having the tracers in the first place, allow setting
a timeout, after which we log a message to bring our attention
to the problem in the first place.
tracer_emitter::tracer_emitter(std::string tag)
tracer_emitter::tracer_emitter(std::string tag, uint64_t timeout_ns)
: m_tag(std::move(tag))
, m_start_ns(sinsp_utils::get_current_time_ns())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to allow providing an external timestamp for now. I remember in the past where lots of calls to sinsp_utils::get_current_time_ns() ended up being expensive.


uint64_t tracer_emitter::elapsed_time() const
{
auto elapsed = sinsp_utils::get_current_time_ns() - m_start_ns;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto on externally provided time, although you may only be able to specify it when explicitly calling stop().

@anoop-sysd anoop-sysd merged commit 7b209ae into dev Aug 3, 2018
@anoop-sysd anoop-sysd deleted the tracer-timing branch August 3, 2018 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants