Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提取-job平台报错无法抛出异常处理报错 #172

Merged
merged 18 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- 【修复】提取-修复打包脚本获取不到LAN_IP直接报错问题 [#50](https://github.com/TencentBlueKing/bk-log/issues/50)
- 【修复】清洗-当时间字段类型为epoch_micros提交报错 [#169](https://github.com/TencentBlueKing/bk-log/pull/169)
- 【修复】清洗-时间格式类型带有000而不是SSS导致解析失败 [#169](https://github.com/TencentBlueKing/bk-log/pull/169)
- 【修复】提取-job平台报错无法抛出异常处理报错 [#172](https://github.com/TencentBlueKing/bk-log/pull/172)
### 优化
- 【优化】管理端-管理端页面功能改版
- 【优化】管理端-支持通过基础计算平台增强清洗入库能力
Expand Down
2 changes: 1 addition & 1 deletion apps/log_extract/handlers/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def get_success_step(query_result):
ip_status = step_result["ip_status"]
if ip_status == constants.JOB_SUCCESS_STATUS:
return step_result
ip_status_list.append(ip_status)
ip_status_list.append(str(ip_status))
raise exceptions.ExplorerException(_("文件预览异常({})".format(",".join(ip_status_list))))

def job_log_to_file_list(self, ip_logs, allowed_dir_file_list):
Expand Down
2 changes: 1 addition & 1 deletion apps/log_trace/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class TraceConfig(AppConfig):
verbose_name = "Trace"

def ready(self):
if settings.OLTP_TRACE:
if settings.OTLP_TRACE:
BluekingInstrumentor().instrument()
11 changes: 9 additions & 2 deletions apps/log_trace/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Collection

import MySQLdb
from django.conf import settings
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation import dbapi
Expand All @@ -30,6 +31,7 @@
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.instrumentation.redis import RedisInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.trace import Span
Expand Down Expand Up @@ -69,9 +71,14 @@ def _uninstrument(self, **kwargs):

def _instrument(self, **kwargs):
"""Instrument the library"""
otlp_exporter = OTLPSpanExporter()
otlp_exporter = OTLPSpanExporter(endpoint=settings.OTLP_GRPC_HOST)
span_processor = BatchSpanProcessor(otlp_exporter)
tracer_provider = TracerProvider()
tracer_provider = TracerProvider(
resource=Resource.create({
"service.name": settings.APP_CODE,
"bk_data_id": settings.OTLP_BK_DATA_ID,
}),
)
tracer_provider.add_span_processor(span_processor)
trace.set_tracer_provider(tracer_provider)
DjangoInstrumentor().instrument(response_hook=django_response_hook)
Expand Down
4 changes: 3 additions & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@
},
}

OLTP_TRACE = os.getenv("BKAPP_OLTP_TRACE", "off") == "on"
OTLP_TRACE = os.getenv("BKAPP_OTLP_TRACE", "off") == "on"
OTLP_GRPC_HOST = os.getenv("BKAPP_OTLP_GRPC_HOST")
OTLP_BK_DATA_ID = int(os.getenv("BKAPP_OTLP_BK_DATA_ID", 0))
# ===============================================================================
# 项目配置
# ===============================================================================
Expand Down