Skip to content

Fix OPAL Client Metrics Failure #761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: release/0.7.x
Choose a base branch
from
Open
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
22 changes: 7 additions & 15 deletions docker/docker-compose-with-prometheus-and-otel.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
services:
broadcast_channel:
image: postgres:alpine
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- postgres_data:/var/lib/postgresql/data

otel-collector:
image: otel/opentelemetry-collector-contrib:0.114.0
Expand All @@ -15,7 +7,7 @@ services:
command: ["--config", "/etc/otelcol/config.yaml"]
ports:
- "4317:4317"
- "8888:8888"
- "8888:8889"
networks:
- opal-network

Expand Down Expand Up @@ -52,31 +44,31 @@ services:
- opal-network

opal_server:
image: permitio/opal-server:latest
image: permitio/opal-server:0.7.16
environment:
- OPAL_BROADCAST_URI=postgres://postgres:postgres@broadcast_channel:5432/postgres
- UVICORN_NUM_WORKERS=4
- OPAL_POLICY_REPO_URL=https://github.com/permitio/opal-example-policy-repo
- OPAL_POLICY_REPO_POLLING_INTERVAL=30
- OPAL_DATA_CONFIG_SOURCES={"config":{"entries":[{"url":"http://opal_server:7002/policy-data","topics":["policy_data"],"dst_path":"/static"}]}}
- OPAL_LOG_FORMAT_INCLUDE_PID=true
- OPAL_ENABLE_OPENTELEMETRY_TRACING=true
- OPAL_ENABLE_OPENTELEMETRY_METRICS=true
- OPAL_OPENTELEMETRY_OTLP_ENDPOINT="otel-collector:4317"
- OPAL_OPENTELEMETRY_OTLP_ENDPOINT=otel-collector:4317
ports:
- "7002:7002"
depends_on:
- broadcast_channel
- otel-collector
networks:
- opal-network

opal_client:
image: permitio/opal-client:latest
image: permitio/opal-client:0.7.16
environment:
- OPAL_SERVER_URL=http://opal_server:7002
- OPAL_LOG_FORMAT_INCLUDE_PID=true
- OPAL_INLINE_OPA_LOG_FORMAT=http
- OPAL_ENABLE_OPENTELEMETRY_TRACING=true
- OPAL_ENABLE_OPENTELEMETRY_METRICS=true
- OPAL_OPENTELEMETRY_OTLP_ENDPOINT=otel-collector:4317
ports:
- "7766:7000"
- "8181:8181"
Expand Down
2 changes: 1 addition & 1 deletion docker/docker_files/otel-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ receivers:

exporters:
prometheus:
endpoint: "0.0.0.0:8888"
endpoint: "0.0.0.0:8889"
debug:
verbosity: detailed

Expand Down
6 changes: 6 additions & 0 deletions docker/docker_files/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ scrape_configs:
static_configs:
- targets: ['opal_client:7000']
metrics_path: '/metrics'

- job_name: 'otel-collector'
static_configs:
- targets: ['otel-collector:8889']
metrics_path: '/metrics'

4 changes: 2 additions & 2 deletions packages/opal-client/opal_client/callbacks/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ async def report_update_results(
status=result.status,
error=error_content,
)
except:
logger.exception("Failed to execute report_update_results")
except Exception as e:
logger.exception(f"Failed to execute report_update_results: {e}")
8 changes: 4 additions & 4 deletions packages/opal-client/opal_client/data/fetcher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, List, Optional, Tuple

from opal_client.config import opal_client_config
from opal_client.policy_store.base_policy_store_client import JsonableValue
Expand Down Expand Up @@ -58,8 +58,8 @@ async def stop(self):
await self._engine.terminate_workers()

async def handle_url(
self, url: str, config: FetcherConfig, data: Optional[JsonableValue]
):
self, url: str, config: dict, data: Optional[JsonableValue]
) -> Optional[JsonableValue]:
"""Helper function wrapping self._engine.handle_url."""
if data is not None:
logger.info("Data provided inline for url: {url}", url=url)
Expand Down Expand Up @@ -107,7 +107,7 @@ async def handle_urls(
results_with_url_and_config = [
(url, config, result)
for (url, config, data), result in zip(urls, results)
if result is not None
if result is not None # FIXME ignores None results
]

# return results
Expand Down
Loading
Loading