GoogleCloudPlatform / GoogleCloudPlatform/opentelemetry-operations-python

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

Open
#382 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
83
Forks
46
Avg merge
11h 40m
Merged PRs (30d)
2

Description

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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.