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
12 changes: 12 additions & 0 deletions source/Canopy-Core-Tests/CanopyAccessorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ Class {
#package : 'Canopy-Core-Tests'
}

{ #category : 'as yet unclassified' }
CanopyAccessorTest >> testALeafCanReadFromABlockInsteadOfAComponent [
"Runtime values have no pragma to declare them - the block is the object and evaluating it is
the read. The value stays live, which is the whole point: it is worked out per scrape."
| count leaf |
count := 0.
leaf := CanopyAccessor reading: [ count ].
self assert: leaf value equals: 0.
count := 42.
self assert: leaf value equals: 42
]

{ #category : 'as yet unclassified' }
CanopyAccessorTest >> testAcceptCanopySkipsWriteOnlyAccessorsInsteadOfCrashing [
"Found 2026-07-21 while sanity-checking format: over the real Canopy systemMetrics
Expand Down
11 changes: 11 additions & 0 deletions source/Canopy-Core/CanopyAccessor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ Class {
#package : 'Canopy-Core'
}

{ #category : 'instance creation' }
CanopyAccessor class >> reading: aBlock [
"A leaf whose value is worked out on the spot instead of being read off a component: the
block is the object and evaluating it is the read. That is how a value nobody declared with
a pragma gets into the tree - every runtime metric of the servers is built that way."
^ self new
object: aBlock;
readSelector: #value;
yourself
]

{ #category : 'visiting' }
CanopyAccessor >> acceptCanopy: aVisitor [
"Write-only accessors (no readSelector) contribute nothing to export/formatting -
Expand Down
24 changes: 24 additions & 0 deletions source/Canopy-Metrics-Tests/CanopyMetricsVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,30 @@ CanopyMetricsVisitorTest >> testAFamilyIsWrittenAsHelpTypeAndOneLine [
self assert: (lines third substrings last allSatisfy: [ :each | each isDigit ])
]

{ #category : 'as yet unclassified' }
CanopyMetricsVisitorTest >> testABlockBackedMetricExportsLikeAnyOther [
"The shape every runtime metric of the servers will take: no pragma anywhere, the block hands
back a full holder, and the exported line is indistinguishable from a declared one - inherited
label included. All of #apptiveGrid and the 23 #soil values are built like this today."
| count root soil |
count := 41.
root := CanopyBranchNode new.
soil := CanopyBranchNode new.
root at: #soil put: soil.
root labelAt: #stage put: 'production'.
soil
at: #objectsSerialized
put: (CanopyAccessor reading: [ CanopyMetric new
type: #counter;
description: 'the number of serialized objects';
value: count ]).
self assert: ((CanopyPrometheusVisitor new format: root) lines last
beginsWith: 'soil_objectsSerialized{stage="production"} 41 ').
count := 42.
self assert: ((CanopyPrometheusVisitor new format: root) lines last
beginsWith: 'soil_objectsSerialized{stage="production"} 42 ')
]

{ #category : 'as yet unclassified' }
CanopyMetricsVisitorTest >> testAMetricWithoutLabelsIsWrittenWithoutBraces [
"An empty label set used to come out as name{} 1024, because the check was for nil and the
Expand Down
Loading