Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions opamp/opentelemetry-opamp-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Breaking change: callback class `Callbacks` renamed to `OpAMPCallbacks`
([#4355](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4355))

## Version 0.1b0 (2026-03-23)

- Initial implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

Since OpAMP APIs, config options or environment variables are not standardizes the distros are required
to provide code doing so.
OTel Python distros would need to provide their own Callbacks subclass that implements the actual
OTel Python distros would need to provide their own OpAMPCallbacks subclass that implements the actual
change of whatever configuration their backends sends.

Please note that the API is not finalized yet and so the name is called ``_opamp`` with the underscore.
Expand All @@ -48,13 +48,13 @@
import os

from opentelemetry._opamp.agent import OpAMPAgent
from opentelemetry._opamp.callbacks import Callbacks
from opentelemetry._opamp.callbacks import OpAMPCallbacks
from opentelemetry._opamp.client import OpAMPClient
from opentelemetry.sdk._configuration import _OTelSDKConfigurator
from opentelemetry.sdk.resources import OTELResourceDetector


class MyCallbacks(Callbacks):
class MyCallbacks(OpAMPCallbacks):
def on_message(self, agent, client, message):
if message.remote_config is None:
return
Expand Down Expand Up @@ -93,7 +93,7 @@ def _configure(self, **kwargs):
"""

from opentelemetry._opamp.agent import OpAMPAgent
from opentelemetry._opamp.callbacks import Callbacks, MessageData
from opentelemetry._opamp.callbacks import MessageData, OpAMPCallbacks
from opentelemetry._opamp.client import OpAMPClient

__all__ = ["Callbacks", "MessageData", "OpAMPAgent", "OpAMPClient"]
__all__ = ["MessageData", "OpAMPAgent", "OpAMPCallbacks", "OpAMPClient"]
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import threading
from typing import Any, Callable

from opentelemetry._opamp.callbacks import Callbacks, MessageData
from opentelemetry._opamp.callbacks import MessageData, OpAMPCallbacks
from opentelemetry._opamp.client import OpAMPClient
from opentelemetry._opamp.proto import opamp_pb2

Expand Down Expand Up @@ -85,15 +85,15 @@ def __init__(
self,
*,
interval: float = 30,
callbacks: Callbacks,
callbacks: OpAMPCallbacks,
max_retries: int = 10,
heartbeat_max_retries: int = 1,
initial_backoff: float = 1.0,
client: OpAMPClient,
):
"""
:param interval: seconds between heartbeat calls
:param callbacks: Callbacks instance for receiving client events
:param callbacks: OpAMPCallbacks instance for receiving client events
:param max_retries: how many times to retry a failed job for ad-hoc messages
:param heartbeat_max_retries: how many times to retry an heartbeat failed job
:param initial_backoff: base seconds for exponential backoff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def from_server_message(
)


class Callbacks(ABC):
class OpAMPCallbacks(ABC):
"""OpAMP client callbacks with no-op defaults.

All methods have no-op defaults so that subclasses only need to
Expand Down
22 changes: 11 additions & 11 deletions opamp/opentelemetry-opamp-client/tests/opamp/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

from opentelemetry._opamp.agent import OpAMPAgent, _safe_invoke
from opentelemetry._opamp.agent import _Job as Job
from opentelemetry._opamp.callbacks import Callbacks, MessageData
from opentelemetry._opamp.callbacks import MessageData, OpAMPCallbacks
from opentelemetry._opamp.proto import opamp_pb2


class _NoOpCallbacks(Callbacks):
class _NoOpCallbacks(OpAMPCallbacks):
pass


Expand All @@ -48,7 +48,7 @@ def test_agent_start_will_send_connection_and_disconnetion_messages():
mock_message.flags = 0
client_mock.send.return_value = mock_message

cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)
agent = OpAMPAgent(interval=30, client=client_mock, callbacks=cb)
agent.start()
# wait for the queue to be consumed
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_agent_send_warns_without_worker_thread(caplog):
def test_agent_retries_before_max_attempts(caplog):
caplog.set_level(logging.DEBUG, logger="opentelemetry._opamp.agent")

cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)
client_mock = mock.Mock()
connection_message = mock.Mock()
connection_message.HasField.return_value = False
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_agent_retries_before_max_attempts(caplog):
def test_agent_stops_after_max_attempts(caplog):
caplog.set_level(logging.DEBUG, logger="opentelemetry._opamp.agent")

cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)
client_mock = mock.Mock()
connection_message = mock.Mock()
connection_message.HasField.return_value = False
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_agent_stops_after_max_attempts(caplog):


def test_agent_send_enqueues_job():
cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)
client_mock = mock.Mock()
msg = mock.Mock()
msg.HasField.return_value = False
Expand All @@ -194,7 +194,7 @@ def test_agent_send_enqueues_job():


def test_on_error_called_without_on_message_for_error_response():
cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)
client_mock = mock.Mock()

error_response = opamp_pb2.ServerErrorResponse(
Expand Down Expand Up @@ -224,7 +224,7 @@ def test_on_error_called_without_on_message_for_error_response():


def test_on_error_not_called_without_error_response():
cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)
client_mock = mock.Mock()

server_msg = opamp_pb2.ServerToAgent()
Expand Down Expand Up @@ -255,7 +255,7 @@ def test_dispatch_order_with_error():
error_response=error_response,
)

class OrderTrackingCallbacks(Callbacks):
class OrderTrackingCallbacks(OpAMPCallbacks):
def on_connect(self, agent, client):
call_order.append("on_connect")

Expand Down Expand Up @@ -286,7 +286,7 @@ def test_dispatch_order_without_error():

server_msg = opamp_pb2.ServerToAgent()

class OrderTrackingCallbacks(Callbacks):
class OrderTrackingCallbacks(OpAMPCallbacks):
def on_connect(self, agent, client):
call_order.append("on_connect")

Expand All @@ -311,7 +311,7 @@ def on_error(self, agent, client, error_response):


def test_report_full_state_flag_triggers_full_state_send():
cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)
client_mock = mock.Mock()

conn_msg = opamp_pb2.ServerToAgent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

from unittest import mock

from opentelemetry._opamp.callbacks import Callbacks, MessageData
from opentelemetry._opamp.callbacks import MessageData, OpAMPCallbacks
from opentelemetry._opamp.proto import opamp_pb2


def test_subclass_override_subset():
class MyCallbacks(Callbacks):
class MyCallbacks(OpAMPCallbacks):
def __init__(self):
self.connected = False

Expand Down
6 changes: 3 additions & 3 deletions opamp/opentelemetry-opamp-client/tests/opamp/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pytest

from opentelemetry._opamp.agent import OpAMPAgent
from opentelemetry._opamp.callbacks import Callbacks
from opentelemetry._opamp.callbacks import OpAMPCallbacks
from opentelemetry._opamp.client import OpAMPClient
from opentelemetry._opamp.proto import opamp_pb2

Expand All @@ -33,7 +33,7 @@
def test_connection_remote_config_status_heartbeat_disconnection(caplog):
caplog.set_level(logging.DEBUG, logger="opentelemetry._opamp.agent")

class E2ECallbacks(Callbacks):
class E2ECallbacks(OpAMPCallbacks):
def on_message(self, agent, client, message):
logger = logging.getLogger(
"opentelemetry._opamp.agent.opamp_handler"
Expand Down Expand Up @@ -104,7 +104,7 @@ def on_message(self, agent, client, message):
def test_with_server_not_responding(caplog):
caplog.set_level(logging.DEBUG, logger="opentelemetry._opamp.agent")

cb = mock.create_autospec(Callbacks, instance=True)
cb = mock.create_autospec(OpAMPCallbacks, instance=True)

opamp_client = OpAMPClient(
endpoint="https://localhost:4399/v1/opamp",
Expand Down
Loading