Skip to content
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

log host and time #496

Merged
merged 2 commits into from
Nov 9, 2023
Merged
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
4 changes: 3 additions & 1 deletion bin/jobsub_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import creds
import get_parser
import condor
from version import print_version, print_support_email
from tracing import as_span
from tracing import as_span, log_host_time


class StoreGroupinEnvironment(argparse.Action):
Expand Down Expand Up @@ -75,6 +75,8 @@ def main() -> None:
arglist, passthru = parser.parse_known_args()
verbose = arglist.verbose

log_host_time(verbose)

if arglist.version:
print_version()

Expand Down
3 changes: 2 additions & 1 deletion bin/jobsub_fetchlog
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ from get_parser import get_jobid_parser
from condor import Job
from utils import cleanup
from version import print_version, print_support_email
from tracing import as_span, add_event
from tracing import as_span, add_event, log_host_time


verbose = 0
Expand Down Expand Up @@ -246,6 +246,7 @@ def main():
args = parser.parse_args()

verbose = args.verbose
log_host_time(verbose)

if args.version:
print_version()
Expand Down
4 changes: 3 additions & 1 deletion bin/jobsub_submit
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PREFIX = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#
sys.path.append(os.path.join(PREFIX, "lib"))
from packages import pkg_find
from tracing import as_span
from tracing import as_span, log_host_time

pkg_find("jinja") # type: ignore
import jinja2 as jinja
Expand Down Expand Up @@ -116,6 +116,8 @@ def main():

verbose = args.verbose

log_host_time(verbose)

# if they were trying to pass LD_LIBRARY_PATH to the job, get it from HIDE_LD_LIBRARY_PATH
if "LD_LIBRARY_PATH" in args.environment and os.environ.get(
"HIDE_LD_LIBRARY_PATH", ""
Expand Down
18 changes: 18 additions & 0 deletions lib/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
"""

from functools import wraps
import datetime
import os
import sys
import socket
import logging
from typing import Dict, Any, Callable, TypeVar, Optional, List

Expand Down Expand Up @@ -168,3 +170,19 @@ def wrapper(*args, **kwargs): # type: ignore
return wrapper # type: ignore

return as_span_inner


#
# log the current time and hostname in a way that also shows up in the
# Jaeger trace...
#


@as_span("log_host_time")
def log_host_time(verbose: int) -> None:
datestr = str(datetime.datetime.now())
fqdn = socket.getfqdn()
msg = f"running on hostname {fqdn} at {datestr}\n"
add_event("log_host_time", {"host": fqdn, "date": datestr})
if verbose != 0:
sys.stderr.write(msg)