Skip to content

Commit

Permalink
Remove service name from IceStorm metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
externl committed Oct 14, 2024
1 parent 66dd217 commit ee09ae8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 36 deletions.
8 changes: 2 additions & 6 deletions cpp/src/IceStorm/Instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,11 @@ namespace IceStorm::Instrumentation

/**
* This method should return an observer for the given topic.
* @param svc The service name.
* @param name The topic name.
* @param old The previous observer, only set when updating an existing observer.
*/
virtual std::shared_ptr<TopicObserver> getTopicObserver(
const std::string& svc,
const std::string& name,
const std::shared_ptr<TopicObserver>& old) = 0;
virtual std::shared_ptr<TopicObserver>
getTopicObserver(const std::string& name, const std::shared_ptr<TopicObserver>& old) = 0;

/**
* This method should return an observer for the given subscriber.
Expand All @@ -115,7 +112,6 @@ namespace IceStorm::Instrumentation
* @param old The previous observer, only set when updating an existing observer.
*/
virtual std::shared_ptr<SubscriberObserver> getSubscriberObserver(
const std::string& svc,
const std::string& topic,
const Ice::ObjectPrx& prx,
const QoS& q,
Expand Down
25 changes: 5 additions & 20 deletions cpp/src/IceStorm/InstrumentationI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,19 @@ namespace
public:
Attributes()
{
add("parent", &TopicHelper::getService);
add("id", &TopicHelper::getId);
add("topic", &TopicHelper::getId);
add("service", &TopicHelper::getService);
}
};
static Attributes attributes;

TopicHelper(const string& service, const string& name) : _service(service), _name(name) {}
TopicHelper(const string& name) : _name(name) {}

virtual string operator()(const string& attribute) const { return attributes(this, attribute); }

const string& getService() const { return _service; }

const string& getId() const { return _name; }

private:
const string& _service;
const string& _name;
};

Expand All @@ -58,7 +53,6 @@ namespace
add("parent", &SubscriberHelper::getTopic);
add("id", &SubscriberHelper::getId);
add("topic", &SubscriberHelper::getTopic);
add("service", &SubscriberHelper::getService);

add("identity", &SubscriberHelper::getIdentity);

Expand All @@ -75,14 +69,12 @@ namespace
static Attributes attributes;

SubscriberHelper(
const string& svc,
const string& topic,
const Ice::ObjectPrx& proxy,
const IceStorm::QoS& qos,
optional<IceStorm::TopicPrx> link,
SubscriberState state)
: _service(svc),
_topic(topic),
: _topic(topic),
_proxy(proxy),
_qos(qos),
_link(std::move(link)),
Expand All @@ -109,8 +101,6 @@ namespace
throw invalid_argument(attribute);
}

const string& getService() const { return _service; }

const string& getTopic() const { return _topic; }

string getMode() const
Expand Down Expand Up @@ -181,7 +171,6 @@ namespace
}

private:
const string& _service;
const string& _topic;
const Ice::ObjectPrx& _proxy;
const IceStorm::QoS& _qos;
Expand Down Expand Up @@ -287,16 +276,13 @@ TopicManagerObserverI::setObserverUpdater(const shared_ptr<ObserverUpdater>& upd
}

shared_ptr<TopicObserver>
TopicManagerObserverI::getTopicObserver(
const string& service, // TODO: should always be "IceStorm"
const string& topic,
const shared_ptr<TopicObserver>& old)
TopicManagerObserverI::getTopicObserver(const string& topic, const shared_ptr<TopicObserver>& old)
{
if (_topics.isEnabled())
{
try
{
return _topics.getObserver(TopicHelper(service, topic), old);
return _topics.getObserver(TopicHelper(topic), old);
}
catch (const exception& ex)
{
Expand All @@ -309,7 +295,6 @@ TopicManagerObserverI::getTopicObserver(

shared_ptr<SubscriberObserver>
TopicManagerObserverI::getSubscriberObserver(
const string& svc,
const string& topic,
const Ice::ObjectPrx& proxy,
const IceStorm::QoS& qos,
Expand All @@ -321,7 +306,7 @@ TopicManagerObserverI::getSubscriberObserver(
{
try
{
return _subscribers.getObserver(SubscriberHelper(svc, topic, proxy, qos, link, state), old);
return _subscribers.getObserver(SubscriberHelper(topic, proxy, qos, link, state), old);
}
catch (const exception& ex)
{
Expand Down
7 changes: 2 additions & 5 deletions cpp/src/IceStorm/InstrumentationI.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ namespace IceStorm

void setObserverUpdater(const std::shared_ptr<IceStorm::Instrumentation::ObserverUpdater>&) override;

std::shared_ptr<IceStorm::Instrumentation::TopicObserver> getTopicObserver(
const std::string&,
const std::string&,
const std::shared_ptr<IceStorm::Instrumentation::TopicObserver>&) override;
std::shared_ptr<IceStorm::Instrumentation::TopicObserver>
getTopicObserver(const std::string&, const std::shared_ptr<IceStorm::Instrumentation::TopicObserver>&) override;

std::shared_ptr<IceStorm::Instrumentation::SubscriberObserver> getSubscriberObserver(
const std::string&,
const std::string&,
const Ice::ObjectPrx&,
const IceStorm::QoS&,
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/IceStorm/Subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,6 @@ Subscriber::updateObserver()
{
assert(_rec.obj);
_observer.attach(_instance->observer()->getSubscriberObserver(
"IceStorm",
_rec.topicName,
*_rec.obj,
_rec.theQoS,
Expand Down Expand Up @@ -852,7 +851,6 @@ Subscriber::Subscriber(
{
assert(_rec.obj);
_observer.attach(_instance->observer()->getSubscriberObserver(
"IceStorm",
_rec.topicName,
*_rec.obj,
_rec.theQoS,
Expand Down Expand Up @@ -900,7 +898,6 @@ Subscriber::setState(Subscriber::SubscriberState state)
{
assert(_rec.obj);
_observer.attach(_instance->observer()->getSubscriberObserver(
"IceStorm",
_rec.topicName,
*_rec.obj,
_rec.theQoS,
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/IceStorm/TopicI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ TopicImpl::TopicImpl(

if (_instance->observer())
{
_observer.attach(_instance->observer()->getTopicObserver("IceStorm", _name, nullptr));
_observer.attach(_instance->observer()->getTopicObserver(_name, nullptr));
}
}
catch (const std::exception&)
Expand Down Expand Up @@ -1140,7 +1140,7 @@ TopicImpl::updateObserver()

if (_instance->observer())
{
_observer.attach(_instance->observer()->getTopicObserver("IceStorm", _name, _observer.get()));
_observer.attach(_instance->observer()->getTopicObserver(_name, _observer.get()));
}
}

Expand Down

0 comments on commit ee09ae8

Please sign in to comment.