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
20 changes: 14 additions & 6 deletions source/Canopy-Core-Tests/CanopyDomainTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,33 @@ CanopyDomainTest >> testRegisterDomainNamedRaisesOnCollisionAndDoesNotOverwrite
]

{ #category : 'as yet unclassified' }
CanopyDomainTest >> testRegisterImageMetricsRegistersOnlyImageDomain [
CanopyDomainTest >> testRegisterImageMetricsRegistersTheImageHalfUnderPharo [
"What Pharo says about itself is one domain, #pharo, with the image half below it - the
exported name pharo_image_... is that path and nothing else."
[ Canopy registerImageMetrics.
self assert: Canopy domainNames asArray equals: #( #image ) ]
self assert: Canopy domainNames asArray equals: #( #pharo ).
self assert: (Canopy / #pharo) keys asArray equals: #( #image ) ]
ensure: [ Canopy reset ]
]

{ #category : 'as yet unclassified' }
CanopyDomainTest >> testRegisterSystemMetricsRegistersImageAndVirtualMachineDomains [
"registerSystemMetrics is an explicit opt-in, not an automatic image-startup hook (Norbert,
2026-07-21: not everyone wants this without being asked) - a caller invokes it themselves."
2026-07-21: not everyone wants this without being asked) - a caller invokes it themselves.
Both halves land under the single domain #pharo, which is where the deployed names come
from - see Canopy class>>registerSystemMetrics."
[ Canopy registerSystemMetrics.
self assertCollection: Canopy domainNames asArray hasSameElements: #( #image #virtualMachine ) ]
self assert: Canopy domainNames asArray equals: #( #pharo ).
self assertCollection: (Canopy / #pharo) keys asArray hasSameElements: #( #image #virtualMachine ) ]
ensure: [ Canopy reset ]
]

{ #category : 'as yet unclassified' }
CanopyDomainTest >> testRegisterVirtualMachineMetricsRegistersOnlyVirtualMachineDomain [
CanopyDomainTest >> testRegisterVirtualMachineMetricsRegistersTheVirtualMachineHalfUnderPharo [
"See testRegisterImageMetricsRegistersTheImageHalfUnderPharo - the same for the other half."
[ Canopy registerVirtualMachineMetrics.
self assert: Canopy domainNames asArray equals: #( #virtualMachine ) ]
self assert: Canopy domainNames asArray equals: #( #pharo ).
self assert: (Canopy / #pharo) keys asArray equals: #( #virtualMachine ) ]
ensure: [ Canopy reset ]
]

Expand Down
9 changes: 7 additions & 2 deletions source/Canopy-Core/Canopy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,26 @@ Canopy class >> registerDomainNamed: aSymbol with: aNode [

{ #category : 'domains' }
Canopy class >> registerImageMetrics [
"Lands under the #pharo domain, see registerSystemMetrics."
SmalltalkImage canopyRegister.
Process canopyRegister.
File canopyRegister
]

{ #category : 'domains' }
Canopy class >> registerSystemMetrics [
"Convenience wrapper - registers both system-metrics domains. Not wired to any
automatic image-startup hook - a caller decides when (or whether) to invoke this."
"Everything Pharo says about itself, under the domain #pharo. That is where the exported
names pharo_image_... and pharo_virtualMachine_... come from: a metric is named after where
it hangs, so the tree says it once instead of the endpoint renaming it a second time.
Not wired to any automatic image-startup hook - a caller decides when (or whether) to
invoke this."
self registerImageMetrics.
self registerVirtualMachineMetrics
]

{ #category : 'domains' }
Canopy class >> registerVirtualMachineMetrics [
"Lands under the #pharo domain, see registerSystemMetrics."
VirtualMachine canopyRegister.
^ ExternalSemaphoreTable canopyRegister
]
Expand Down
15 changes: 15 additions & 0 deletions source/Canopy-Metrics-Tests/CanopyMetricsHandlerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ CanopyMetricsHandlerTest >> testHandleRequestWithConfigOnlyExportsConfiguredDoma
self deny: (body includesSubstring: 'beta')
] ensure: [ Canopy reset ]
]

{ #category : 'tests' }
CanopyMetricsHandlerTest >> testRegisteredSystemMetricsAreExportedUnderTheirPharoNames [
"What Pharo says about itself is one domain, #pharo, and a series is named after the path to
its node - so pharo_virtualMachine_memorySize comes out of an unconfigured handler, with
nothing prepended anywhere. Before, the two halves were domains of their own and the name
only became the deployed one because the endpoint had been told to prefix them."
| body |
[ Canopy registerSystemMetrics.
self assertCollection: Canopy domainNames asArray hasSameElements: #( #pharo ).
body := (CanopyMetricsHandler new handleRequest: nil) entity contents.
self assert: (body includesSubstring: 'pharo_virtualMachine_memorySize').
self assert: (body includesSubstring: 'pharo_image_')
] ensure: [ Canopy reset ]
]
14 changes: 8 additions & 6 deletions source/Canopy-Metrics-Tests/CanopyMetricsVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ CanopyMetricsVisitorTest >> testExternalObjectMetricsHaveDistinctDescriptions [
| metrics tableSize objects |
[ ExternalSemaphoreTable canopyRegister.
metrics := Canopy instance.
tableSize := (metrics / #virtualMachine / #externalObjectTableSize) valueHolder.
objects := (metrics / #virtualMachine / #externalObjects) valueHolder.
tableSize := (metrics / #pharo / #virtualMachine / #externalObjectTableSize) valueHolder.
objects := (metrics / #pharo / #virtualMachine / #externalObjects) valueHolder.
self deny: tableSize description equals: objects description ]
ensure: [ Canopy reset ]
]
Expand All @@ -44,11 +44,13 @@ CanopyMetricsVisitorTest >> testExternalObjectMetricsHaveDistinctDescriptions [
CanopyMetricsVisitorTest >> testExternalObjectMetricsLiveUnderTheVirtualMachine [
"Parity with what the servers export today: pharo-metrics declares both under #virtualMachine
(ExternalSemaphoreTable's pragmas say so), and external semaphores are a VM concept. Canopy
registered them under #image, which renamed two series without saying a word."
registered them under #image, which renamed two series without saying a word. Both halves of
what Pharo says about itself sit under the domain #pharo, which is where the exported name
pharo_virtualMachine_externalObjects comes from."
[ ExternalSemaphoreTable canopyRegister.
self assert: (Canopy instance / #virtualMachine / #externalObjects) notNil.
self assert: (Canopy instance / #virtualMachine / #externalObjectTableSize) notNil.
self should: [ Canopy instance / #image ] raise: NotFound ]
self assert: (Canopy instance / #pharo / #virtualMachine / #externalObjects) notNil.
self assert: (Canopy instance / #pharo / #virtualMachine / #externalObjectTableSize) notNil.
self should: [ Canopy instance / #pharo / #image ] raise: NotFound ]
ensure: [ Canopy reset ]
]

Expand Down
2 changes: 1 addition & 1 deletion source/Canopy-Metrics/ExternalSemaphoreTable.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Extension { #name : 'ExternalSemaphoreTable' }
ExternalSemaphoreTable class >> canopyRegister [
"External semaphores are a virtual machine concept, and pharo-metrics exports them under
#virtualMachine. Registering them under #image renamed two series without saying so."
^ (Canopy /+ #virtualMachine) merge: (CanopyMappingBuilder new object: self; map: CanopyBranchNode new; build)
^ (Canopy /+ #pharo /+ #virtualMachine) merge: (CanopyMappingBuilder new object: self; map: CanopyBranchNode new; build)
]

{ #category : '*Canopy-Metrics' }
Expand Down
2 changes: 1 addition & 1 deletion source/Canopy-Metrics/File.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Extension { #name : 'File' }

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

{ #category : '*Canopy-Metrics' }
Expand Down
2 changes: 1 addition & 1 deletion source/Canopy-Metrics/Process.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Process class >> activeProcessListCanopy [

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

{ #category : '*Canopy-Metrics' }
Expand Down
2 changes: 1 addition & 1 deletion source/Canopy-Metrics/SmalltalkImage.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Extension { #name : 'SmalltalkImage' }

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

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

{ #category : '*Canopy-Metrics' }
Expand Down
Loading