aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/storageserver/tls_statistics_metrics_wrapper.h
blob: daf02b53b7abc6d80102ef0c73d7c2376ce0dd5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/metrics/metricset.h>
#include <vespa/metrics/countmetric.h>
#include <vespa/vespalib/net/tls/statistics.h>

#include <chrono>

namespace storage {

// Simple wrapper around low-level vespalib network statistics which
// converts the monotonically increasing counters to deltas during
// periodic metric snapshotting.
class TlsStatisticsMetricsWrapper : public metrics::MetricSet {
    struct EndpointMetrics : metrics::MetricSet {
        EndpointMetrics(vespalib::stringref type, metrics::MetricSet* owner);
        ~EndpointMetrics() override;

        metrics::LongCountMetric tls_connections_established;
        metrics::LongCountMetric insecure_connections_established;
    };

    EndpointMetrics client;
    EndpointMetrics server;
    metrics::LongCountMetric tls_handshakes_failed;
    metrics::LongCountMetric peer_authorization_failures;
    metrics::LongCountMetric tls_connections_broken;

    metrics::LongCountMetric failed_tls_config_reloads;

    metrics::LongCountMetric rpc_capability_checks_failed;
    metrics::LongCountMetric status_capability_checks_failed;

    vespalib::net::tls::ConnectionStatistics::Snapshot last_client_stats_snapshot;
    vespalib::net::tls::ConnectionStatistics::Snapshot last_server_stats_snapshot;
    vespalib::net::tls::ConfigStatistics::Snapshot     last_config_stats_snapshot;
    vespalib::net::tls::CapabilityStatistics::Snapshot last_capability_stats_snapshot;

public:
    explicit TlsStatisticsMetricsWrapper(metrics::MetricSet* owner);
    ~TlsStatisticsMetricsWrapper() override;

    void update_metrics_with_snapshot_delta();
};

}