3 Replies
      Latest reply on Feb 5, 2020 11:39 PM by kacperh_
      martijnwalraven Level 1 Level 1 (0 points)

        Inspired by WWDC 2019 session 421 and the associated sample project, I've been working on a custom instrument. Things are mostly going great, but I have a question about the use of engineering type tracks and augmentations. It seems following the sample code (defining `<engineering-type-track>` in the instrument with a separate `<augmentation>` definition) adds tracks below all other instruments that may have been added to the document. That means these other instruments will be shown between the main track and additional 'augmented' tracks (see https://ibb.co/vB17Hjd), losing the connection between the instrument and these tracks. This is in contrast to what seem to be truly hierarchical instruments like `os_signpost`, which nest additional tracks under the main instrument track (see https://ibb.co/BG7MnHZ). Is there any way to get this same behavior in a custom instrument?

        • Re: Nesting engineering type tracks under custom instrument
          kacperh_ Apple Staff Apple Staff (10 points)

          Hey there!

           

          Great question.

          In general, you can specify multiple levels in the engineering-type-track elements by specifying multiple hierarchy levels.

          Your tracks can be nested under instrument if you specify <self/> as the first hierarchy level, like so:

           

          <hierarchy>
               <level> <self/> </level>
               <level> <column>value-column</column> </level>
          </hierarchy>
          

           

          Then, in the matching augmentation, you'll need to provide Instrument type ID as the first restriction level:

           

          <slice-type-hierarchy>
               <level>
                    <slice-type>instrument-type</slice-type>
                    <equals>
                         <instrument-type>com.example.your-instrument-id</instrument-type>
                    </equals>
               </level>
               <level>
                    <slice-type>value-column-type</slice-type>
                </level>
          </slice-type-hierarchy>
          

           

          Please keep in mind that you can create hierarchies even if you don't nest something under instrument track — just specify more levels in the hierarchy. Some bundled Instruments like Time Profiler do exactly this — summarize CPU whole machine CPU activity on the Time Profiler track and later provides process/thread separation in form of a separate hierarchy.

           

          I hope this helps. Please let me know if you encounter any problems.

            • Re: Nesting engineering type tracks under custom instrument
              martijnwalraven Level 1 Level 1 (0 points)

              That worked perfectly, thanks a lot!

               

              I have another question though: I've been trying to get `containment-level-from` to work, but it doesn't seem to do much so far. I've added an explicit `level` column and the intervals at level 1 are all fully contained in level 0 intervals. Adding `<containment-level-from>level</containment-level-from>` to my `<plot>` results in no visible intervals at all. If I specify `<qualified-by>level</qualified-by>` instead, at least both levels are visible, although the level 1 intervals are displayed underneath the level 0 ones, not nested inside them (as I would expect `containment-level-from` to do).

               

              Interestingly, when I specify both qualified-by and containment-level-from, I get this build time error:

              > qualified-by and containment-level-from cannot currently be used together due to a workaround that will be resolved shortly in further Instruments 11 betas.

               

              Does this mean the functionality may not yet be working? Or am I missing something?

               

              (Sorry for the weird formatting, I can't seem to figure out how to get inline code formatting or quoting, hence the pseudo-markdown...)