[BugFix] Fix BE crash in tracer when jaeger_endpoint is invalid (backport #63257) (#63283)

Signed-off-by: xiangguangyxg <xiangguangyxg@gmail.com>
Co-authored-by: xiangguangyxg <110401425+xiangguangyxg@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2025-09-19 03:25:16 +00:00 committed by GitHub
parent 5be0b3f880
commit 2aedd17e2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -1087,6 +1087,8 @@ CONF_Int64(rpc_connect_timeout_ms, "30000");
CONF_Int32(max_batch_publish_latency_ms, "100");
// Config for opentelemetry tracing.
// Valid example: jaeger_endpoint = localhost:14268
// Invalid example: jaeger_endpoint = http://localhost:14268
CONF_String(jaeger_endpoint, "");
// Config for query debug trace

View File

@ -40,12 +40,17 @@ void Tracer::release_instance() {
Instance().shutdown();
}
static inline opentelemetry::nostd::shared_ptr<opentelemetry::trace::Tracer> create_no_op_tracer() {
return opentelemetry::trace::Provider::GetTracerProvider()->GetTracer("no-op", OPENTELEMETRY_SDK_VERSION);
}
void Tracer::init(const std::string& service_name) {
if (!config::jaeger_endpoint.empty()) {
opentelemetry::exporter::jaeger::JaegerExporterOptions opts;
vector<string> host_port = strings::Split(config::jaeger_endpoint, ":");
if (host_port.size() != 2) {
LOG(WARNING) << "bad jaeger_endpoint " << config::jaeger_endpoint;
_tracer = create_no_op_tracer();
return;
}
opts.endpoint = host_port[0];
@ -63,7 +68,7 @@ void Tracer::init(const std::string& service_name) {
new opentelemetry::sdk::trace::TracerProvider(std::move(processor), jaeger_resource));
_tracer = provider->GetTracer(service_name, OPENTELEMETRY_SDK_VERSION);
} else {
_tracer = opentelemetry::trace::Provider::GetTracerProvider()->GetTracer("no-op", OPENTELEMETRY_SDK_VERSION);
_tracer = create_no_op_tracer();
}
}