11// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22// SPDX-License-Identifier: Apache-2.0
3- //
4- // Licensed under the Apache License, Version 2.0 (the "License");
5- // you may not use this file except in compliance with the License.
6- // You may obtain a copy of the License at
7- //
8- // http://www.apache.org/licenses/LICENSE-2.0
9- //
10- // Unless required by applicable law or agreed to in writing, software
11- // distributed under the License is distributed on an "AS IS" BASIS,
12- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- // See the License for the specific language governing permissions and
14- // limitations under the License.
153
164use dynamo_runtime:: {
175 metrics:: MetricsRegistry ,
@@ -39,13 +27,11 @@ pub struct MyStats {
3927/// Custom metrics for system stats with data bytes tracking
4028#[ derive( Clone , Debug ) ]
4129pub struct MySystemStatsMetrics {
42- pub data_bytes_processed : Arc < IntCounter > ,
30+ pub data_bytes_processed : IntCounter ,
4331}
4432
4533impl MySystemStatsMetrics {
46- pub fn from_endpoint (
47- endpoint : & dynamo_runtime:: component:: Endpoint ,
48- ) -> Result < Self , Box < dyn std:: error:: Error + Send + Sync > > {
34+ pub fn from_endpoint ( endpoint : & dynamo_runtime:: component:: Endpoint ) -> anyhow:: Result < Self > {
4935 let data_bytes_processed = endpoint. create_intcounter (
5036 "my_custom_bytes_processed_total" ,
5137 "Example of a custom metric. Total number of data bytes processed by system handler" ,
@@ -60,7 +46,7 @@ impl MySystemStatsMetrics {
6046
6147#[ derive( Clone ) ]
6248pub struct RequestHandler {
63- metrics : Option < Arc < MySystemStatsMetrics > > ,
49+ metrics : Option < MySystemStatsMetrics > ,
6450}
6551
6652impl RequestHandler {
@@ -70,7 +56,7 @@ impl RequestHandler {
7056
7157 pub fn with_metrics ( metrics : MySystemStatsMetrics ) -> Arc < Self > {
7258 Arc :: new ( Self {
73- metrics : Some ( Arc :: new ( metrics) ) ,
59+ metrics : Some ( metrics) ,
7460 } )
7561 }
7662}
0 commit comments