Skip to content

Commit

Permalink
bridge: use get_int to obtain the metrics interval option
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed Aug 22, 2024
1 parent 5f11284 commit 66124e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cockpit/channels/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from typing import Dict, List, NamedTuple, Optional, Set, Tuple, Type, Union

from ..channel import AsyncChannel, ChannelError
from ..jsonutil import JsonList, JsonObject
from ..jsonutil import JsonList, JsonObject, get_int
from ..samples import SAMPLERS, SampleDescription, Sampler, Samples

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -56,8 +56,8 @@ def ensure_samplers(cls):
def parse_options(self, options: JsonObject) -> None:
logger.debug('metrics internal open: %s, channel: %s', options, self.channel)

interval = options.get('interval', self.interval)
if not isinstance(interval, int) or interval <= 0 or interval > sys.maxsize:
interval = get_int(options, 'interval', self.interval)
if interval <= 0 or interval > sys.maxsize:
raise ChannelError('protocol-error', message=f'invalid "interval" value: {interval}')

self.interval = interval
Expand Down

0 comments on commit 66124e9

Please sign in to comment.