Skip to content

Commit

Permalink
processor: Include state change and error count in stat
Browse files Browse the repository at this point in the history
Drop rx/tx fields since they are always 0
  • Loading branch information
shramov committed Nov 22, 2024
1 parent 8b00722 commit b46ee2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/processor/deps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@ int Object::callback(const Channel *c, const tll_msg_t *msg)
data.state = s;
worker->post(data);

if (auto block = worker->stat(); block) {
if (auto page = block->acquire(); page) {
page->state.update(1);
if (s == tll::state::Error)
page->error.update(1);
block->release(page);
}
}

return 0;
}
9 changes: 6 additions & 3 deletions src/processor/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef _PROCESSOR_WORKER_H
#define _PROCESSOR_WORKER_H

#include <string>
#include <string_view>

#include "processor/deps.h"
#include "tll/channel/base.h"
Expand All @@ -28,14 +28,17 @@ struct Worker : public tll::channel::Base<Worker>

tll::processor::Loop loop;

struct StatType : public Base::StatType
//< Stat structure for Worker. It is not derived from base struct since worker has no messages
struct StatType
{
tll::stat::Integer<tll::stat::Sum, tll::stat::Unknown, 's', 't', 'e', 'p'> step;
tll::stat::Integer<tll::stat::Sum, tll::stat::Ns, 'p', 'o', 'l', 'l'> poll;
tll_stat_field_t padding[2] = {};
tll::stat::Integer<tll::stat::Sum, tll::stat::Unknown, 's', 't', 'a', 't', 'e'> state;
tll::stat::Integer<tll::stat::Sum, tll::stat::Unknown, 'e', 'r', 'r', 'o', 'r'> error;
};

std::optional<tll::stat::Block<StatType>> _stat;
auto stat() { return static_cast<stat::BlockT<StatType> *>(internal.stat); }

std::list<Object *> objects;
struct {
Expand Down

0 comments on commit b46ee2d

Please sign in to comment.