custom span for jaeger
All checks were successful
Build And Test / build-and-push (push) Successful in 4m20s
All checks were successful
Build And Test / build-and-push (push) Successful in 4m20s
This commit is contained in:
@ -60,29 +60,46 @@ def ip_mgmt_view(request):
|
||||
return render(request, "butler/ip_mgmt.html", {"records": records, "var_search": query})
|
||||
|
||||
|
||||
import logging
|
||||
from opentelemetry import trace
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
tracer = trace.get_tracer(__name__) # 트레이서 가져오기
|
||||
|
||||
def add_ip_record(request):
|
||||
# print(f"Create_Record_IP_ADDRS")
|
||||
if request.method == "POST":
|
||||
network_nm = request.POST.get("network_nm")
|
||||
ip_addrs = request.POST.get("ip_addrs")
|
||||
svr_nm = request.POST.get("svr_nm")
|
||||
contents = request.POST.get("contents")
|
||||
remark = request.POST.get("remark")
|
||||
# 작성자 (author)는 로그인된 사용자로 설정
|
||||
author = request.user
|
||||
# 데이터 저장
|
||||
IPManagementRecord.objects.create(
|
||||
network_nm=network_nm,
|
||||
ip_addrs=ip_addrs,
|
||||
svr_nm=svr_nm,
|
||||
contents=contents,
|
||||
remark=remark,
|
||||
author=author,
|
||||
)
|
||||
|
||||
# 2025-04-14 Log 등록
|
||||
|
||||
# 2025-04-14 트레이스 span 생성
|
||||
with tracer.start_as_current_span("create_ip_record") as span:
|
||||
# 데이터 저장
|
||||
IPManagementRecord.objects.create(
|
||||
network_nm=network_nm,
|
||||
ip_addrs=ip_addrs,
|
||||
svr_nm=svr_nm,
|
||||
contents=contents,
|
||||
remark=remark,
|
||||
author=author,
|
||||
)
|
||||
|
||||
# 2025-04-14 Jaeger용 Event 추가
|
||||
span.add_event(
|
||||
"Saved IPManagementRecord",
|
||||
attributes={
|
||||
"ip_addrs": ip_addrs,
|
||||
"svr_nm": svr_nm,
|
||||
"desc": "jager logs test",
|
||||
}
|
||||
)
|
||||
|
||||
# 2025-04-14 로그 등록 (콘솔+FluentBit용)
|
||||
logger.info(f"Create_Record_IP_ADDRS: {ip_addrs}")
|
||||
|
||||
|
||||
return redirect("/ip_mgmt")
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user