Code Monkey home page Code Monkey logo

Comments (4)

LalitMaganti avatar LalitMaganti commented on June 15, 2024

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.

LalitMaganti avatar LalitMaganti commented on June 15, 2024

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.

gammapibd avatar gammapibd commented on June 15, 2024

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:

  1. Record trace information lazily at a certain time.
  2. Display not perfectly nested data. According to ref "Users are recommended to emit TrackEvent instead"

from perfetto.

LalitMaganti avatar LalitMaganti commented on June 15, 2024

It's still not clear to me if you have the following case:

  1. you have a C++ program (library, binary whatever) you are trying to instrument to collect tracing information while the system runs
  2. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.