{"id":8282,"library":"lightstep","title":"Lightstep (OpenTracing - Deprecated)","description":"The `lightstep` library provides the Python OpenTracing implementation for sending tracing data to Lightstep (now ServiceNow Cloud Observability). As of late 2020, Lightstep strongly recommends migrating to OpenTelemetry for all new and existing Python instrumentation, and this `lightstep-tracer-python` library is no longer the recommended approach. The current version is 4.4.8, but new development has shifted to OpenTelemetry-based solutions.","status":"deprecated","version":"4.4.8","language":"en","source_language":"en","source_url":"https://github.com/lightstep/lightstep-tracer-python","tags":["observability","tracing","opentracing","opentelemetry","deprecated","servicenow"],"install":[{"cmd":"pip install lightstep","lang":"bash","label":"Deprecated Lightstep OpenTracing tracer"},{"cmd":"pip install opentelemetry-distro opentelemetry-exporter-otlp\nopentelemetry-bootstrap -a install","lang":"bash","label":"Recommended OpenTelemetry setup for Lightstep/Cloud Observability"}],"dependencies":[{"reason":"Required by the deprecated lightstep-tracer-python library for OpenTracing API compliance.","package":"opentracing","optional":false},{"reason":"Recommended for OpenTelemetry-based tracing to Lightstep/Cloud Observability. Provides API, SDK, and auto-instrumentation tools.","package":"opentelemetry-distro","optional":false},{"reason":"Required for exporting OpenTelemetry data using OTLP (OpenTelemetry Protocol), which Lightstep/Cloud Observability supports.","package":"opentelemetry-exporter-otlp","optional":false},{"reason":"Specifically required by `opentelemetry-launcher` for compatibility if using that (which is also deprecated, but part of a transition path).","package":"protobuf==3.20.1","optional":true}],"imports":[{"note":"The `lightstep.Tracer` class itself is deprecated. The recommended pattern involves setting it as the OpenTracing global tracer. However, users should migrate to OpenTelemetry.","wrong":"from lightstep import Tracer # direct import often leads to issues with global tracer registration","symbol":"Tracer","correct":"import lightstep\nopentracing.tracer = lightstep.Tracer(...)"},{"note":"This is the current recommended import for OpenTelemetry-based tracing, which Lightstep now advocates.","symbol":"trace","correct":"from opentelemetry import trace"}],"quickstart":{"code":"import os\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.resources import Resource\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor\nfrom opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter\n\n# --- Configuration (using environment variables for security) ---\nLS_ACCESS_TOKEN = os.environ.get('LS_ACCESS_TOKEN', 'YOUR_LIGHTSTEP_ACCESS_TOKEN')\nSERVICE_NAME = os.environ.get('OTEL_SERVICE_NAME', 'my-python-app')\nOTLP_ENDPOINT = os.environ.get('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT', 'ingest.lightstep.com:443')\n\n# Configure resource\nresource = Resource.create({\"service.name\": SERVICE_NAME})\n\n# Configure tracer provider\nprovider = TracerProvider(resource=resource)\n\n# Configure OTLP exporter for Lightstep\notlp_exporter = OTLPSpanExporter(\n    endpoint=OTLP_ENDPOINT,\n    headers={\n        \"lightstep-access-token\": LS_ACCESS_TOKEN\n    },\n    # Optionally, if using a collector without TLS, set insecure=True\n    # insecure=True\n)\n\n# Configure console exporter for local debugging\nconsole_exporter = ConsoleSpanExporter()\n\n# Add span processors\nprovider.add_span_processor(SimpleSpanProcessor(otlp_exporter))\nprovider.add_span_processor(SimpleSpanProcessor(console_exporter))\n\n# Set the global tracer provider\ntrace.set_tracer_provider(provider)\n\n# Acquire a tracer\ntracer = trace.get_tracer(__name__)\n\ndef my_function():\n    with tracer.start_as_current_span(\"my_function_span\") as span:\n        span.set_attribute(\"event\", \"example\")\n        print(\"Executing my_function\")\n        nested_function()\n\ndef nested_function():\n    with tracer.start_as_current_span(\"nested_function_span\"):\n        print(\"Executing nested_function\")\n\nif __name__ == \"__main__\":\n    print(f\"Sending traces for service: {SERVICE_NAME} to {OTLP_ENDPOINT}\")\n    my_function()\n\n    # It's important to shut down the tracer provider to ensure all spans are flushed\n    provider.shutdown()","lang":"python","description":"This quickstart demonstrates how to send traces to Lightstep/Cloud Observability using the recommended OpenTelemetry Python SDK. It configures a `TracerProvider` with an `OTLPSpanExporter` and sets up basic manual instrumentation. Ensure `LS_ACCESS_TOKEN` and `OTEL_SERVICE_NAME` environment variables are set. For non-development environments, using an OpenTelemetry Collector is highly recommended."},"warnings":[{"fix":"Migrate your instrumentation to use the OpenTelemetry Python SDK and its exporters for Lightstep/Cloud Observability. Refer to official Lightstep/OpenTelemetry documentation.","message":"The direct `lightstep-tracer-python` library is officially deprecated in favor of OpenTelemetry. Existing applications using `lightstep.Tracer` directly will not receive new features or bug fixes, and users are strongly advised to migrate.","severity":"breaking","affected_versions":"<= 4.4.8"},{"fix":"Use `pip install opentelemetry-distro opentelemetry-exporter-otlp` and instrument your applications with OpenTelemetry APIs and SDKs. Configure OTLP exporter to send data to Lightstep.","message":"The `lightstep` PyPI package, which provides the `lightstep-tracer-python` OpenTracing implementation, is deprecated. Lightstep (now ServiceNow Cloud Observability) has fully embraced OpenTelemetry.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Ensure only a single, consistent set of OpenTelemetry packages is installed. Check your `pip freeze` output and dependency trees. Remove any old `lightstep` or `opentracing` libraries if you're fully migrating to OpenTelemetry.","message":"Installing multiple versions of OpenTelemetry packages, or older Lightstep tracers alongside OpenTelemetry, can cause traces not to be created or propagated correctly due to conflicts.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `gcc` and `gcc-c++` (or equivalent build-essential packages) on your system before running the installation command.","message":"When using `opentelemetry-bootstrap -a install` on slim Linux distributions (e.g., CentOS), you might encounter issues due to missing `gcc` and `gcc-c++` compilers.","severity":"gotcha","affected_versions":"All OpenTelemetry-related versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"If you intend to use the legacy `lightstep` tracer, ensure `pip install opentracing` is run. Otherwise, migrate to OpenTelemetry which has its own APIs and does not directly use `opentracing`.","cause":"The deprecated `lightstep` library explicitly depends on the `opentracing` package.","error":"ModuleNotFoundError: No module named 'opentracing'"},{"fix":"Verify that `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` is correctly set (e.g., `ingest.lightstep.com:443` or `ingest.eu.lightstep.com:443`). Check network connectivity and firewall rules. Ensure TLS is configured correctly or use `insecure=True` if connecting to a local Collector without TLS (not recommended for production). Set gRPC debug environment variables for more details (e.g., `GRPC_TRACE=all GRPC_VERBOSITY=DEBUG`).","cause":"This typically indicates a gRPC connectivity issue, such as an incorrect endpoint, firewall blockage, or network problem preventing the OpenTelemetry OTLP exporter from reaching the Lightstep ingest endpoint.","error":"grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with: status = StatusCode.UNAVAILABLE details = \"failed to connect to all addresses\" debug_error_string = \"\""},{"fix":"For OpenTracing: Pass `access_token='YOUR_ACCESS_TOKEN'` during `lightstep.Tracer` initialization. For OpenTelemetry: Set the `LS_ACCESS_TOKEN` environment variable or explicitly provide the `lightstep-access-token` header to the OTLP exporter as shown in the quickstart. Ensure the token is valid for your Lightstep/Cloud Observability project.","cause":"The OpenTracing-based Lightstep tracer requires an access token, which was often passed during `lightstep.Tracer` initialization. The OpenTelemetry exporter requires it via `lightstep-access-token` header.","error":"ValueError: Lightstep access token is required."}]}