This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow setting a custom timeout * Automatically obtain the API URL from the Activegate config
- Loading branch information
1 parent
a83d520
commit e3778a4
Showing
5 changed files
with
82 additions
and
31 deletions.
There are no files selected for viewing
Binary file modified
BIN
+36 KB
(100%)
...ctive-gate-extensions/extension-third-party-port/custom.remote.python.thirdparty_port.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
42 changes: 42 additions & 0 deletions
42
...nthetic/active-gate-extensions/extension-third-party-port/src/port_imports/environment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
import re | ||
from pathlib import Path | ||
import logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
tenant_regex = re.compile(r"\[(.*)\]") | ||
|
||
|
||
def get_api_url() -> str: | ||
endpoint = "" | ||
environment = "" | ||
|
||
base_path = Path(__file__) | ||
|
||
# Only true if running from simulator | ||
if "remotepluginmodule" not in str(base_path): | ||
base_path = "/opt" if os.name != "nt" else "C:/Program Files" | ||
base_path = Path(base_path) / "dynatrace" / "remotepluginmodule" / "agent" | ||
|
||
# Go up one level until the directory name is remotepluginmodule | ||
while True: | ||
base_path = base_path.parent | ||
if base_path.name == "remotepluginmodule": | ||
extensions_conf = base_path / "agent" / "conf" / "extensions.conf" | ||
with open(extensions_conf, "r", errors="replace") as f: | ||
for line in f: | ||
if line.startswith("Server "): | ||
endpoint = line.split(" ")[1].strip() | ||
endpoint = endpoint.replace("/communication", "") | ||
if line.startswith("Tenant "): | ||
environment = line.split(" ")[1].strip() | ||
if endpoint and environment: | ||
api_url = f"{endpoint}/e/{environment}" | ||
log.info(f"Found API URL: '{api_url}' in '{extensions_conf}'") | ||
return api_url | ||
else: | ||
raise Exception(f"Could not find API URL after reading {extensions_conf}") | ||
# End of the line | ||
if base_path.parent == base_path: | ||
raise Exception("Could not find config directory") |