Skip to content

Commit

Permalink
Merge pull request #3 from Sylphe88/labels-rework
Browse files Browse the repository at this point in the history
1.1.0 - Labels, OpenMetrics, Errors
  • Loading branch information
Sylphe88 authored Apr 8, 2021
2 parents 00981c3 + 9c57eb8 commit 4a352be
Show file tree
Hide file tree
Showing 82 changed files with 492 additions and 272 deletions.
9 changes: 6 additions & 3 deletions PromVIEW.lvproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@
<Item Name="PromVIEW_GlobalOnCommand.vi" Type="VI" URL="../src/provider/PromVIEW/PromVIEW_GlobalOnCommand.vi"/>
</Item>
<Item Name="tests" Type="Folder">
<Item Name="Test Labels.vi" Type="VI" URL="../tests/Test Labels.vi"/>
<Item Name="Test Metric.vi" Type="VI" URL="../tests/Test Metric.vi"/>
</Item>
<Item Name="utils" Type="Folder">
<Item Name="Float to Go String.vi" Type="VI" URL="../src/utils/Float to Go String.vi"/>
<Item Name="Flattened Call Chain.vi" Type="VI" URL="../src/utils/Flattened Call Chain.vi"/>
<Item Name="Float to Go Format.vi" Type="VI" URL="../src/utils/Float to Go Format.vi"/>
<Item Name="LV timestamp to unix.vi" Type="VI" URL="../src/utils/LV timestamp to unix.vi"/>
</Item>
<Item Name="Collector.lvlib" Type="Library" URL="../src/collector/Collector.lvlib"/>
<Item Name="Metrics.lvlib" Type="Library" URL="../src/metrics/Metrics.lvlib"/>
<Item Name="Prometheus-Export" Type="Web Service">
<Item Name="Export" Type="Web Service">
<Property Name="Bld_buildSpecName" Type="Str"></Property>
<Property Name="Bld_version.build" Type="Int">1</Property>
<Property Name="ws.autoIncrementVersion" Type="Bool">true</Property>
Expand Down Expand Up @@ -75,6 +76,7 @@
</Item>
<Item Name="VIs de démarrage" Type="Startup VIs Container"/>
</Item>
<Item Name="Metrics.lvlib" Type="Library" URL="../src/metrics/Metrics.lvlib"/>
<Item Name="README.md" Type="Document" URL="../README.md"/>
<Item Name="Registry.lvlib" Type="Library" URL="../src/registry/Registry.lvlib"/>
<Item Name="Dependencies" Type="Dependencies">
Expand Down Expand Up @@ -131,6 +133,7 @@
<Item Name="Longest Line Length in Pixels.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Longest Line Length in Pixels.vi"/>
<Item Name="LVBoundsTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVBoundsTypeDef.ctl"/>
<Item Name="LVDataTypes.lvlib" Type="Library" URL="/&lt;vilib&gt;/AppBuilder/Engine/WebServiceDescription/LVDataTypes/LVDataTypes.lvlib"/>
<Item Name="LVMapReplaceAction.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVMapReplaceAction.ctl"/>
<Item Name="LVNumericRepresentation.ctl" Type="VI" URL="/&lt;vilib&gt;/numeric/LVNumericRepresentation.ctl"/>
<Item Name="LVRectTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVRectTypeDef.ctl"/>
<Item Name="MatchInterface.vi" Type="VI" URL="/&lt;vilib&gt;/WebServerConfig/MatchInterface.vi"/>
Expand Down
39 changes: 25 additions & 14 deletions PromVIEW.vipb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VI_Package_Builder_Settings Version="2018" Created_Date="2020-05-28 15:36:55" Modified_Date="2020-06-27 21:28:25" Creator="EricM" Comments="" ID="82aaff86f07f02ad35b6c792f7cce63d">
<VI_Package_Builder_Settings Version="2018" Created_Date="2020-05-28 15:36:55" Modified_Date="2021-04-08 19:59:12" Creator="EricM" Comments="" ID="ff0ffe9e56ea28fa03900a795af65e10">
<Library_General_Settings>
<Package_File_Name>thelvlab_lib_PromVIEW</Package_File_Name>
<Library_Version>1.0.0.11</Library_Version>
<Library_Version>1.1.0.7</Library_Version>
<Auto_Increment_Version>false</Auto_Increment_Version>
<Library_Source_Folder>.</Library_Source_Folder>
<Library_Output_Folder>builds\package</Library_Output_Folder>
Expand Down Expand Up @@ -33,7 +33,15 @@
<Description>PromVIEW is a client library written in LabVIEW to expose metrics to Prometheus (https://www.prometheus.io)

PromVIEW provides the basic functions to instrument your LabVIEW code by creating metrics and collectors, and it can also be used to create an exporter through the &lt;i&gt;Tools &gt; PromVIEW &gt; Create Exposition Web Service...&lt;/i&gt; menu.
An Prometheus exporter is a web service that exposes the metrics so Prometheus can scrape this web service and update its time-series database with the new values.</Description>
An Prometheus exporter is a web service that exposes the metrics so Prometheus can scrape this web service and update its time-series database with the new values.

&lt;b&gt;Changelog:&lt;/b&gt;
1.1.0 : - Fixed how labels are stored in metrics so they now allow multiple values
BREAKING CHANGE: for all metric types, Create.vi now accepts label names as an array
- Edited the internal structure of metrics to handle internal "children" metrics
- Edited examples to reflect changes. Also the basic example is more fitted to track metrics.
- Partially support OpenMetrics format through metrics format and additional children metrics
</Description>
<Copyright/>
<Packager/>
<URL/>
Expand All @@ -57,7 +65,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
</Custom_Probes>
<Custom_Errors>
<Preserve_Hierarchy>true</Preserve_Hierarchy>
<Path/>
<Path>&lt;user.lib&gt;\errors</Path>
</Custom_Errors>
<Help_Files>
<Preserve_Hierarchy>true</Preserve_Hierarchy>
Expand Down Expand Up @@ -203,6 +211,9 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Exclusions>
<Path>resource</Path>
</Exclusions>
<Exclusions>
<Path>examples/promview-examplefinder.bin3</Path>
</Exclusions>
</Source_Files>
<License_Agreement_Filepath/>
<Licensing_and_Activation>
Expand Down Expand Up @@ -344,7 +355,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>Exposition</Path>
<VI_Title/>
</Items_Data>
<GUID>8C7583E1B5CCBC872A90FFC9B54919B3</GUID>
<GUID>A1D0929052E0805C402A4D84F771F5A6</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -407,7 +418,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\metrics\histogram</Path>
<VI_Title/>
</Items_Data>
<GUID>A141C4D129F987FC1AC4C3EC366C3186</GUID>
<GUID>B037A1CC34456600B6F84D3634EFCF73</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -526,7 +537,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\registry\session\Collect.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>EE6DC29065E1F150DC234931362BB9D8</GUID>
<GUID>2534B2569E35213EE72E6F1481DFA334</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -589,7 +600,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>Advanced - Custom Collector API</Path>
<VI_Title/>
</Items_Data>
<GUID>1D32889E290BB0DEFECCF2DE08F057DD</GUID>
<GUID>B3FE41780F0BFDDCC1EE8F067CA23EC1</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>1</Parent_Palette_Index>
Expand Down Expand Up @@ -666,7 +677,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\metrics\gauge\Set.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>DE8583D6E27B5E6C288C6E02A0720F40</GUID>
<GUID>DA9A5346663A2509D48D61C2C601A4BA</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>1</Parent_Palette_Index>
Expand Down Expand Up @@ -715,7 +726,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\metrics\counter\Increment.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>134CEDE7C4562326D844C9ECED444366</GUID>
<GUID>0EFBDF2A86C98970A4CEB99B1B536D76</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>1</Parent_Palette_Index>
Expand Down Expand Up @@ -764,7 +775,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\metrics\histogram\Observe.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>A3834EB70B2C1F76900738B2B50BD47E</GUID>
<GUID>1EE137BC06A7FB4D9D3843FE007CB552</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>2</Parent_Palette_Index>
Expand Down Expand Up @@ -813,7 +824,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\registry\session\Release Session.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>87433C9DD00DEE5647CAA41371072FE5</GUID>
<GUID>A676D50B32C6883F2DFB4DA495043E0C</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>0</Parent_Palette_Index>
Expand Down Expand Up @@ -848,7 +859,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\exposition\server\Get Metrics.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>793D0BB6D0CCD639B03E05C4B71C0142</GUID>
<GUID>1B7286857BA6754EA251545EBFD98CB1</GUID>
</Functions_Palette_Data>
<Functions_Palette_Data>
<Parent_Palette_Index>3</Parent_Palette_Index>
Expand Down Expand Up @@ -911,7 +922,7 @@ An Prometheus exporter is a web service that exposes the metrics so Prometheus c
<Path>src\collector\generic collector\Erase Metrics.vi</Path>
<VI_Title/>
</Items_Data>
<GUID>7E3FD2854E2AA86A8598E1A79AB94849</GUID>
<GUID>EBAF24FF237492136DB46D4A70515906</GUID>
</Functions_Palette_Data>
</Library_Palette_Definition>
</VI_Package_Builder_Settings>
Binary file modified examples/basic metrics/Get Metrics - PromTest1.vi
Binary file not shown.
36 changes: 34 additions & 2 deletions examples/basic metrics/PromVIEW - Basic Metrics.lvproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,55 @@
</Item>
<Item Name="PromVIEW Basic Metrics Example.vi" Type="VI" URL="../PromVIEW Basic Metrics Example.vi"/>
<Item Name="Readme.md" Type="Document" URL="../Readme.md"/>
<Item Name="Registry.lvlib" Type="Library" URL="../../../src/registry/Registry.lvlib"/>
<Item Name="Dependencies" Type="Dependencies">
<Item Name="user.lib" Type="Folder">
<Item Name="Session - Root.lvclass" Type="LVClass" URL="/&lt;userlib&gt;/_Session Fwk/Session - Root.lvclass"/>
</Item>
<Item Name="vi.lib" Type="Folder">
<Item Name="BuildHelpPath.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/BuildHelpPath.vi"/>
<Item Name="Check Special Tags.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Check Special Tags.vi"/>
<Item Name="Clear Errors.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Clear Errors.vi"/>
<Item Name="Convert property node font to graphics font.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Convert property node font to graphics font.vi"/>
<Item Name="Details Display Dialog.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Details Display Dialog.vi"/>
<Item Name="DialogType.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/DialogType.ctl"/>
<Item Name="DialogTypeEnum.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/DialogTypeEnum.ctl"/>
<Item Name="Error Cluster From Error Code.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Error Cluster From Error Code.vi"/>
<Item Name="Error Code Database.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Error Code Database.vi"/>
<Item Name="ErrWarn.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/ErrWarn.ctl"/>
<Item Name="eventvkey.ctl" Type="VI" URL="/&lt;vilib&gt;/event_ctls.llb/eventvkey.ctl"/>
<Item Name="Find Tag.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Find Tag.vi"/>
<Item Name="Format Message String.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Format Message String.vi"/>
<Item Name="General Error Handler Core CORE.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/General Error Handler Core CORE.vi"/>
<Item Name="General Error Handler.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/General Error Handler.vi"/>
<Item Name="Get LV Class Name.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/LVClass/Get LV Class Name.vi"/>
<Item Name="Get String Text Bounds.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Get String Text Bounds.vi"/>
<Item Name="Get Text Rect.vi" Type="VI" URL="/&lt;vilib&gt;/picture/picture.llb/Get Text Rect.vi"/>
<Item Name="GetHelpDir.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/GetHelpDir.vi"/>
<Item Name="GetRTHostConnectedProp.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/GetRTHostConnectedProp.vi"/>
<Item Name="Longest Line Length in Pixels.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Longest Line Length in Pixels.vi"/>
<Item Name="LVBoundsTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVBoundsTypeDef.ctl"/>
<Item Name="LVMapReplaceAction.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVMapReplaceAction.ctl"/>
<Item Name="LVRectTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVRectTypeDef.ctl"/>
<Item Name="NI_WebServices.lvlib" Type="Library" URL="/&lt;vilib&gt;/wsapi/NI_WebServices.lvlib"/>
<Item Name="Not Found Dialog.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Not Found Dialog.vi"/>
<Item Name="Search and Replace Pattern.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Search and Replace Pattern.vi"/>
<Item Name="Set Bold Text.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Set Bold Text.vi"/>
<Item Name="Set String Value.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Set String Value.vi"/>
<Item Name="Simple Error Handler.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Simple Error Handler.vi"/>
<Item Name="TagReturnType.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/TagReturnType.ctl"/>
<Item Name="Three Button Dialog CORE.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Three Button Dialog CORE.vi"/>
<Item Name="Three Button Dialog.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Three Button Dialog.vi"/>
<Item Name="Trim Whitespace.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Trim Whitespace.vi"/>
<Item Name="whitespace.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/whitespace.ctl"/>
</Item>
<Item Name="Collector.lvlib" Type="Library" URL="../../../src/collector/Collector.lvlib"/>
<Item Name="Float to Go String.vi" Type="VI" URL="../../../src/utils/Float to Go String.vi"/>
<Item Name="Float to Go Format.vi" Type="VI" URL="../../../src/utils/Float to Go Format.vi"/>
<Item Name="LV timestamp to unix.vi" Type="VI" URL="../../../src/utils/LV timestamp to unix.vi"/>
<Item Name="Metrics.lvlib" Type="Library" URL="../../../src/metrics/Metrics.lvlib"/>
<Item Name="mscorlib" Type="VI" URL="mscorlib">
<Property Name="NI.PreserveRelativePath" Type="Bool">true</Property>
</Item>
<Item Name="Registry.lvlib" Type="Library" URL="../../../src/registry/Registry.lvlib"/>
<Item Name="System" Type="VI" URL="System">
<Property Name="NI.PreserveRelativePath" Type="Bool">true</Property>
</Item>
Expand Down
Binary file modified examples/basic metrics/PromVIEW Basic Metrics Example.vi
Binary file not shown.
Binary file modified examples/custom collector/PromTest2 - Get Metrics.vi
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<Property Name="ws.removeLibraryItems" Type="Bool">true</Property>
<Property Name="ws.removePolyVIs" Type="Bool">true</Property>
<Property Name="ws.serveDefaultDoc" Type="Bool">true</Property>
<Property Name="ws.SSE2" Type="Bool">true</Property>
<Property Name="ws.SSE2" Type="Bool">false</Property>
<Property Name="ws.static_permissions" Type="Str"></Property>
<Property Name="ws.version.build" Type="Int">0</Property>
<Property Name="ws.version.fix" Type="Int">0</Property>
Expand Down Expand Up @@ -78,6 +78,7 @@
<Item Name="GetRTHostConnectedProp.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/GetRTHostConnectedProp.vi"/>
<Item Name="Longest Line Length in Pixels.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Longest Line Length in Pixels.vi"/>
<Item Name="LVBoundsTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVBoundsTypeDef.ctl"/>
<Item Name="LVMapReplaceAction.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVMapReplaceAction.ctl"/>
<Item Name="LVRectTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVRectTypeDef.ctl"/>
<Item Name="NI_FileType.lvlib" Type="Library" URL="/&lt;vilib&gt;/Utility/lvfile.llb/NI_FileType.lvlib"/>
<Item Name="NI_PackedLibraryUtility.lvlib" Type="Library" URL="/&lt;vilib&gt;/Utility/LVLibp/NI_PackedLibraryUtility.lvlib"/>
Expand All @@ -94,7 +95,8 @@
<Item Name="whitespace.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/whitespace.ctl"/>
</Item>
<Item Name="Collector.lvlib" Type="Library" URL="../../../src/collector/Collector.lvlib"/>
<Item Name="Float to Go String.vi" Type="VI" URL="../../../src/utils/Float to Go String.vi"/>
<Item Name="Flattened Call Chain.vi" Type="VI" URL="../../../src/utils/Flattened Call Chain.vi"/>
<Item Name="Float to Go Format.vi" Type="VI" URL="../../../src/utils/Float to Go Format.vi"/>
<Item Name="LV timestamp to unix.vi" Type="VI" URL="../../../src/utils/LV timestamp to unix.vi"/>
<Item Name="Metrics.lvlib" Type="Library" URL="../../../src/metrics/Metrics.lvlib"/>
<Item Name="mscorlib" Type="VI" URL="mscorlib">
Expand Down
Binary file modified examples/custom collector/PromVIEW Custom Collector Example.vi
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/custom collector/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ In PromVIEW, the base class for creating custom collectors is *Default Collector

- You need to add metrics to your collector once they are created. This is done using the *Add Metrics* VI from the PromVIEW Collector palette.

- You need to register your collector to a registry. This allows the registry to parse the collector and the metrics it contains when Prometheus scrape your PromVIEW web service. It is usually a good practice to register your collector when all the metrics in it are created. In the Disk Collector example, it is done at the very end of the *Create* method.
- You need to register your collector to a registry. This allows the registry to parse the collector and the metrics it contains when Prometheus scrapes your PromVIEW web service. It is usually a good practice to register your collector when all the metrics in it are created. In the Disk Collector example, it is done at the very end of the *Create* method.
- You should override the *Collect* method in your collector. This allows you to define how the metrics sample values are updated in your collector.
- Make sure the *Collect* method executes as fast as possible. This method is called every time the PromVIEW exposition web service is called (by Prometheus or your web browser), for all the collectors, and the web service must return a response (with data) as soon as possible. Consider using thread or other asynchronous mechanisms if the *Collect* method takes too long to execute.
- Do not register single metrics inside a collector to a registry , as an error will be thrown when the collector is registered. This is because the metrics of a collector are all registered when the collector is registered (so the metrics would not be registered twice!). Generally speaking, the *Auto-Register* parameter passed at metric creation should be True when using independent/isolated metrics in your application, and False when creating a metric inside a collector.
- Do NOT register single metrics inside a collector to a registry , as an error will be thrown when the collector is registered. This is because the metrics of a collector are all registered when the collector is registered (so the metrics would not be registered twice!). Generally speaking, the *Auto-Register* parameter passed at metric creation should be True when using independent/isolated metrics in your application, and False when creating a metric inside a collector.
Binary file modified examples/custom collector/disk collector/Collect.vi
Binary file not shown.
Binary file modified examples/custom collector/disk collector/Create.vi
Binary file not shown.
Loading

0 comments on commit 4a352be

Please sign in to comment.