Skip to content

Commit

Permalink
Emit deprecation warnings for collect-metrics, pre-series-upgrade, an…
Browse files Browse the repository at this point in the history
…d post-series-upgrade events.
  • Loading branch information
tonyandrewmeyer committed Sep 17, 2024
1 parent d3b878e commit d9b8bd2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ops/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import enum
import logging
import pathlib
import warnings
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -359,6 +360,14 @@ class PreSeriesUpgradeEvent(HookEvent):
.. jujuremoved:: 4.0
"""

def __init__(self, handle: 'Handle'):
warnings.warn(
'pre-series-upgrade events will not be emitted from Juju 4.0 onwards',
DeprecationWarning,
stacklevel=2,
)
super().__init__(handle)


class PostSeriesUpgradeEvent(HookEvent):
"""Event triggered after a series upgrade.
Expand All @@ -375,6 +384,14 @@ class PostSeriesUpgradeEvent(HookEvent):
.. jujuremoved:: 4.0
"""

def __init__(self, handle: 'Handle'):
warnings.warn(
'post-series-upgrade events will not be emitted from Juju 4.0 onwards',
DeprecationWarning,
stacklevel=2,
)
super().__init__(handle)


class LeaderElectedEvent(HookEvent):
"""Event triggered when a new leader has been elected.
Expand Down Expand Up @@ -412,6 +429,15 @@ class CollectMetricsEvent(HookEvent):
.. jujuremoved:: 4.0
"""

def __init__(self, handle: 'Handle'):
warnings.warn(
'collect-metrics events will not be emitted from Juju 4.0 onwards - '
'consider using the Canonical Observability Stack',
DeprecationWarning,
stacklevel=2,
)
super().__init__(handle)

def add_metrics(
self, metrics: Mapping[str, Union[int, float]], labels: Optional[Mapping[str, str]] = None
):
Expand Down

0 comments on commit d9b8bd2

Please sign in to comment.