Added an instance tag ID (#971)

This commit is contained in:
cybermaggedon 2026-06-02 14:49:24 +01:00 committed by GitHub
parent 00bb964e93
commit 60f861bac4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,6 +11,7 @@ Supports dual output to console and Loki for centralized log aggregation.
import contextvars
import logging
import logging.handlers
import uuid
from argparse import ArgumentParser
from queue import Queue
from typing import Any
@ -132,14 +133,12 @@ def setup_logging(args: dict[str, Any]) -> None:
try:
from logging_loki import LokiHandler
# Create Loki handler with optional authentication. The
# processor label is NOT baked in here — it's stamped onto
# each record by _ProcessorIdFilter reading the task-local
# contextvar, and logging_loki's emitter reads record.tags
# to build per-record Loki labels.
instance_id = str(uuid.uuid4())[:8]
loki_handler_kwargs = {
'url': loki_url,
'version': "1",
'tags': {'instance': instance_id},
}
if loki_username and loki_password: