How I Traced a Missing Vercel AI SDK Duration Histogram
I could see how long the model call took in an OpenTelemetry span. My metrics export showed a counter I’d added during the same run. I looked for the inference duration histogram and came up empty. The counter told me the metrics exporter worked.
I filed AI SDK issue #24229 with the reproduction. The histogram shipped in @ai-sdk/otel 1.0.160 through PR #24354. That gave me a way to check what gen_ai.client.inference.duration actually measures.
I ran 25 calls on each version, five each for three generation delays, a stream and an error. A local mock model supplied the delays with timers, and I flushed the in-memory export after every call. The older version recorded zero histogram observations. The new version recorded 25, including all five errors.
The histogram in 1.0.160. It contains 25 observations.
A span attribute does not create a metric
I started with ai 7.0.157 and @ai-sdk/otel 1.0.157....
Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE