mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 05:32:30 +08:00
22 lines
307 B
Python
22 lines
307 B
Python
import functools
|
|
import socket
|
|
|
|
_hostname = None
|
|
|
|
|
|
def _cached(func):
|
|
@functools.wraps(func)
|
|
def wrapper():
|
|
global _hostname
|
|
if not _hostname:
|
|
_hostname = func()
|
|
|
|
return _hostname
|
|
|
|
return wrapper
|
|
|
|
|
|
@_cached
|
|
def get_hostname():
|
|
return socket.gethostname()
|