diff --git a/source/Canopy-Core-Tests/CanopyComposedAppExample.class.st b/source/Canopy-Core-Tests/CanopyComposedAppExample.class.st new file mode 100644 index 0000000..ef52fca --- /dev/null +++ b/source/Canopy-Core-Tests/CanopyComposedAppExample.class.st @@ -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 [ + + 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 +] diff --git a/source/Canopy-Core-Tests/CanopyComposedSubComponent.class.st b/source/Canopy-Core-Tests/CanopyComposedSubComponent.class.st new file mode 100644 index 0000000..67c8f6a --- /dev/null +++ b/source/Canopy-Core-Tests/CanopyComposedSubComponent.class.st @@ -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 [ + + ^ value +] diff --git a/source/Canopy-Core/Canopy.class.st b/source/Canopy-Core/Canopy.class.st index 32a7f5f..73d377c 100644 --- a/source/Canopy-Core/Canopy.class.st +++ b/source/Canopy-Core/Canopy.class.st @@ -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' } @@ -55,8 +57,7 @@ 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' } @@ -64,8 +65,7 @@ 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' } @@ -73,25 +73,6 @@ 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 diff --git a/source/Canopy-Metrics-Tests/CanopyMetricsVisitorTest.class.st b/source/Canopy-Metrics-Tests/CanopyMetricsVisitorTest.class.st index 646bf71..878c35e 100644 --- a/source/Canopy-Metrics-Tests/CanopyMetricsVisitorTest.class.st +++ b/source/Canopy-Metrics-Tests/CanopyMetricsVisitorTest.class.st @@ -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' } diff --git a/source/Canopy-Metrics-Tests/CanopyReadWriteLeafExampleTest.class.st b/source/Canopy-Metrics-Tests/CanopyReadWriteLeafExampleTest.class.st index ff32871..582f972 100644 --- a/source/Canopy-Metrics-Tests/CanopyReadWriteLeafExampleTest.class.st +++ b/source/Canopy-Metrics-Tests/CanopyReadWriteLeafExampleTest.class.st @@ -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 -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 diff --git a/source/Canopy-Metrics/CanopyZincCounter.class.st b/source/Canopy-Metrics/CanopyZincCounter.class.st index 847f064..684f806 100644 --- a/source/Canopy-Metrics/CanopyZincCounter.class.st +++ b/source/Canopy-Metrics/CanopyZincCounter.class.st @@ -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 diff --git a/source/Canopy-Metrics/ExternalSemaphoreTable.extension.st b/source/Canopy-Metrics/ExternalSemaphoreTable.extension.st index 77d5ca1..75076bb 100644 --- a/source/Canopy-Metrics/ExternalSemaphoreTable.extension.st +++ b/source/Canopy-Metrics/ExternalSemaphoreTable.extension.st @@ -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 [ diff --git a/source/Canopy-Metrics/File.extension.st b/source/Canopy-Metrics/File.extension.st index f75a5f6..7b8ab8a 100644 --- a/source/Canopy-Metrics/File.extension.st +++ b/source/Canopy-Metrics/File.extension.st @@ -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 [ diff --git a/source/Canopy-Metrics/Process.extension.st b/source/Canopy-Metrics/Process.extension.st index 8d9792a..73c3445 100644 --- a/source/Canopy-Metrics/Process.extension.st +++ b/source/Canopy-Metrics/Process.extension.st @@ -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 [ diff --git a/source/Canopy-Metrics/SmalltalkImage.extension.st b/source/Canopy-Metrics/SmalltalkImage.extension.st new file mode 100644 index 0000000..651620e --- /dev/null +++ b/source/Canopy-Metrics/SmalltalkImage.extension.st @@ -0,0 +1,6 @@ +Extension { #name : 'SmalltalkImage' } + +{ #category : '*Canopy-Metrics' } +SmalltalkImage class >> canopyRegister [ + ^ (Canopy /+ #image) merge: (CanopyMappingBuilder new object: Smalltalk; map: CanopyBranchNode new; build) +] diff --git a/source/Canopy-Metrics/VirtualMachine.extension.st b/source/Canopy-Metrics/VirtualMachine.extension.st index d09e528..caa406a 100644 --- a/source/Canopy-Metrics/VirtualMachine.extension.st +++ b/source/Canopy-Metrics/VirtualMachine.extension.st @@ -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 [