none
Creating a v2 Performance Counter from Manifest RRS feed

  • Question

  • I'm attempting to create some custom performance counters (version 2) via manifest, using Visual Studio 2017.

    1. Starting with this document: Performance Counters Schema, I copied the example manifest (XML) to a file, sample.xml
      (https://docs.microsoft.com/en-us/windows/desktop/perfctrs/performance-counters-schema)
    2. I then invoke the preprocessor tool, CTRPP:
      > ctrpp -h tsamp.h -rc tsamp.rc -prefix tsamp sample.xml
    3. This command fails:
      | sample.xml : error : Failed to acquire Schema Version. This can be due to one of the following reasons:

    I was hoping the sample would be of value. I tried the sample because my attempt at crafting a simple manifest failed for the same reason.

    Here's my simple(r) manifest, modeled after the sample. I added schemaVersion (per the schema SGML displayed on the same doc page) attribute to the counters element, but the result was the same.

    <!-- <?xml version="1.0" encoding="UTF-8"?> -->
    <instrumentationManifest     
        xmlns="https://schemas.microsoft.com/win/2004/08/events" 
        xmlns:win="https://manifests.microsoft.com/win/2004/08/windows/events"
        xmlns:xs="https://www.w3.org/2001/XMLSchema"    
        >
    
        <instrumentation>
    
          <counters xmlns="https://schemas.microsoft.com/win/2005/12/counters"
                    schemaVersion="1.1"
                    >
    
            <provider callback = "custom"
                      applicationIdentity = "MyProvider.exe"
                      providerType = "userMode"
      symbol = "MyProvider"
                      providerGuid = "{26A8277C-2C3B-4D1A-BDAE-8884B743A23E}">
    
              <counterSet guid = "{FADAAA7D-E501-4E58-842C-7D520D0F0A88}"
                          uri = "Microsoft.Windows.System.PerfCounters.MyProvider"
                          name = "MyProviderSet" 
                          description = "my custom performance data." 
          symbol = "MyProviderSet"
                          instances = "multiple">
    
                <counter id = "1"
                         uri = "Microsoft.Windows.System.PerfCounters.MyProvider.MyCounter"
                         name = "MyProviderCounter"
                         description = "simple value"
                         type = "perf_counter_rawcount"
                         detailLevel = "standard"
                         defaultScale = "1"/>
    
              </counterSet>
    
            </provider>
    
          </counters>
    
        </instrumentation>
    
    </instrumentationManifest>



    It fails in the same way.

    > ctrpp -h ttest.h -rc ttest.rc --prefix ttest test.man
    
    test.man : error : Failed to acquire Schema Version. This can be due to one of the following reasons:
    
    1. The <counters> node is either missing or in the wrong namespace.
    2. The <counters> node does not have the schemaVersion attribute.
    3. The schemaVersion attribute value is a malformed floating point string.
    
    If this is a legacy manifest and the error was received from ctrpp.exe,
    run ctrpp.exe with -legacy switch. It is recommended to always use
    ECMangen.exe to create counter manifests to ensure validity.
    Error: CTRPP failed, error code is 0xC007EF9F

    Can anyone tell me what I'm doing incorrectly (or why I can't get the sample in the docs to work)? Are there working examples elsewhere? 



    • Edited by mojomojomojo Tuesday, February 12, 2019 3:36 PM formatting (use code block)
    Monday, February 11, 2019 8:51 PM

All replies

  • So, the big problem in the XML I copied from the example is that all the XML namespace URI's were https. When I change them to http, the tool stops complaining.

    Is there a complete, working example of creating a performance counter?

    Tuesday, February 12, 2019 12:55 PM
  • Besides the http changes, I have to make several changes that reported:

    --- Original.ini 2019-05-24 11:41:12.834409700 -0400
    +++ CounterProvider.ini 2019-05-24 10:59:33.108858200 -0400
    @@ -1,22 +1,24 @@
     <!-- <?xml version="1.0" encoding="UTF-16"?> -->
     <instrumentationManifest     
    -    xmlns="https://schemas.microsoft.com/win/2004/08/events" 
    -    xmlns:win="https://manifests.microsoft.com/win/2004/08/windows/events"
    -    xmlns:xs="https://www.w3.org/2001/XMLSchema"    
    +    xmlns="http://schemas.microsoft.com/win/2004/08/events" 
    +    xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events"
    +    xmlns:xs="http://www.w3.org/2001/XMLSchema"    
         >
     
         <instrumentation>
     
    -        <counters xmlns="https://schemas.microsoft.com/win/2005/12/counters">
    +        <counters xmlns="http://schemas.microsoft.com/win/2005/12/counters" schemaVersion="1.1">
     
                 <provider callback = "custom"
                   applicationIdentity = "myprovider.exe"
                   providerType = "userMode"
    +              symbol = "ThisOne"
                   providerGuid = "{ab8e1320-965a-4cf9-9c07-fe25378c2a23}">
     
                     <counterSet guid = "{dd36a036-c923-4794-b696-70577630b5cf}"
                       uri = "Microsoft.Windows.System.PerfCounters.MyCounterSet1"
                       name = "My LogicalDisk" 
    +                  symbol = "MySymbol1"
                       description = "This is a sample counter set with multiple instances." 
                       instances = "multiple">
     
    @@ -56,6 +58,7 @@
                     <counterSet guid = "{f72fdf55-eaa6-45ba-bf6d-4c7cb0d6ef73}"
                       uri = "Microsoft.Windows.System.PerfCounters.MyCounterSet2"
                       name = "My System Objects"
    +                  symbol = "MySymbol2"
                       description = "My System Objects Help."
                       instances = "single">
     
    @@ -76,6 +79,7 @@
                           uri = "Microsoft.Windows.System.PerfCounters.MyCounterSet2.MyCounter2"
                           name = "Thread Count)"
                           description = "Thread Count Help."
    +                      detailLevel = "standard"
                           type = "perf_counter_rawcount">
                         </counter>
      
    @@ -92,6 +96,7 @@
     
                         <counter id = "4"
                           uri = "Microsoft.Windows.System.PerfCounters.MyCounterSet2.MyCounter4"
    +                      detailLevel = "standard"
                           type = "perf_counter_large_rawcount">
                           <counterAttributes>
                               <counterAttribute name = "noDisplay" />
    @@ -100,6 +105,7 @@
     
                         <counter id = "5"
                           uri = "Microsoft.Windows.System.PerfCounters.MyCounterSet2.MyCounter5"
    +                      detailLevel = "standard"
                           type = "perf_counter_large_rawcount">
                           <counterAttributes>
                               <counterAttribute name = "noDisplay" />


    Friday, May 24, 2019 3:44 PM