In the last section, you’ve setup OpenTelemetry tracing and connected it to Grafana. You also created a span around the query operation.
In this segment, you’ll add some additional information on the spans to give you insight on the operation the span is representing.
You may see spans that are 4 seconds long, and others that are 10 seconds long. The keyword used for the query is a critical factor since it’s the input of the whole operation. It will affect how many results match this keyword.
The main idea of building observability with OpenTelemetry and Grafana is to have a visual representation of the data. Gauges are presented on a graph. Spans are lines, the longer the duration, the longer the line. With that, the keyword on its own doesn’t give you much information on why the operation was long or short. You’d want to see directly on the span how many results did this keyword represent. Additional Attributes you want to add to the span are:
Search Keyword
Count of ObjectIDs
Count of Objects stored
Spans already have the methods you need to add those values. Go to TheMetStore.swift, right after you create the span add this line:
Build and run the app, search a few times for different keywords to generate different spans.
On Grafana, open the details of one of the new spans, and click on the line to expand its details.
You’ll find “Span attributes” and “Resource attributes”. Expand the first and you’ll see the attributes you added to the span there.
Now you have some insight on what’s going on in the span. You also know that there are multiple smaller operations happening within that span, how long is each of them taking? If you create separate spans for each, how can they be related to each other?
Spans can be connected. Each can have child spans, and each can have its own children. It resembles a tree structure where each span can have only one parent. But considering that each has its own start and end times, that would give a lot more information on what happened, and how long each step took with a quick glimpse. Much faster than reading a log.
In the next section, you’ll create spans for each of the individual operations, connect them to the main span and preview it on Grafana.
See forum comments
This content was released on Oct 24 2025. The official support period is 6-months
from this date.
Adding attributes and additional information to spans can provide valuable insight on the operation covered by the span.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Sending Spans with Start & Finish
Next: Connecting Spans Together
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.