Skip to content

Commit 5f6f5de

Browse files
author
Peter Giacomo Lombardo
authored
Metrics: Assure announce pid with payload (#264)
1 parent 2c95ddf commit 5f6f5de

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

instana/agent/host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
import os
88
import json
9+
from datetime import datetime
10+
911
import urllib3
1012
import requests
11-
from datetime import datetime
1213

1314
from ..log import logger
1415
from .base import BaseAgent
@@ -219,7 +220,6 @@ def report_data_payload(self, payload):
219220

220221
# Report metrics
221222
metric_bundle = payload["metrics"]["plugins"][0]["data"]
222-
# logger.debug(to_json(metric_bundle))
223223
response = self.client.post(self.__data_url(),
224224
data=to_json(metric_bundle),
225225
headers={"Content-Type": "application/json"},

instana/collector/helpers/runtime.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ def collect_metrics(self, with_snapshot=False):
3232
plugin_data["name"] = "com.instana.plugin.python"
3333
plugin_data["entityId"] = str(os.getpid())
3434
plugin_data["data"] = DictionaryOfStan()
35-
plugin_data["data"]["pid"] = str(os.getpid())
35+
36+
if hasattr(self.collector.agent, "announce_data"):
37+
try:
38+
plugin_data["data"]["pid"] = self.collector.agent.announce_data.pid
39+
except Exception:
40+
plugin_data["data"]["pid"] = str(os.getpid())
41+
else:
42+
plugin_data["data"]["pid"] = str(os.getpid())
3643

3744
self._collect_runtime_metrics(plugin_data, with_snapshot)
3845

0 commit comments

Comments
 (0)