Skip to content

Commit

Permalink
feat: central environment vars file and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nampereira committed Dec 20, 2023
1 parent 858bdc8 commit abc1ab7
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arena/arena_mqtt.py
Expand Up @@ -183,7 +183,7 @@ def __init__(
self.mqttc.socket().setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 2048)

# check if we want to start the command interpreter
enable_interp = os.getenv("ENABLE_INTERPRETER", 'False').lower() in ('true', '1', 't')
enable_interp = os.environ.get("ENABLE_INTERPRETER", 'False').lower() in ('true', '1', 't')
if enable_interp:
self.cmd_interpreter = ArenaCmdInterpreter(self,
show_attrs=('config_data', 'scene', 'users', 'all_objects', 'msg_io'),
Expand Down
124 changes: 124 additions & 0 deletions arena/env_vars.py
@@ -0,0 +1,124 @@
# Environment variables definitions
#

MQTTH = "MQTTH"
"""
.. envvar:: MQTTH
The :envvar:`MQTTH` defines the MQTT host used by the library.
This variable overrides arguments passed in the command line.
Default: None
"""

ARENA_USERNAME = "ARENA_USERNAME"
"""
.. envvar:: ARENA_USERNAME
The :envvar:`ARENA_USERNAME` defines username used to authenticate.
This variable overrides arguments passed in the command line.
Default: None
"""

ARENA_PASSWORD = "ARENA_PASSWORD"
"""
.. envvar:: ARENA_PASSWORD
The :envvar:`ARENA_PASSWORD` defines password used to authenticate.
This variable overrides arguments passed in the command line.
Default: None
"""

REALM = "REALM"
"""
.. envvar:: REALM
The :envvar:`REALM` defines the ARENA Realm to listen to.
After connecting, the library listens to a scene topic as follows:
`{REALM}/s/{NAMESPACE}/{SCENE}`.
This variable overrides arguments passed in the command line.
Default: None
"""

SCENE = "SCENE"
"""
.. envvar:: SCENE
The :envvar:`SCENE` defines ARENA Scene to listen to.
After connecting, the library listens to a scene topic as follows:
`{REALM}/s/{NAMESPACE}/{SCENE}`.
This variable overrides arguments passed in the command line.
Default: None
"""

NAMESPACE = "NAMESPACE"
"""
.. envvar:: NAMESPACE
The :envvar:`NAMESPACE` defines ARENA Namespace to listen to.
After connecting, the library listens to a scene topic as follows:
`{REALM}/s/{NAMESPACE}/{SCENE}`.
This variable overrides arguments passed in the command line.
Default: None
"""

DEVICE = "DEVICE"
"""
.. envvar:: DEVICE
The :envvar:`DEVICE` defines the name of a device, to publish and listen to.
After connecting, the library listens to device topic as follows:
`{REALM}/d/{NAMESPACE}/{SCENE}`.
This variable overrides arguments passed in the command line.
Default: None
"""

ENABLE_INTERPRETER = "ENABLE_INTERPRETER"
"""
.. envvar:: ENABLE_INTERPRETER
The :envvar:`ENABLE_INTERPRETER` enables the a simple command line interpreter that
can be used to inspect library/program state. Set this variable with a value of
`true`, `1` or `t` (case insensitive) to enable the interpreter.
Default: False
"""

ARENA_TELEMETRY = "ARENA_TELEMETRY"
"""
.. envvar:: ARENA_TELEMETRY
The :envvar:`ARENA_TELEMETRY` environment variable enables the library's telemetry to generate
traces, metrics, and logs. Set this variable with a value of `otlp`, `mqtt` or `console` (case insensitive)
to enable telemetry using OpenTelemetry (OTEL) and its Protocol (OTLP), send JSON OTEL spans to MQTT, or to the console.
Default: None
"""

OTLP_ENDPOINT = "OTLP_ENDPOINT"
"""
.. envvar:: OTLP_ENDPOINT
The :envvar:`OTLP_ENDPOINT` environment variable is used when OTLP telemetry is enabled (`ARENA_TELEMETRY=otlp`) to define
the telemtry endpoint.
Our implementation uses OpenTelemetry (OTEL) and its Protocol (OTLP) for encoding and transport.
Default: "http://localhost:4317"
"""

OTEL_LOG_LEVEL = "OTEL_LOG_LEVEL"
"""
.. envvar:: OTEL_LOG_LEVEL
The :envvar:`OTEL_LOG_LEVEL` environment variable sets the log level used by the logger
implementation (ArenaTelemetry) using OpenTelemetry (OTEL).
Default: "info". Our logger uses OpenTelemetry (OTEL).
"""
5 changes: 4 additions & 1 deletion arena/scene.py
Expand Up @@ -10,7 +10,7 @@
from .attributes import *
from .events import *
from .objects import *
from .utils import *
from .utils import Utils, ArenaTelemetry

class Scene(ArenaMQTT):
"""
Expand Down Expand Up @@ -39,6 +39,9 @@ def __init__(
cli_args = False,
**kwargs
):

self.tel = ArenaTelemetry()

if cli_args:
self.args = self.parse_cli()
if self.args["host"]:
Expand Down

0 comments on commit abc1ab7

Please sign in to comment.