Skip to content

Commit 9961250

Browse files
committed
Add option INCLUDE_PUBSUB_METRICS to manage verbose metrics
1 parent e6690be commit 9961250

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

documentation/docs/getting-started/configuration.mdx

+4-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ Please use this table as a reference.
121121
| OPAL_POLICY_REPO_CLONE_PATH | Where (i.e: base target path) to clone the repo in your docker filesystem (not important unless you mount a docker volume). | |
122122
| OPAL_POLICY_REPO_MAIN_BRANCH | Name of the git branch to track for policy files (default: `master`). | |
123123
| OPAL_BUNDLE_IGNORE | Paths to omit from policy bundle. List of glob style paths, or paths without wildcards but ending with "/\*\*" indicating a parent path (ignoring all under it). | `bundle_ignore: Optional[List[str]]` |
124+
| INCLUDE_PUBSUB_METRICS | Set if OPAL should include pubsub info in OpenTelemetry metrics | |
125+
126+
124127

125128
## OPAL Client Configuration Variables
126129

@@ -178,4 +181,4 @@ Please use this table as a reference.
178181
| OPA_HEALTH_CHECK_TRANSACTION_LOG_PATH | Path to OPA document that stores the OPA write transactions. | |
179182
| OPAL_CLIENT_STAT_ID | Unique client statistics identifier. | |
180183
| OPA_HEALTH_CHECK_POLICY_PATH | | |
181-
| SCOPE_ID | | |
184+
| SCOPE_ID | | |

packages/opal-server/opal_server/config.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,16 @@ class OpalServerConfig(Confi):
384384
description="Policy polling refresh interval",
385385
)
386386

387+
INCLUDE_PUBSUB_METRICS = confi.bool(
388+
"INCLUDE_PUBSUB_METRICS",
389+
False,
390+
description="Set if OPAL should include pubsub info in OpenTelemetry metrics",
391+
)
392+
387393
def on_load(self):
388394
if self.SERVER_PORT is not None and self.SERVER_PORT.isdigit():
389395
# Backward compatibility - if SERVER_PORT is set with a valid value, use it as SERVER_BIND_PORT
390396
self.SERVER_BIND_PORT = int(self.SERVER_PORT)
391397

392398

393-
opal_server_config = OpalServerConfig(prefix="OPAL_")
399+
opal_server_config = OpalServerConfig(prefix="OPAL_")

packages/opal-server/opal_server/pubsub.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def get_active_clients_counter():
4545
if _active_clients_counter is None:
4646
if not opal_common_config.ENABLE_OPENTELEMETRY_METRICS:
4747
return None
48+
if not opal_server_config.INCLUDE_PUBSUB_METRICS:
49+
return None
4850
meter = get_meter()
4951
_active_clients_counter = meter.create_counter(
5052
name="opal_server_active_clients",
@@ -58,6 +60,8 @@ def get_client_data_subscriptions_counter():
5860
if _client_data_subscriptions_counter is None:
5961
if not opal_common_config.ENABLE_OPENTELEMETRY_METRICS:
6062
return None
63+
if not opal_server_config.INCLUDE_PUBSUB_METRICS:
64+
return None
6165
meter = get_meter()
6266
_client_data_subscriptions_counter = meter.create_up_down_counter(
6367
name="opal_client_data_subscriptions",
@@ -279,4 +283,4 @@ async def _verify_permitted_topics(
279283
if unauthorized_topics:
280284
raise Unauthorized(
281285
description=f"Invalid 'topics' to subscribe {unauthorized_topics}"
282-
)
286+
)

0 commit comments

Comments
 (0)