3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
23 Abstract: Headers for the metrics class.
24 This class provides a simple interface for an xAPP to compose and
25 send metrics. The class allows the xAPP to name the metric and to
26 provide one or more key/value pairs which are sent to the metrics
27 gateway (munchkin) when Send() is invoked. The class hides the
28 true message structure that the munchkin desires from the xAPP.
30 The munchkin endpoint is assumed to be a routable target and thus
31 normal RMR messages (with appropriate type) are sent.
34 Author: E. Scott Daniels
37 #ifndef _XAPP_METRICS_HPP
38 #define _XAPP_METRICS_HPP
44 #include "msg_component.hpp"
48 // ------------------------------------------------------------------------
51 This class is loosely tied to the json expected by the munchkin. See the munchkin
52 documentation for explicit information, but this will help to understand a bit:
54 "reporter": "<string>",
55 "generator" "<string>",
69 std::shared_ptr<Message> msg; // message to send
71 // data for the payload
72 std::string reporter; // this application as it's reporting the metrics
73 std::string source; // source of the measurement if not the reporter
74 std::string data; // key/value/type tuples "pushed" waiting for send
77 int build_payload( xapp::Msg_component payload, int payload_len );
81 Metrics( std::shared_ptr<Message> msg ); // builders
82 Metrics( std::shared_ptr<Message> msg, std::string msource ); // allow xapp to supply metric source
83 Metrics( std::shared_ptr<Message> msg, std::string reporter, std::string msource ); // allow xapp to supply all
85 Metrics( const Metrics& soi ); // copy to newly created instance
86 Metrics& operator=( const Metrics& soi ); // copy operator
87 Metrics( Metrics&& soi ); // mover
88 Metrics& operator=( Metrics&& soi ); // move operator
89 ~Metrics(); // destroyer
92 void Set_source( std::string new_source );
93 void Set_reporter( std::string new_reporter );
94 void Push_data( std::string key, double value );