LCOV - code coverage report
Current view: top level - http2 - MyTrafficHttp2Client.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 15 15
Test Date: 2026-04-17 17:21:26 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  ___________________________________________
       3              : |    _     ___                        _     |
       4              : |   | |   |__ \                      | |    |
       5              : |   | |__    ) |__ _  __ _  ___ _ __ | |_   |
       6              : |   | '_ \  / // _` |/ _` |/ _ \ '_ \| __|  |  HTTP/2 AGENT FOR MOCK TESTING
       7              : |   | | | |/ /| (_| | (_| |  __/ | | | |_   |  Version 0.0.z
       8              : |   |_| |_|____\__,_|\__, |\___|_| |_|\__|  |  https://github.com/testillano/h2agent
       9              : |                     __/ |                 |
      10              : |                    |___/                  |
      11              : |___________________________________________|
      12              : 
      13              : Licensed under the MIT License <http://opensource.org/licenses/MIT>.
      14              : SPDX-License-Identifier: MIT
      15              : Copyright (c) 2021 Eduardo Ramos
      16              : 
      17              : Permission is hereby  granted, free of charge, to any  person obtaining a copy
      18              : of this software and associated  documentation files (the "Software"), to deal
      19              : in the Software  without restriction, including without  limitation the rights
      20              : to  use, copy,  modify, merge,  publish, distribute,  sublicense, and/or  sell
      21              : copies  of  the Software,  and  to  permit persons  to  whom  the Software  is
      22              : furnished to do so, subject to the following conditions:
      23              : 
      24              : The above copyright notice and this permission notice shall be included in all
      25              : copies or substantial portions of the Software.
      26              : 
      27              : THE SOFTWARE  IS PROVIDED "AS  IS", WITHOUT WARRANTY  OF ANY KIND,  EXPRESS OR
      28              : IMPLIED,  INCLUDING BUT  NOT  LIMITED TO  THE  WARRANTIES OF  MERCHANTABILITY,
      29              : FITNESS FOR  A PARTICULAR PURPOSE AND  NONINFRINGEMENT. IN NO EVENT  SHALL THE
      30              : AUTHORS  OR COPYRIGHT  HOLDERS  BE  LIABLE FOR  ANY  CLAIM,  DAMAGES OR  OTHER
      31              : LIABILITY, WHETHER IN AN ACTION OF  CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      32              : OUT OF OR IN CONNECTION WITH THE SOFTWARE  OR THE USE OR OTHER DEALINGS IN THE
      33              : SOFTWARE.
      34              : */
      35              : 
      36              : #include <boost/optional.hpp>
      37              : #include <sstream>
      38              : #include <map>
      39              : #include <errno.h>
      40              : 
      41              : 
      42              : #include <ert/tracing/Logger.hpp>
      43              : #include <ert/http2comm/Http.hpp>
      44              : #include <ert/http2comm/Http2Headers.hpp>
      45              : #include <ert/http2comm/URLFunctions.hpp>
      46              : 
      47              : #include <MyTrafficHttp2Client.hpp>
      48              : 
      49              : #include <AdminData.hpp>
      50              : #include <MockClientData.hpp>
      51              : #include <Configuration.hpp>
      52              : #include <Vault.hpp>
      53              : #include <FileManager.hpp>
      54              : #include <SocketManager.hpp>
      55              : #include <functions.hpp>
      56              : 
      57              : namespace h2agent
      58              : {
      59              : namespace http2
      60              : {
      61              : 
      62           10 : void MyTrafficHttp2Client::enableMyMetrics(ert::metrics::Metrics *metrics, const std::string &source) {
      63              : 
      64           10 :     metrics_ = metrics;
      65              : 
      66           10 :     if (metrics_) {
      67            2 :         std::string src = source.empty() ? name_ : source;
      68              : 
      69              :         // Family labels are constant labels shared by all metrics in the family.
      70              :         // Use for invariant dimensions (e.g. {{"deployment", "canary"}} or {{"region", "eu-west-1"}}).
      71              :         // Variable dimensions like 'source' go as instance labels in Add() calls,
      72              :         // allowing multiple client endpoints to coexist in the same family.
      73            2 :         ert::metrics::labels_t familyLabels = {};
      74              : 
      75            8 :         ert::metrics::counter_family_t& cf = metrics->addCounterFamily("h2agent_traffic_client_provisioned_requests_counter", "Requests provisioned counter in h2agent_traffic_client", familyLabels);
      76            8 :         provisioned_requests_successful_counter_ = &(cf.Add({{"source", src}, {"result", "successful"}}));
      77            8 :         provisioned_requests_failed_counter_ = &(cf.Add({{"source", src}, {"result", "failed"}}));
      78              : 
      79            8 :         ert::metrics::counter_family_t& cf2 = metrics->addCounterFamily("h2agent_traffic_client_purged_contexts_counter", "Contexts purged counter in h2agent_traffic_client", familyLabels);
      80            8 :         purged_contexts_successful_counter_ = &(cf2.Add({{"source", src}, {"result", "successful"}}));
      81            8 :         purged_contexts_failed_counter_ = &(cf2.Add({{"source", src}, {"result", "failed"}}));
      82              : 
      83            8 :         ert::metrics::counter_family_t& cf3 = metrics->addCounterFamily("h2agent_traffic_client_unexpected_response_status_code_counter", "Unexpected response status code counter in h2agent_traffic_client", familyLabels);
      84            6 :         unexpected_response_status_code_counter_ = &(cf3.Add({{"source", src}}));
      85            2 :     }
      86           20 : }
      87              : 
      88              : }
      89              : }
        

Generated by: LCOV version 2.0-1