Ingest Your First Traces
1. Install dependencies
Section titled “1. Install dependencies”pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp2. Send traces
Section titled “2. Send traces”from opentelemetry import tracefrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import BatchSpanProcessorfrom opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True)provider = TracerProvider()provider.add_span_processor(BatchSpanProcessor(exporter))trace.set_tracer_provider(provider)
tracer = trace.get_tracer("my-app")
with tracer.start_as_current_span("handle-request") as span: span.set_attribute("http.method", "GET") span.set_attribute("http.url", "/api/users")
with tracer.start_as_current_span("query-database") as child: child.set_attribute("db.system", "postgresql") # your database query hereFor other languages, see Send Data.
3. View traces in OpenSearch Dashboards
Section titled “3. View traces in OpenSearch Dashboards”- Open OpenSearch Dashboards
- Navigate to Observability → Traces
- Search for your trace by name or filter by time range
- Click a trace to see the span tree, timing, and attributes
Next steps
Section titled “Next steps”- Create Your First Dashboard - build custom visualizations
- Agent Tracing - trace AI agent workflows with GenAI semantic conventions
- Send Data - more instrumentation options