jobec / powershell-prom-client

Prometheus instrumentation library for Powershell applications
BSD 2-Clause "Simplified" License
29 stars 10 forks source link

The property 'labels' exists on multiple object types #8

Open DennisL68 opened 1 year ago

DennisL68 commented 1 year ago

When trouble shooting the collector I can't display the Labels for the Metrics definition and the Labels property for the actual metric object at the same time.

When trying to list all values in action during a trouble shooting session

$ExampleDescriptor = New-MetricDescriptor `
  -Name "ExampleDescriptor" `
  -Type gauge `
  -Help "Some help" `
  -Labels "Instance"

$Metrics = @(
  New-Metric `
    -MetricDesc $ExampleDescriptor `
    -Value 10 `
    -Labels ("example")
)

examination of the object is possible separately using

C:\> $Metrics

Descriptor Value Labels
---------- ----- ------
MetricDesc    10 {example}

C:\> $Metrics | select -ExpandProperty Descriptor

Name              Help       Type Labels
----              ----       ---- ------
ExampleDescriptor Some help gauge {Instance}

but not using a "combined view"

C:\> $Metrics | select Value, Labels -ExpandProperty Descriptor | ft
Select-Object: The property cannot be processed because the property "Labels" already exists.

Value Name              Help       Type Labels
----- ----              ----       ---- ------
   10 ExampleDescriptor Some help gauge {Instance}

I could of course use a calculated property during output

$Metrics | select Value, @{l='LabelValue'; e={$_.Labels}} -ExpandProperty Descriptor | ft

Value LabelValue Name              Help       Type Labels
----- ---------- ----              ----       ---- ------
   10 example    ExampleDescriptor Some help gauge {Instance}

The property Labels is clearly for different use depending on the object related, and so should have different names to better separate them.