YANG-DB › Examples › Traces

OpenTelemetry traces, queried where they lie.

The span index Data Prepper writes for OpenSearch trace analytics, unchanged. YANG-DB reads it as spans calling spans, services and traces, and asks across every trace at once what the trace view shows one trace at a time.

2,035spans
82traces
15services
1,952calls
1index, yours
Step 1 · Connect

Run everything on your own engine.

The page talks to YANG-DB's REST API straight from your browser. Without an engine it shows results recorded from a real one, marked recorded, so you can explore first and run later.

Your engine

  • The engine answers at /health
  • The OtelTraces ontology is registered
  • The Span index has data

The engine allows requests from any origin, so this works from yang-db.github.io to localhost. If your browser blocks it (Safari blocks http:// from an https:// page), open a local copy instead: docs/examples/otel/index.html in a clone of the repository.

Start it and load the data

  1. Start YANG-DB 0.12 or later and OpenSearch with Docker. The image is built from source (about 5 minutes the first time). The traces load next to the Dragons tutorial in the same engine:
    cd docker && ./buildDocker.sh Dragons
    docker compose -f docker-compose-os.yml up -d
  2. Load the spans. The loader indexes the sample (2,035 spans, in the repository) into otel_spans as Data Prepper writes them, then registers the ontology and the index provider. From the repository root:
    python3 examples/otel/load_otel.py --reset
    Your own spans already in OpenSearch? Point the index provider at your index instead: nothing is copied or reshaped.
  3. For projection (step 5), the engine's projection index is set up by the Dragons tutorial: python3 docker/e2e/load_tutorial.py once.
  4. Connect on the left. All set: explore the schema.

More: examples/otel, and how event indices are mapped: F21.

Step 2 · No reshaping

One span document is already a piece of the graph.

The flights example copies its sample into entity and relationship indices. Here nothing is copied: the index provider says which field is what, and the engine reads the graph from the spans as they are. Four fields carry it.

One document of otel_spans
spanId: "744bc1422ae9d08d" parentSpanId: "fed3ff2085dbc875" serviceName: "frauddetectionservice" traceId: "48c1123005aff7a16c8c9e9f20e8ee93" name: "orders process" kind: "SPAN_KIND_CONSUMER" durationInNanos: 3215417 startTime: "2024-10-16T03:09:14.607710543Z" traceGroup: "HTTP POST"
Read as
Span the document
id: spanIdname, kind, durationInNanos, …
One vertex per document, keyed by spanId (idField); the _id OpenSearch generated is not used.
ChildOf parentSpanId
Span → Span
A relationship stored as a field. Followed outwards, it reads the field; inwards, it searches it.
Of → Service serviceName
Span → Service
Service is derived: each distinct value is a vertex. There is no service document.
In → Trace traceId
Span → Trace
Trace is derived too; traceGroup rides along as its property.
The schema

The ontology the queries are written against.

Three entity types and three relationship types (OtelTraces.json), mapped onto the span index by OtelTraces-indexProvider.json. Click a type to see its properties and where it comes from; drag the nodes to rearrange them.

Click a node or an arrow · drag to move
Step 3 · The index

Six types, one index, created by someone else.

Every type below reads otel_spans. YANG-DB creates no index and writes no document: initialising the ontology only registers the mapping. Relationships are not stored twice here: each is one field of one span.

Counts are those of the sample. Connect to count your engine's data.
Step 4 · Queries

Ask across every trace in Cypher.

Pick a query, edit it if you like, and run it. The result is drawn as a graph, listed as rows, or shown as the JSON the API returns. Each query's answer was checked against the sample data itself.

O1

Step 5 · Projection

Save a query's results, then slice them.

With the projection cursor, the engine writes every result row into an OpenSearch index. Here: every call made from a checkout span, 1,067 rows. Break them down by service, operation and duration, and page through them, without running the query again. recorded