function add_labels(tag, ts, record)
  record["job_id"] = os.getenv("FB_JOB_ID") or record["job_id"] or "unknown"
  record["user"]   = os.getenv("FB_USER")   or record["user"]   or "unknown"
  record["model"]  = os.getenv("FB_MODEL")  or record["model"]  or "unknown"
  record["gpu_id"] = os.getenv("FB_GPU_ID") or record["gpu_id"] or "na"
  local p = record["log_path"] or ""
  if string.find(p, "/logs/infer/") then
    record["role"] = "infer"
  elseif string.find(p, "/logs/train/") then
    record["role"] = "train"
  else
    record["role"] = record["role"] or "app"
  end
  return 1, ts, record
end
