1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
12 #include <anna/diameter.comm/MessageStatistics.hpp>
13 #include <anna/statistics/Engine.hpp>
14 #include <anna/diameter/functions.hpp>
15 #include <anna/diameter/helpers/defines.hpp>
16 #include <anna/diameter/codec/Message.hpp>
17 #include <anna/diameter/codec/Engine.hpp>
18 #include <anna/diameter/codec/EngineManager.hpp>
21 void anna::diameter::comm::MessageStatistics::initialize(const std::string &name) throw(anna::RuntimeException) {
22 a_accumulator = anna::statistics::Engine::instantiate().createAccumulator(name);
26 void anna::diameter::comm::MessageStatistics::process(const ConceptType::_v &conceptType, const anna::diameter::CommandId &cid, const double & value) throw(anna::RuntimeException) {
29 // if (!a_accumulator) {
30 // LOGWARNING(anna::Logger::warning("Cannot process uninitialized 'MessageStatistics' instance", ANNA_FILE_LOCATION));
34 // retrieve the concept id for the pair:
35 ConceptId conceptId(cid, conceptType);
36 int engine_concept_id = 0;
37 concepts_map_it it = a_concepts.find(conceptId);
38 if (it != a_concepts.end()) { // found
39 engine_concept_id = it->second;
41 else { // register a new concept id
42 std::string description;
43 if(conceptType == ConceptType::SentRequestProcessingTime) {
44 description = anna::functions::asString("Processing time for outgoing requests (code = %d)", cid.first);
46 else if (conceptType == ConceptType::ReceivedMessageSize) {
47 description = "Message size for received messages ";
48 description += anna::diameter::functions::commandIdAsPairString(cid);
51 engine_concept_id = a_accumulator->addConcept(description, "ms", true/* integer values */);
52 a_concepts[conceptId] = engine_concept_id;
55 a_accumulator->process(engine_concept_id, value);