Skip to content

Conversation

wfchandler
Copy link
Contributor

Our external API timeseries endpoints currently return data as a BTreeMap<TimeseriesKey, Timeseries>, which results in JSON output with arbitrary numeric keys that have no meaning to API consumers:

{
  "timeseries": {
    "2352746367989923131": { ... },
    "3940108470521992408": { ... }
  }
}

This commit introduces a new TableOutput struct that presents timeseries data as an array instead of a map. The TableOutput type is converted from the internal Table representation at the API boundary, preserving the ordering from the original BTreeMap while providing a cleaner JSON structure:

{
  "timeseries": [ { ... }, { ... } ]
}

Closes #8108

Our external API timeseries endpoints currently return data as a
`BTreeMap<TimeseriesKey, Timeseries>`, which results in JSON output
with arbitrary numeric keys that have no meaning to API consumers:

```json
{
  "timeseries": {
    "2352746367989923131": { ... },
    "3940108470521992408": { ... }
  }
}
```

This commit introduces a new `TableOutput` struct that presents
timeseries data as an array instead of a map. The `TableOutput` type is
converted from the internal `Table` representation at the API boundary,
preserving the ordering from the original `BTreeMap` while providing a
cleaner JSON structure:

```json
{
  "timeseries": [ { ... }, { ... } ]
}
```

Closes #8108
@wfchandler wfchandler marked this pull request as ready for review August 14, 2025 20:28
@david-crespo
Copy link
Contributor

david-crespo commented Aug 14, 2025

Love the idea, TableOutput is kind of a meh name. By “output” do you just mean “view”? Kinda redundant. I feel like it could just be called Table in that case. Might be cool to add another word that indicates it’s about metrics. Do we already have an OxqlResult in the views? Looks like no.

Edit: I see now it’s inside OxqlQueryResult. In that case I think I prefer Table over TableOutput, though neither is a great name for an array of timeseries.

@wfchandler
Copy link
Contributor Author

Love the idea, TableOutput is kind of a meh name.

@david-crespo agreed. Just Table is an existing type which is still used internally by oximeter, what do you think about MetricsTable?

@david-crespo
Copy link
Contributor

MetricsTable is fine, or you could make Table work by defining it in views.rs? There are plenty of examples where the view struct has the same name as the underlying thing.

Built on #8842. I wanted to try my suggestion locally and ended up doing
the whole thing.
@wfchandler
Copy link
Contributor Author

FYI @askfongjojo, this will slightly change how we parse OxQL results. I'll update the fmt-query.py script in the docs and your JSON metrics exporter.

/cc @jmcarp I think you've been working on tooling for our metrics.

@wfchandler
Copy link
Contributor Author

Hmm, actually I think the metrics exporter will handle this without change as it uses .timeseries.*.

@wfchandler wfchandler merged commit 778d6e6 into main Aug 19, 2025
17 checks passed
@wfchandler wfchandler deleted the wc/strip-tablekey branch August 19, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Returning OxQL timeseries data as an object requires needless transformation
3 participants