Comments (4)
If you are emitting track_event using the SDK, is there a reason why you are trying to write the packets manually instead of using the track_event macros (https://perfetto.dev/docs/instrumentation/track-events)? The synthetic track_event page was designed for folks specifically not using the SDK i.e. they have some other trace format they want to convert to Perfetto to visualise it in the UI or query with trace processor. If you're already using the SDK, there is little need to look at that page at all.
from perfetto.
To answer your actual question though, the problem is the line auto trackEvent = packet->set_track_event();
. Protozero
(the proto library that Perfetto uses) expects that the fields of a sub-message are all written contiguously. Given that you call set_track_event twice, that causes undefined behaviour. The trusted_packet_sequence_id also should not be written if you are using the SDK: again that's only designed if you are writing track_event without using the SDK.
Your code should work if you do something like this:
CustomDataSource::Trace([](CustomDataSource::TraceContext ctx) {
auto packet = ctx.NewTracePacket();
packet->set_timestamp(43);
auto* event = packet->set_track_event();
event->add_categories("cat");
event->set_name("ev1");
event->set_type(perfetto::protos::pbzero::TrackEvent::TYPE_INSTANT);
});
But again please just use the track_event macros, it's simpler for you and for us to support as well.
from perfetto.
If you are emitting track_event using the SDK, is there a reason why you are trying to write the packets manually instead of using the track_event macros (https://perfetto.dev/docs/instrumentation/track-events)? The synthetic track_event page was designed for folks specifically not using the SDK i.e. they have some other trace format they want to convert to Perfetto to visualise it in the UI or query with trace processor. If you're already using the SDK, there is little need to look at that page at all.
I'm trying to:
- Record trace information lazily at a certain time.
- Display not perfectly nested data. According to ref "Users are recommended to emit TrackEvent instead"
from perfetto.
It's still not clear to me if you have the following case:
- you have a C++ program (library, binary whatever) you are trying to instrument to collect tracing information while the system runs
- if you have some already existing data source you are trying to visualize in the UI without having a live tracing system
The "Synthetic Track Event" page is only appropriate for case 2). For case 1) you should be using the track_event macros in the SDK as described in https://perfetto.dev/docs/instrumentation/track-events. For case 2), you don't need (and shouldn't) use the SDK at all, you can just use any protobuf writing library (e.g. the official library) and just write protos directly. I explained how to do this a few days ago for Python, the instructions for C++ are very similar: #779.
from perfetto.
Related Issues (20)
- How to quickly locate a ftrace slice on the timeline based on the start timestamp HOT 1
- Empty auxiliary tracks show up as crashed? HOT 2
- How to cut a large perfetto trace to some small file HOT 1
- Why can't I click the box corresponding to a single ftrace event? HOT 1
- Trace counters aren't present in timeline HOT 2
- traces with low timestamped logcat events fail to open properly HOT 1
- feature request: selectively display specific slice HOT 3
- Failed to get information about GPU when recording a perfetto-trace HOT 2
- အားလုံး ပိတ်ပါ (0)
- How to split a big perfetto trace by given slice names? HOT 1
- Perfect
- Perfetto no longer adjusting range to file min/max on Catapult json data HOT 1
- "android.power_rails" Stdlib SQL implementation does not match the docs. HOT 1
- TrackEvents proto binary recorded by CustomDataSource not successfully displayed by Perfetto UI HOT 2
- ninja, gn and pnpm do not forward failures on Windows HOT 2
- Build on Windows should compile additional security flags HOT 5
- Perfetto UI - An unrecoverable problem occurred HOT 6
- Cannot open some perfetto trace files in v45 (But works in v44) HOT 7
- Interned event strings do not work on stable or canary HOT 5
- The perfetto UI displays all numbers. There is no information such as function name. HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perfetto.