Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions source/Canopy-Core-Tests/CanopyComposedAppExample.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Class {
#name : 'CanopyComposedAppExample',
#superclass : 'Object',
#instVars : [
'componentA',
'componentB'
],
#category : 'Canopy-Core-Tests',
#package : 'Canopy-Core-Tests'
}

{ #category : 'as yet unclassified' }
CanopyComposedAppExample >> canopyBranch: aBuilder [
<canopyBranch>
aBuilder at: #componentA addMapping: componentA.
aBuilder at: #componentB addMapping: componentB
]

{ #category : 'accessing' }
CanopyComposedAppExample >> componentA [
^ componentA
]

{ #category : 'accessing' }
CanopyComposedAppExample >> componentB [
^ componentB
]

{ #category : 'initialization' }
CanopyComposedAppExample >> initialize [
super initialize.
componentA := CanopyComposedSubComponent new.
componentB := CanopyComposedSubComponent new
]
20 changes: 20 additions & 0 deletions source/Canopy-Core-Tests/CanopyComposedSubComponent.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Class {
#name : 'CanopyComposedSubComponent',
#superclass : 'Object',
#instVars : [
'value'
],
#category : 'Canopy-Core-Tests',
#package : 'Canopy-Core-Tests'
}

{ #category : 'accessing' }
CanopyComposedSubComponent >> value: anInteger [
value := anInteger
]

{ #category : 'as yet unclassified' }
CanopyComposedSubComponent >> valueCanopy [
<canopyValue: #value type: #metric arguments: #('A sub-component value' gauge)>
^ value
]
31 changes: 6 additions & 25 deletions source/Canopy-Core/Canopy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ Canopy class >> registerDomainNamed: aSymbol with: aNode [

{ #category : 'domains' }
Canopy class >> registerImageMetrics [
"Explicit opt-in, independently selectable from registerVirtualMachineMetrics."
^ self registerDomainNamed: #image with: (self systemMetrics / #image)
SmalltalkImage canopyRegister.
Process canopyRegister.
File canopyRegister.
ExternalSemaphoreTable canopyRegister
]

{ #category : 'domains' }
Expand All @@ -55,43 +57,22 @@ Canopy class >> registerSystemMetrics [

{ #category : 'domains' }
Canopy class >> registerVirtualMachineMetrics [
"Explicit opt-in, independently selectable from registerImageMetrics."
^ self registerDomainNamed: #virtualMachine with: (self systemMetrics / #virtualMachine)
^ VirtualMachine canopyRegister
]

{ #category : 'domains' }
Canopy class >> registerZincMetrics [
"Explicit opt-in - subscribes CanopyZincCounter to live Zinc server traffic and registers
the #zinc domain. Not wired to any automatic image-startup hook, same reasoning as
registerSystemMetrics: not everyone wants this without being asked."
CanopyZincCounter install.
^ self registerDomainNamed: #zinc with: (self zincMetrics / #zinc)
^ CanopyZincCounter canopyRegister
]

{ #category : 'initialization' }
Canopy class >> reset [
instance := nil
]

{ #category : 'as yet unclassified' }
Canopy class >> systemMetrics [
^ CanopyMappingBuilder new
at: #image addMapping: Smalltalk;
at: #image addMapping: Process;
at: #image addMapping: File;
at: #image addMapping: ExternalSemaphoreTable;
at: #virtualMachine addMapping: Smalltalk vm;
map

]

{ #category : 'metrics' }
Canopy class >> zincMetrics [
^ CanopyMappingBuilder new
at: #zinc addMapping: CanopyZincCounter instance;
map
]

{ #category : 'domains' }
Canopy >> domainNames [
^ self keys
Expand Down
6 changes: 4 additions & 2 deletions source/Canopy-Metrics-Tests/CanopyMetricsVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ CanopyMetricsVisitorTest >> testExternalObjectMetricsHaveDistinctDescriptions [
same description despite measuring different things: total table size (including free
slots) vs. count of currently registered (non-nil) objects."
| metrics tableSize objects |
metrics := Canopy systemMetrics.
[ ExternalSemaphoreTable canopyRegister.
metrics := Canopy instance.
tableSize := metrics / #image / #externalObjectTableSize.
objects := metrics / #image / #externalObjects.
self deny: tableSize description equals: objects description
self deny: tableSize description equals: objects description ]
ensure: [ Canopy reset ]
]

{ #category : 'as yet unclassified' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ Class {
#package : 'Canopy-Metrics-Tests'
}

{ #category : 'as yet unclassified' }
CanopyReadWriteLeafExampleTest >> testComposedInstanceRegistersAsDomainViaCanopyBranch [
"Antwort auf die Instanz-basierte Haelfte der Registrierungsmechanismus-Frage (siehe
Canopy backlog, Registrierungsmechanismus): eine komponierte Instanz baut ueber ihre
eigene <canopyBranch>-Methode eine komponierte Struktur aus mehreren Sub-Komponenten,
die per canopyMapping + registerDomainNamed:with: als eigene Domain in Canopy landet -
kein neuer Mechanismus noetig, canopyBranch war schon da (bisher nur an Dictionary
demonstriert, siehe Canopy doc). fullKey loest auch ueber zwei Verschachtelungsebenen
korrekt auf (myApp_componentA_value)."
| app output |
[ app := CanopyComposedAppExample new.
app componentA value: 10.
app componentB value: 20.
Canopy registerDomainNamed: #myApp with: app canopyMapping.
self assert: (Canopy / #myApp / #componentA / #value) value equals: 10.
self assert: (Canopy / #myApp / #componentB / #value) value equals: 20.
output := CanopyPrometheusVisitor new format: Canopy instance.
self assert: (output includesSubstring: 'myApp_componentA_value{} 10 ').
self assert: (output includesSubstring: 'myApp_componentB_value{} 20 ') ]
ensure: [ Canopy reset ]
]

{ #category : 'as yet unclassified' }
CanopyReadWriteLeafExampleTest >> testConfiguredLimitAndLiveUsageProduceExportedPercentage [
"Leitbeispiel aus Canopy roadmap, Terminologie Accessor/Metric-Richtungsambiguitaet: ein
Expand Down
6 changes: 6 additions & 0 deletions source/Canopy-Metrics/CanopyZincCounter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Class {
#package : 'Canopy-Metrics'
}

{ #category : 'installing' }
CanopyZincCounter class >> canopyRegister [
self install.
^ Canopy registerDomainNamed: #zinc with: (CanopyMappingBuilder new object: self instance; map: CanopyBranchNode new; build)
]

{ #category : 'installing' }
CanopyZincCounter class >> install [
^ self instance install
Expand Down
5 changes: 5 additions & 0 deletions source/Canopy-Metrics/ExternalSemaphoreTable.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Extension { #name : 'ExternalSemaphoreTable' }

{ #category : '*Canopy-Metrics' }
ExternalSemaphoreTable class >> canopyRegister [
^ (Canopy /+ #image) merge: (CanopyMappingBuilder new object: self; map: CanopyBranchNode new; build)
]

{ #category : '*Canopy-Metrics' }
ExternalSemaphoreTable class >> externalObjectTableSizeCanopy [
<canopyValue: #externalObjectTableSize type: #metric arguments: #('The total size of the external object table, including free slots' gauge)>
Expand Down
5 changes: 5 additions & 0 deletions source/Canopy-Metrics/File.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Extension { #name : 'File' }

{ #category : '*Canopy-Metrics' }
File class >> canopyRegister [
^ (Canopy /+ #image) merge: (CanopyMappingBuilder new object: self; map: CanopyBranchNode new; build)
]

{ #category : '*Canopy-Metrics' }
File class >> fileRegistrySizeCanopy [
<canopyValue: #fileRegistrySize type: #metric arguments: #('The number of files registered' gauge)>
Expand Down
5 changes: 5 additions & 0 deletions source/Canopy-Metrics/Process.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Process class >> activeProcessListCanopy [
^ (self allSubInstances reject: #isTerminated) size
]

{ #category : '*Canopy-Metrics' }
Process class >> canopyRegister [
^ (Canopy /+ #image) merge: (CanopyMappingBuilder new object: self; map: CanopyBranchNode new; build)
]

{ #category : '*Canopy-Metrics' }
Process class >> terminatedProcessListCanopy [
<canopyValue: #processesTerminated type: #metric arguments: #('The number of terminated processes' gauge)>
Expand Down
6 changes: 6 additions & 0 deletions source/Canopy-Metrics/SmalltalkImage.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : 'SmalltalkImage' }

{ #category : '*Canopy-Metrics' }
SmalltalkImage class >> canopyRegister [
^ (Canopy /+ #image) merge: (CanopyMappingBuilder new object: Smalltalk; map: CanopyBranchNode new; build)
]
5 changes: 5 additions & 0 deletions source/Canopy-Metrics/VirtualMachine.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Extension { #name : 'VirtualMachine' }

{ #category : '*Canopy-Metrics' }
VirtualMachine class >> canopyRegister [
^ Canopy registerDomainNamed: #virtualMachine with: (CanopyMappingBuilder new object: Smalltalk vm; map: CanopyBranchNode new; build)
]

{ #category : '*Canopy-Metrics' }
VirtualMachine >> edenSpaceSizeCanopy [
<canopyValue: #edenSpaceSize type: #metric arguments: #('The size of eden (new space) in bytes' gauge)>
Expand Down
Loading