Tor  0.4.7.0-alpha-dev
Macros | Functions
hs_metrics.c File Reference

Onion service metrics exposed through the MetricsPort. More...

#include "orconfig.h"
#include "lib/malloc/malloc.h"
#include "lib/container/smartlist.h"
#include "lib/metrics/metrics_store.h"
#include "feature/hs/hs_metrics.h"
#include "feature/hs/hs_metrics_entry.h"
#include "feature/hs/hs_service.h"

Go to the source code of this file.

Functions

static const char * port_to_str (const uint16_t port)
 
static void init_store (hs_service_t *service)
 
void hs_metrics_update_by_service (const hs_metrics_key_t key, hs_service_t *service, const uint16_t port, int64_t n)
 
void hs_metrics_update_by_ident (const hs_metrics_key_t key, const ed25519_public_key_t *ident_pk, const uint16_t port, int64_t n)
 
const smartlist_ths_metrics_get_stores (void)
 
void hs_metrics_service_init (hs_service_t *service)
 
void hs_metrics_service_free (hs_service_t *service)
 

Detailed Description

Onion service metrics exposed through the MetricsPort.

Definition in file hs_metrics.c.

Function Documentation

◆ hs_metrics_get_stores()

const smartlist_t* hs_metrics_get_stores ( void  )

Return a list of all the onion service metrics stores. This is the function attached to the .get_metrics() member of the subsys_t.

Definition at line 123 of file hs_metrics.c.

◆ hs_metrics_service_free()

void hs_metrics_service_free ( hs_service_t service)

Free the metrics store in the given service.

Definition at line 154 of file hs_metrics.c.

◆ hs_metrics_service_init()

void hs_metrics_service_init ( hs_service_t service)

Initialize the metrics store in the given service.

Definition at line 136 of file hs_metrics.c.

Referenced by register_service().

◆ hs_metrics_update_by_ident()

void hs_metrics_update_by_ident ( const hs_metrics_key_t  key,
const ed25519_public_key_t ident_pk,
const uint16_t  port,
int64_t  n 
)

Update the metrics key entry in the store of a service identified by the given identity public key. The port, if non 0, is used to find the correct metrics entry. The value n is the value used to update the entry.

This is used by callsite that have access to the key but not the service object so an extra lookup is done to find the service.

Definition at line 101 of file hs_metrics.c.

◆ hs_metrics_update_by_service()

void hs_metrics_update_by_service ( const hs_metrics_key_t  key,
hs_service_t service,
const uint16_t  port,
int64_t  n 
)

Update the metrics key entry in the store in the given service. The port, if non 0, is used to find the correct metrics entry. The value n is the value used to update the entry.

Definition at line 67 of file hs_metrics.c.

Referenced by hs_metrics_update_by_ident().

◆ init_store()

static void init_store ( hs_service_t service)
static

Initialize a metrics store for the given service.

Essentially, this goes over the base_metrics array and adds them all to the store set with their label(s) if any.

Definition at line 37 of file hs_metrics.c.

Referenced by hs_metrics_service_init().

◆ port_to_str()

static const char* port_to_str ( const uint16_t  port)
static

Return a static buffer pointer that contains the port as a string.

Subsequent call to this function invalidates the previous buffer.

Definition at line 25 of file hs_metrics.c.