Skip to content

Feature request: use the name of the Python application for the default log name #382

@michaelsafyan

Description

@michaelsafyan

If the log name is missing from the list of attributes it falls back to a hard-coded default string:

  • otel_python_inprocess_log_name_temp

It would be ideal to make the default name more intelligent, perhaps derived from the script name? For example:

  • ./path/to/the/script.py -> script
  • ./path/to/the/scriptdir/main.py -> scriptdir
  • python3 (interactive mode) -> python3

A sketch of the code might look something like:

def _get_entrypoint_script_name():
    main_script_path = sys.argv[0]
    if not main_script_path:
        main_script_path = sys.executable
    simple_script_name = os.path.basename(main_script_path).rstrip('.py')
    return simple_script_name

def _get_default_log_name():
   entrypoint_script_name = _get_entrypoint_script_name()
   if entrypoint_script_name == 'main':
     return os.path.dirname(os.path.abspath(sys.argv[0]))
   return entrypoint_script_name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions