Skip to content

Commit 410b125

Browse files
authored
[Core] Added logs to post sync metrics (#2004)
### **User description** # Description What - added logs Why - investigate reconciliation pending bug How - added more logs ## Type of change Please leave one option from the following and delete the rest: - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] New Integration (non-breaking change which adds a new integration) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Non-breaking change (fix of existing functionality that will not change current behavior) - [ ] Documentation (added/updated documentation) <h4> All tests should be run against the port production environment(using a testing org). </h4> ### Core testing checklist - [ ] Integration able to create all default resources from scratch - [ ] Resync finishes successfully - [ ] Resync able to create entities - [ ] Resync able to update entities - [ ] Resync able to detect and delete entities - [ ] Scheduled resync able to abort existing resync and start a new one - [ ] Tested with at least 2 integrations from scratch - [ ] Tested with Kafka and Polling event listeners - [ ] Tested deletion of entities that don't pass the selector ___ ### **PR Type** Enhancement ___ ### **Description** - Enhanced logging for sync metrics reporting - Changed debug logs to info level for better visibility - Added detailed logging for metrics generation process ___ ### Diagram Walkthrough ```mermaid flowchart LR A["Sync Metrics Process"] --> B["POST Request Logging"] A --> C["Metrics Generation Logging"] B --> D["Info Level Logs"] C --> D ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>integrations.py</strong><dd><code>Enhanced POST metrics request logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> port_ocean/clients/port/mixins/integrations.py <ul><li>Changed log level from debug to info for POST metrics requests<br> <li> Enhanced visibility of sync metrics API calls</ul> </details> </td> <td><a href="https://github.com/port-labs/ocean/pull/2004/files#diff-6fa1fdcc86d6cf46d57bc513204cd5ffeafede20d1a079786705644c4937a521">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>metric.py</strong><dd><code>Added detailed sync metrics logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> port_ocean/helpers/metric/metric.py <ul><li>Added info logging for sync metrics reporting with kinds<br> <li> Added detailed logging for generated metrics<br> <li> Reorganized imports for better structure</ul> </details> </td> <td><a href="https://github.com/port-labs/ocean/pull/2004/files#diff-417f5cc56a87b7b79de3357469c3793dde206e5398aff18a9e253f1f250b51b2">+14/-10</a>&nbsp; </td> </tr> </table></td></tr><tr><td><strong>Documentation</strong></td><td><table> <tr> <td> <details> <summary><strong>CHANGELOG.md</strong><dd><code>Updated changelog for v0.27.8</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> CHANGELOG.md <ul><li>Added entry for version 0.27.8<br> <li> Documented sync metrics logging improvements</ul> </details> </td> <td><a href="https://github.com/port-labs/ocean/pull/2004/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed">+6/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Configuration changes</strong></td><td><table> <tr> <td> <details> <summary><strong>pyproject.toml</strong><dd><code>Version bump to 0.27.8</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> pyproject.toml - Bumped version from 0.27.7 to 0.27.8 </details> </td> <td><a href="https://github.com/port-labs/ocean/pull/2004/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___
1 parent fc5d3c9 commit 410b125

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
<!-- towncrier release notes start -->
9+
## 0.27.8 (2025-08-18)
10+
11+
### Improvements
12+
13+
- added more logs to sync metrics in order to investigate reconciliation pending bug
14+
915
## 0.27.7 (2025-08-15)
1016

1117
### Improvements

port_ocean/clients/port/mixins/integrations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async def patch_integration(
212212
async def post_integration_sync_metrics(
213213
self, metrics: list[dict[str, Any]]
214214
) -> None:
215-
logger.debug("starting POST metrics request", metrics=metrics)
215+
logger.info("starting POST metrics request", metrics=metrics)
216216
metrics_attributes = await self.get_metrics_attributes()
217217
headers = await self.auth.headers()
218218
url = metrics_attributes["ingestUrl"] + "/syncMetrics"
@@ -224,7 +224,7 @@ async def post_integration_sync_metrics(
224224
},
225225
)
226226
handle_port_status_code(response, should_log=False)
227-
logger.debug("Finished POST metrics request")
227+
logger.info("Finished POST metrics request")
228228

229229
async def put_integration_sync_metrics(self, kind_metrics: dict[str, Any]) -> None:
230230
logger.debug("starting PUT metrics request", kind_metrics=kind_metrics)

port_ocean/helpers/metric/metric.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import os
2-
from typing import Any, TYPE_CHECKING, Optional, Dict, List, Tuple
3-
from fastapi import APIRouter
4-
from port_ocean.exceptions.context import ResourceContextNotFoundError
2+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
3+
54
import prometheus_client
6-
from httpx import AsyncClient
7-
from fastapi.responses import PlainTextResponse
8-
from loguru import logger
9-
from port_ocean.context import metric_resource, resource
10-
from prometheus_client import Gauge
115
import prometheus_client.openmetrics
126
import prometheus_client.openmetrics.exposition
137
import prometheus_client.parser
14-
from prometheus_client import multiprocess
8+
from fastapi import APIRouter
9+
from fastapi.responses import PlainTextResponse
10+
from httpx import AsyncClient
11+
from loguru import logger
12+
from prometheus_client import Gauge, multiprocess
13+
14+
from port_ocean.context import metric_resource, resource
15+
from port_ocean.exceptions.context import ResourceContextNotFoundError
1516

1617
if TYPE_CHECKING:
17-
from port_ocean.config.settings import MetricsSettings, IntegrationSettings
1818
from port_ocean.clients.port.client import PortClient
19+
from port_ocean.config.settings import IntegrationSettings, MetricsSettings
1920

2021

2122
class MetricPhase:
@@ -294,6 +295,7 @@ async def report_sync_metrics(
294295
if kinds is None:
295296
return None
296297

298+
logger.info("Reporting sync metrics for kinds", kinds=kinds)
297299
metrics = []
298300

299301
if blueprints is None:
@@ -303,6 +305,8 @@ async def report_sync_metrics(
303305
metric = self.generate_metrics(metric_name, kind, blueprint)
304306
metrics.extend(metric)
305307

308+
logger.info("Generated metrics", metrics=metrics, kinds=kinds)
309+
306310
try:
307311
await self.port_client.post_integration_sync_metrics(metrics)
308312
except Exception as e:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "port-ocean"
3-
version = "0.27.7"
3+
version = "0.27.8"
44
description = "Port Ocean is a CLI tool for managing your Port projects."
55
readme = "README.md"
66
homepage = "https://app.getport.io"

0 commit comments

Comments
 (0)