diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/InstrumentationI.cpp | 55 | ||||
-rw-r--r-- | cpp/src/Ice/MetricsAdminI.cpp | 69 | ||||
-rw-r--r-- | cpp/src/Ice/MetricsAdminI.h | 8 | ||||
-rw-r--r-- | cpp/src/Ice/MetricsObserverI.h | 16 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesAdminI.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceStorm/InstrumentationI.cpp | 7 |
6 files changed, 106 insertions, 52 deletions
diff --git a/cpp/src/Ice/InstrumentationI.cpp b/cpp/src/Ice/InstrumentationI.cpp index 4e57ea93285..139e304a673 100644 --- a/cpp/src/Ice/InstrumentationI.cpp +++ b/cpp/src/Ice/InstrumentationI.cpp @@ -151,7 +151,7 @@ public: { add("parent", &ConnectionHelper::getParent); add("id", &ConnectionHelper::getId); - + add("endpoint", &ConnectionHelper::getEndpoint); addConnectionAttributes<ConnectionHelper>(*this); } }; @@ -189,6 +189,10 @@ public: { os << "connection-" << _connectionInfo.get(); } + if(!_connectionInfo->connectionId.empty()) + { + os << " [" << _connectionInfo->connectionId << "]"; + } _id = os.str(); } return _id; @@ -213,6 +217,12 @@ public: return _connectionInfo; } + const EndpointPtr& + getEndpoint() const + { + return _endpoint; + } + const EndpointInfoPtr& getEndpointInfo() const { @@ -246,12 +256,12 @@ public: { add("parent", &DispatchHelper::getParent); add("id", &DispatchHelper::getId); + add("endpoint", &DispatchHelper::getEndpoint); addConnectionAttributes<DispatchHelper>(*this); add("operation", &DispatchHelper::getCurrent, &Current::operation); - add("identityCategory", &DispatchHelper::getIdentity, &Identity::category); - add("identityName", &DispatchHelper::getIdentity, &Identity::name); + add("identity", &DispatchHelper::getIdentity); add("facet", &DispatchHelper::getCurrent, &Current::facet); add("encoding", &DispatchHelper::getCurrent, &Current::encoding); add("mode", &DispatchHelper::getMode); @@ -317,6 +327,12 @@ public: return _current.con->getInfo(); } + EndpointPtr + getEndpoint() const + { + return _current.con->getEndpoint(); + } + const EndpointInfoPtr& getEndpointInfo() const { @@ -333,10 +349,10 @@ public: return _current; } - const Identity& + string getIdentity() const { - return _current.id; + return _current.adapter->getCommunicator()->identityToString(_current.id); } private: @@ -362,8 +378,7 @@ public: add("id", &InvocationHelper::getId); add("operation", &InvocationHelper::getOperation); - add("identityCategory", &InvocationHelper::getIdentity, &Identity::category); - add("identityName", &InvocationHelper::getIdentity, &Identity::name); + add("identity", &InvocationHelper::getIdentity); add("facet", &InvocationHelper::getProxy, &IceProxy::Ice::Object::ice_getFacet); add("encoding", &InvocationHelper::getProxy, &IceProxy::Ice::Object::ice_getEncodingVersion); add("mode", &InvocationHelper::getMode); @@ -471,16 +486,16 @@ public: } - Identity + string getIdentity() const { if(_proxy) { - return _proxy->ice_getIdentity(); + return _proxy->ice_getCommunicator()->identityToString(_proxy->ice_getIdentity()); } else { - return Identity(); + return ""; } } @@ -512,6 +527,7 @@ public: { add("parent", &RemoteInvocationHelper::getParent); add("id", &RemoteInvocationHelper::getId); + add("endpoint", &RemoteInvocationHelper::getEndpoint); addConnectionAttributes<RemoteInvocationHelper>(*this); } }; @@ -532,17 +548,11 @@ public: { if(_id.empty()) { - ostringstream os; - IPConnectionInfoPtr info = IPConnectionInfoPtr::dynamicCast(_connectionInfo); - if(info) - { - os << info->remoteAddress << ':' << info->remotePort; - } - else + _id = _endpoint->toString(); + if(!_connectionInfo->connectionId.empty()) { - os << "connection-" << _connectionInfo.get(); + _id += " [" + _connectionInfo->connectionId + "]"; } - _id = os.str(); } return _id; } @@ -566,6 +576,12 @@ public: return _connectionInfo; } + const EndpointPtr& + getEndpoint() const + { + return _endpoint; + } + const EndpointInfoPtr& getEndpointInfo() const { @@ -640,6 +656,7 @@ public: { add("parent", &EndpointHelper::getParent); add("id", &EndpointHelper::getId); + add("endpoint", &EndpointHelper::getId); addEndpointAttributes<EndpointHelper>(*this); } }; diff --git a/cpp/src/Ice/MetricsAdminI.cpp b/cpp/src/Ice/MetricsAdminI.cpp index 71651d83f82..d70ca64458b 100644 --- a/cpp/src/Ice/MetricsAdminI.cpp +++ b/cpp/src/Ice/MetricsAdminI.cpp @@ -11,6 +11,7 @@ #include <Ice/InstrumentationI.h> #include <Ice/Properties.h> +#include <Ice/Logger.h> #include <Ice/Communicator.h> #include <Ice/Instance.h> #include <Ice/LoggerUtil.h> @@ -28,8 +29,8 @@ const string viewSuffixes[] = { "Disabled", "GroupBy", - "Accept", - "Reject", + "Accept.*", + "Reject.*", "RetainDetached", "Map.*", }; @@ -37,8 +38,8 @@ const string viewSuffixes[] = const string mapSuffixes[] = { "GroupBy", - "Accept", - "Reject", + "Accept.*", + "Reject.*", "RetainDetached", }; @@ -84,7 +85,14 @@ parseRule(const PropertiesPtr& properties, const string& name) PropertyDict rules = properties->getPropertiesForPrefix(name + '.'); for(PropertyDict::const_iterator p = rules.begin(); p != rules.end(); ++p) { - regexps.push_back(new MetricsMapI::RegExp(p->first.substr(name.length() + 1), p->second)); + try + { + regexps.push_back(new MetricsMapI::RegExp(p->first.substr(name.length() + 1), p->second)); + } + catch(const std::exception&) + { + throw "invalid regular expression `" + p->second + "' for `" + p->first + "'"; + } } return regexps; } @@ -111,15 +119,15 @@ MetricsMapI::RegExp::~RegExp() } bool -MetricsMapI::RegExp::match(const MetricsHelper& helper) +MetricsMapI::RegExp::match(const MetricsHelper& helper, bool reject) { string value = helper(_attribute); -#ifndef ICE_CPP11_REGEXP - if(regexec(&_preg, value.c_str(), 0, 0, 0) == 0) + if(value == "unknown") // Unknown attributes are ignored by filtering { - return true; + return !reject; } - return false; +#ifndef ICE_CPP11_REGEXP + return regexec(&_preg, value.c_str(), 0, 0, 0) == 0; #else return regex_match(value, _regex); #endif @@ -228,7 +236,8 @@ MetricsViewI::MetricsViewI(const string& name) : _name(name) void MetricsViewI::update(const PropertiesPtr& properties, const map<string, MetricsMapFactoryPtr>& factories, - set<MetricsMapFactoryPtr>& updatedMaps) + set<MetricsMapFactoryPtr>& updatedMaps, + const Ice::LoggerPtr& logger) { // // Add maps to views configured with the given map. @@ -263,7 +272,23 @@ MetricsViewI::update(const PropertiesPtr& properties, { continue; // The map configuration didn't change, no need to re-create. } - _maps[mapName] = p->second->create(mapPrefix, properties); + + try + { + _maps[mapName] = p->second->create(mapPrefix, properties); + } + catch(const std::exception& ex) + { + Ice::Warning warn(logger); + warn << "unexpected exception while creating metrics map:\n" << ex; + _maps.erase(mapName); + } + catch(const string& msg) + { + Ice::Warning warn(logger); + warn << msg; + _maps.erase(mapName); + } updatedMaps.insert(p->second); } } @@ -274,7 +299,11 @@ MetricsViewI::getMetrics() MetricsView metrics; for(map<string, MetricsMapIPtr>::const_iterator p = _maps.begin(); p != _maps.end(); ++p) { - metrics.insert(make_pair(p->first, p->second->getMetrics())); + MetricsMap map = p->second->getMetrics(); + if(!map.empty()) + { + metrics.insert(make_pair(p->first, map)); + } } return metrics; } @@ -324,7 +353,7 @@ MetricsViewI::getMap(const string& mapName) const } MetricsAdminI::MetricsAdminI(const PropertiesPtr& properties, const LoggerPtr& logger) : - _properties(properties), _logger(logger) + _logger(logger), _properties(properties) { } @@ -371,7 +400,7 @@ MetricsAdminI::updateViews() { q = views.insert(make_pair(viewName, q->second)).first; } - q->second->update(_properties, _factories, updatedMaps); + q->second->update(_properties, _factories, updatedMaps, _logger); } _views.swap(views); @@ -485,7 +514,15 @@ MetricsAdminI::updated(const PropertyDict& props) if(p->first.find("IceMX.") == 0) { // Udpate the metrics views using the new configuration. - updateViews(); + try + { + updateViews(); + } + catch(const std::exception& ex) + { + Ice::Warning warn(_logger); + warn << "unexpected exception while updating metrics view configuration:\n" << ex.what(); + } return; } } diff --git a/cpp/src/Ice/MetricsAdminI.h b/cpp/src/Ice/MetricsAdminI.h index ad30849244e..ffc32850fa2 100644 --- a/cpp/src/Ice/MetricsAdminI.h +++ b/cpp/src/Ice/MetricsAdminI.h @@ -46,7 +46,7 @@ public: RegExp(const std::string&, const std::string&); ~RegExp(); - bool match(const MetricsHelper&); + bool match(const MetricsHelper&, bool); private: const std::string _attribute; @@ -330,7 +330,7 @@ public: // for(std::vector<RegExpPtr>::const_iterator p = _accept.begin(); p != _accept.end(); ++p) { - if(!(*p)->match(helper)) + if(!(*p)->match(helper, false)) { return 0; } @@ -338,7 +338,7 @@ public: for(std::vector<RegExpPtr>::const_iterator p = _reject.begin(); p != _reject.end(); ++p) { - if((*p)->match(helper)) + if((*p)->match(helper, true)) { return 0; } @@ -482,7 +482,7 @@ public: MetricsViewI(const std::string&); void update(const Ice::PropertiesPtr&, const std::map<std::string, MetricsMapFactoryPtr>&, - std::set<MetricsMapFactoryPtr>&); + std::set<MetricsMapFactoryPtr>&, const Ice::LoggerPtr&); MetricsView getMetrics(); MetricsFailuresSeq getFailures(const std::string&); diff --git a/cpp/src/Ice/MetricsObserverI.h b/cpp/src/Ice/MetricsObserverI.h index 2e216cca87b..e39caf38644 100644 --- a/cpp/src/Ice/MetricsObserverI.h +++ b/cpp/src/Ice/MetricsObserverI.h @@ -14,7 +14,7 @@ #include <Ice/Instrumentation.h> #include <Ice/Metrics.h> - +#include <Ice/Endpoint.h> #include <Ice/MetricsAdminI.h> #include <Ice/MetricsFunctional.h> @@ -229,6 +229,12 @@ protected: } static std::string + toString(const Ice::EndpointPtr& e) + { + return e->toString(); + } + + static std::string toString(bool v) { return v ? "true" : "false"; @@ -509,13 +515,7 @@ public: if(updater) { - try - { - updater->update(); - } - catch(const std::exception& ex) - { - } + updater->update(); } } diff --git a/cpp/src/Ice/PropertiesAdminI.cpp b/cpp/src/Ice/PropertiesAdminI.cpp index 93650cc5259..898f0414f13 100644 --- a/cpp/src/Ice/PropertiesAdminI.cpp +++ b/cpp/src/Ice/PropertiesAdminI.cpp @@ -158,7 +158,8 @@ Ice::PropertiesAdminI::setProperties_async(const AMD_PropertiesAdmin_setProperti } // - // Send the response now so that we do not block the client during the call to the update callback. + // Send the response now so that we do not block the client during + // the call to the update callback. // cb->ice_response(); diff --git a/cpp/src/IceStorm/InstrumentationI.cpp b/cpp/src/IceStorm/InstrumentationI.cpp index 24d6c5d2ef0..a7ad8ef1ae7 100644 --- a/cpp/src/IceStorm/InstrumentationI.cpp +++ b/cpp/src/IceStorm/InstrumentationI.cpp @@ -81,8 +81,7 @@ public: add("topic", &SubscriberHelper::getTopic); add("service", &SubscriberHelper::getService); - add("identityCategory", &SubscriberHelper::getIdentity, &Identity::category); - add("identityName", &SubscriberHelper::getIdentity, &Identity::name); + add("identity", &SubscriberHelper::getIdentity); add("facet", &SubscriberHelper::getProxy, &IceProxy::Ice::Object::ice_getFacet); add("encoding", &SubscriberHelper::getProxy, &IceProxy::Ice::Object::ice_getEncodingVersion); add("mode", &SubscriberHelper::getMode); @@ -186,10 +185,10 @@ public: return _proxy; } - Identity + string getIdentity() const { - return _proxy->ice_getIdentity(); + return _proxy->ice_getCommunicator()->identityToString(_proxy->ice_getIdentity()); } private: |