{"record":{"id":"c583e8920e260ed2","repo":"sgl-project/sglang","slug":"initialize-opentelemetry-error-e-please-set-cor","errorCode":null,"errorMessage":"initialize opentelemetry error:{e}. Please set correct otlp endpoint.","messagePattern":"initialize opentelemetry error:(.+?)\\. Please set correct otlp endpoint\\.","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/observability/trace.py","lineNumber":252,"sourceCode":"            }\n        )\n        tracer_provider = TracerProvider(\n            resource=resource, id_generator=TraceCustomIdGenerator()\n        )\n\n        schedule_delay_millis = envs.SGLANG_OTLP_EXPORTER_SCHEDULE_DELAY_MILLIS.get()\n        max_export_batch_size = envs.SGLANG_OTLP_EXPORTER_MAX_EXPORT_BATCH_SIZE.get()\n\n        processor = BatchSpanProcessor(\n            span_exporter=get_otlp_span_exporter(otlp_endpoint),\n            schedule_delay_millis=schedule_delay_millis,\n            max_export_batch_size=max_export_batch_size,\n        )\n        tracer_provider.add_span_processor(processor)\n        trace.set_tracer_provider(tracer_provider)\n    except Exception as e:\n        opentelemetry_initialized = False\n        raise RuntimeError(\n            f\"initialize opentelemetry error:{e}. Please set correct otlp endpoint.\"\n        )\n\n    opentelemetry_initialized = True\n    tracer = trace.get_tracer(\"sglang server\")\n\n    # Auto-start async trace exporter when SGLANG_TRACE_ASYNC=1\n    if envs.SGLANG_TRACE_ASYNC.get():\n        from sglang.srt.observability.trace_async import start_trace_exporter\n\n        start_trace_exporter(otlp_endpoint, server_name, trace_modules=trace_modules)\n\n\ndef get_global_tracing_enabled():\n    return opentelemetry_initialized\n\n\ndef get_otlp_span_exporter(endpoint):","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/observability/trace.py#L234-L270","documentation":"process_tracing_init builds an OTLP exporter/span processor and registers a tracer provider; any exception during that setup (bad OTLP endpoint URL, unreachable collector, invalid sampling/batch options) is wrapped into this RuntimeError with the underlying message.","triggerScenarios":"Setting an malformed or unreachable OTLP endpoint (e.g. --otlp-endpoint http:localhost:4317 missing slashes, or collector not running / TLS mismatch), or invalid batch size arguments.","commonSituations":"Collector not started before sglang; endpoint scheme mismatch (http vs https/grpc); typos in the endpoint flag; firewall/DNS issues in k8s.","solutions":["Fix the OTLP endpoint: use a full valid URL like http://collector-host:4317 and confirm the collector is reachable (curl the health port)","Verify scheme/port match your exporter protocol (grpc 4317 vs http 4318)","If TLS is involved, install/point to the right CA cert; retest after collector startup"],"exampleFix":"# before\n--otlp-endpoint localhost:4317  # malformed, init fails\n# after\n--otlp-endpoint http://collector:4317","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\nu = urlparse(otlp_endpoint)\nassert u.scheme in ('http', 'https', 'grpc') and u.hostname and u.port, 'invalid OTLP endpoint'\nimport socket\nsocket.create_connection((u.hostname, u.port), timeout=2).close()  # reachability precheck","typeGuard":null,"tryCatchPattern":"try:\n    process_tracing_init(...)\nexcept RuntimeError as e:\n    log_fatal(f'tracing init failed: {e}'); start_without_tracing_or_exit()","preventionTips":["Start the collector before sglang; use full http(s)://host:port endpoints","Validate endpoint URL format and port/protocol match (4317 grpc vs 4318 http) in deploy scripts"],"tags":["observability","tracing","opentelemetry","otlp-endpoint"],"backgroundTag":"otlp-endpoint-misconfigured","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}