blob: 916e3598c1833ab0b3c64fdf634afbd01ea70067 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "echo_connection.h"
#include <lib/sys/cpp/component_context.h>
namespace example {
EchoConnection::EchoConnection(inspect_deprecated::Node node,
std::weak_ptr<EchoConnectionStats> stats)
: node_(std::move(node)), stats_(std::move(stats)) {
bytes_processed_ = node_.CreateUIntMetric("bytes_processed", 0);
requests_ = node_.CreateUIntMetric("requests", 0);
}
void EchoConnection::EchoString(fidl::StringPtr value, EchoStringCallback callback) {
requests_.Add(1);
bytes_processed_.Add(value->size());
auto stats = stats_.lock();
if (stats) {
stats->request_size_histogram.Insert(value->size(), 1);
stats->total_requests.Add(1);
}
callback(std::move(value));
}
} // namespace example