Skip to content

Commit af458bf

Browse files
committed
Fix docs build
1 parent e5fced7 commit af458bf

File tree

4 files changed

+96
-73
lines changed

4 files changed

+96
-73
lines changed

docs-requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ sqlalchemy>=1.0
4444
tornado>=5.1.1
4545
tortoise-orm>=0.17.0
4646

47+
# required by opamp
48+
uuid_utils
49+
protobuf>=5.0,< 7.0
50+
4751
# indirect dependency pins
4852
markupsafe==2.0.1
4953
itsdangerous==2.0.1
54+

docs/opamp/client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ OpenTelemetry Python - OpAMP Client
22
===================================
33

44
.. automodule:: opentelemetry._opamp
5-
:members: agent, client
5+
:members:
66
:undoc-members:
77
:show-inheritance:
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
OpenTelemetry Python - OpAMP client
17+
-----------------------------------
18+
19+
This package provides a bunch of classes that can be used by OpenTelemetry distributions implementors
20+
to implement remote config support via the OpAMP protocol.
21+
22+
The client implements the following capabilities:
23+
24+
* ReportsStatus
25+
* ReportsHeartbeat
26+
* AcceptsRemoteConfig
27+
* ReportsRemoteConfig
28+
29+
These capabilities are enough to get a remote config from an opamp server, parse it, apply it and ack it.
30+
31+
Since OpAMP APIs, config options or environment variables are not standardizes the distros are required
32+
to provide code doing so.
33+
OTel Python distros would need to provide their own message handler callback that implements the actual
34+
change of whatever configuration their backends sends.
35+
36+
Please note that the API is not finalized yet and so the name is called ``_opamp`` with the underscore.
37+
38+
Usage
39+
-----
40+
41+
.. code-block:: python
42+
43+
import os
44+
45+
from opentelemetry._opamp import messages
46+
from opentelemetry._opamp.agent import OpAMPAgent
47+
from opentelemetry._opamp.client import OpAMPClient
48+
from opentelemetry._opamp.proto import opamp_pb2 as opamp_pb2
49+
from opentelemetry.sdk._configuration import _OTelSDKConfigurator
50+
from opentelemetry.sdk.resources import OTELResourceDetector
51+
52+
53+
def opamp_handler(agent: OpAMPAgent, client: OpAMPClient, message: opamp_pb2.ServerToAgent):
54+
for config_filename, config in messages._decode_remote_config(message.remote_config):
55+
print("do something")
56+
57+
58+
class MyOpenTelemetryConfigurator(_OTelSDKConfigurator):
59+
def _configure(self, **kwargs):
60+
super()._configure(**kwargs)
61+
62+
enable_opamp = False
63+
endpoint = os.environ.get("OTEL_PYTHON_OPAMP_ENDPOINT")
64+
if endpoint:
65+
# this is not great but we don't have the calculated resource attributes around
66+
# see https://github.com/open-telemetry/opentelemetry-python/pull/4646 for creating
67+
# an entry point distros can implement
68+
resource = OTELResourceDetector().detect()
69+
agent_identifying_attributes = {
70+
"service.name": resource.attributes.get("service.name"),
71+
}
72+
opamp_client = OpAMPClient(
73+
endpoint=endpoint,
74+
agent_identifying_attributes=agent_identifying_attributes,
75+
)
76+
opamp_agent = OpAMPAgent(
77+
interval=30,
78+
message_handler=opamp_handler,
79+
client=opamp_client,
80+
)
81+
opamp_agent.start()
82+
83+
API
84+
---
85+
"""
86+
87+
from opentelemetry._opamp.agent import OpAMPAgent
88+
from opentelemetry._opamp.client import OpAMPClient
89+
90+
__all__ = ["OpAMPAgent", "OpAMPClient"]

opamp/opentelemetry-opamp-client/src/opentelemetry/_opamp/agent.py

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -27,78 +27,6 @@
2727
logger = logging.getLogger(__name__)
2828

2929

30-
"""
31-
OpenTelemetry Python - OpAMP client
32-
-----------------------------------
33-
34-
This package provides a bunch of classes that can be used by OpenTelemetry distributions implementors
35-
to implement remote config support via the OpAMP protocol.
36-
37-
The client implements the following capabilities:
38-
- ReportsStatus
39-
- ReportsHeartbeat
40-
- AcceptsRemoteConfig
41-
- ReportsRemoteConfig
42-
43-
These capabilities are enough to get a remote config from an opamp server, parse it, apply it and ack it.
44-
45-
Since OpAMP APIs, config options or environment variables are not standardizes the distros are required
46-
to provide code doing so.
47-
OTel Python distros would need to provide their own message handler callback that implements the actual
48-
change of whatever configuration their backends sends.
49-
50-
Please note that the API is not finalized yet and so the name is called ``_opamp`` with the underscore.
51-
52-
Usage
53-
-----
54-
55-
.. code-block:: python
56-
57-
import os
58-
59-
from opentelemetry._opamp import messages
60-
from opentelemetry._opamp.agent import OpAMPAgent
61-
from opentelemetry._opamp.client import OpAMPClient
62-
from opentelemetry._opamp.proto import opamp_pb2 as opamp_pb2
63-
from opentelemetry.sdk._configuration import _OTelSDKConfigurator
64-
from opentelemetry.sdk.resources import OTELResourceDetector
65-
66-
67-
def opamp_handler(agent: OpAMPAgent, client: OpAMPClient, message: opamp_pb2.ServerToAgent):
68-
for config_filename, config in messages._decode_remote_config(message.remote_config):
69-
print("do something")
70-
71-
72-
class MyOpenTelemetryConfigurator(_OTelSDKConfigurator):
73-
def _configure(self, **kwargs):
74-
super()._configure(**kwargs)
75-
76-
enable_opamp = False
77-
endpoint = os.environ.get("OTEL_PYTHON_OPAMP_ENDPOINT")
78-
if endpoint:
79-
# this is not great but we don't have the calculated resource attributes around
80-
# see https://github.com/open-telemetry/opentelemetry-python/pull/4646 for creating
81-
# an entry point distros can implement
82-
resource = OTELResourceDetector().detect()
83-
agent_identifying_attributes = {
84-
"service.name": resource.attributes.get("service.name"),
85-
}
86-
opamp_client = OpAMPClient(
87-
endpoint=endpoint,
88-
agent_identifying_attributes=agent_identifying_attributes,
89-
)
90-
opamp_agent = OpAMPAgent(
91-
interval=30,
92-
message_handler=opamp_handler,
93-
client=opamp_client,
94-
)
95-
opamp_agent.start()
96-
97-
API
98-
---
99-
"""
100-
101-
10230
class _Job:
10331
"""
10432
Represents a single request job, with retry/backoff metadata.

0 commit comments

Comments
 (0)