Skip to content

Commit

Permalink
Merge pull request #146 from wguanicedew/master
Browse files Browse the repository at this point in the history
optimize loki
  • Loading branch information
PalNilsson authored Oct 4, 2024
2 parents 128ebe4 + 2729a51 commit 598ec6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pilot/control/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def get_logging_info(job: JobData, args: object) -> dict:
logger.info("correct logserver formal: logging_type;protocol://hostname:port")
return {}

regex = r"logserver='(?P<logging_type>[^;]+);(?P<protocol>[^:]+)://(?P<hostname>[^:]+):(?P<port>\d+)'"
regex = r"logserver=(?P<logging_type>[^;]+);(?P<protocol>[^:]+)://(?P<hostname>[^:]+):(?P<port>\d+)"
match = search(regex, logserver)
if match:
logging_type = match.group('logging_type')
Expand Down
3 changes: 2 additions & 1 deletion pilot/util/https.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ def request2(url: str = "",
# Send the request securely
try:
logger.debug('sending data to server')
with urllib.request.urlopen(req, context=ssl_context, timeout=30) as response:
timeout = int(config.Pilot.http_maxtime)
with urllib.request.urlopen(req, context=ssl_context, timeout=timeout) as response:
# Handle the response here
logger.debug(f"response.status={response.status}, response.reason={response.reason}")
ret = response.read().decode('utf-8')
Expand Down
8 changes: 6 additions & 2 deletions pilot/util/lokirealtimelogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,22 @@ def format(self, record: logging.LogRecord) -> dict:

formatted = {
"timestamp": record.created,
"process": record.process,
"thread": record.thread,
# "process": record.process,
# "thread": record.thread,
"function": record.funcName,
"module": record.module,
"name": record.name,
"level": record.levelname,
}

"""
# Not send all information, some loki services have limitations on number of labels.
record_keys = set(record.__dict__.keys())
for key in record_keys:
if key not in formatted and key not in ['msg']:
formatted[key] = getattr(record, key)
"""

message = record.msg
try:
Expand Down

0 comments on commit 598ec6f

Please sign in to comment.