Feature Request: Metadata/notes data source
(Sorry if this feature already exists in a way that I'm failing to see.)
I would like to embed some notes / my own metadata to traces. Something like
data_sources {
config {
name: "trace.notes"
trace_note {
key: "pmu_set"
value: "1"
} } }
I would like to be able to inject these from command line as well
perfetto ... --note "screensize" "$(wm size)" --note "run_id" "$RUN_ID"
(command line should be able to override notes embedded in config file)
Would this make sense?
so just to double check, you just want to dump some data end to end in the trace. Which use would you make of this? Just looking at that by querying trace processor?
In theory you could do it today in the way you suggest, something like
data_sources {
config {
name: "trace.notes"
legacy_config: "pmu_set=1"
} }
And then you could query it in the config (info & stats page of the ui, and whatever TP table it queries to obtain that)
however it's a bit of a hack as you'd be abusing and speculate on the absence of thata datasource
Maybe we could have a properly supported way, which would be a dedicate field in DataSources. but we'd have to agree on what's the shape it takes in TraceProcessor. maybe we say we only support key-value pairs where the value is a string, and the data ends up in the metadata table as "notes-name1", "notes-name2" columns?
Could we maybe tie it to the concept of built-in data sources we already have instead of doing anything too custom: I could see this makes sense as a "consumer controlled" field of perfetto/traced: https://source.chromium.org/chromium/chromium/src/+/main:third_party/perfetto/protos/perfetto/config/trace_config.proto;drc=0fde4213e1af1de023b881b886d273eeea4493b4;l=105
Which use would you make of this?
Like you describe, it would have its own table, and as you suggest it could be highlighted in info & stats page.
Maybe we could have a properly supported way, which would be a dedicate field in DataSources.
Sorry for being terse, that's what I was asking for in the title.
"consumer controlled" field of perfetto/traced
Sure, as long as it is key/value pair and easy to query. Though I would require an example.
Sure, as long as it is key/value pair and easy to query. Though I would require an example.
Example:
builtin_data_sources: {
notes: {
key: "foo"
value: "bar"
}
}
perfetto_cmd could add these in from command line as well (though I think it should just append and make decision of final value in TP.
In TP, you could query it as follows:
select *
from metadata
where key = 'note.foo'
I don't see why this needs to be a data source at all. It doesn't belong to that concept. A DS is something that you can configure as part of a tracing session. This isn't. Drop that line completely, I'd just make this a
buffers: {... usual stuff}
duration_ms: ...
notes: { key: "key1", value: "bar"}
notes: { key: "key2", value: "bar"}
essentially take trace_config.proto and append a
message Note: {
string key = 1;
string value = 2;
}
repeated Note notes = 43
In TP, you could query it as follows: select * from metadata where key = 'note.foo'
+1
If we go there we could also (as a separate PR) allow the notes to be appended via perfetto cmdline client
so you could take an existing config (which might or might not have notes) and do something like
perfetto -c /path/to/existing/config -o /path/to/trace --add-note key=value
I don't see why this needs to be a data source at all. It doesn't belong to that concept. A DS is something that you can configure as part of a tracing session. This isn't. Drop that line completely, I'd just make this a
Sure yes.
If we go there we could also (as a separate PR) allow the notes to be appended via perfetto cmdline client
Agreed, no reason for the client to not just add protos.
I'm giving it a try: https://github.com/google/perfetto/pull/4735
Merged.
Shouldn't we add the trace processor side of this as well to parse the notes?