Skip to content
Open
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
58 changes: 54 additions & 4 deletions source/StatsDClient/NullStatsDClient.class.st
Original file line number Diff line number Diff line change
@@ -1,26 +1,76 @@
"
I do no work
I do no work.

""2021/05/20""
The instance variable atomicContent has bee added in order to use Unittests (and to test contents of data send to a NulStatsDClient object) outside of StatsDClientTest scope


"
Class {
#name : #NullStatsDClient,
#superclass : #StatsDClientBase,
#instVars : [
'atomicContent'
],
#category : #StatsDClient
}

{ #category : #'accessing-initialize' }
NullStatsDClient >> atomicContent [
^ atomicContent
]

{ #category : #'as yet unclassified' }
NullStatsDClient >> decrement: aName rate: aRate [
]

{ #category : #Tags }
NullStatsDClient >> format: aName value: aValue rate: aRate type: aType [
"We store the string in the temporary buffer atomicContent"

atomicContent := super
format: aName
value: aValue
rate: aRate
type: aType.
^ atomicContent
]

{ #category : #Tags }
NullStatsDClient >> format: aName value: aValue rate: aRate type: aType withTags: aDictionary [
"We store the string in the temporary buffer atomicContent"

atomicContent := super
format: aName
value: aValue
rate: aRate
type: aType
withTags: aDictionary.
^ atomicContent
]

{ #category : #'as yet unclassified' }
NullStatsDClient >> gauge: aName value: aValue rate: aRate [
]

{ #category : #'as yet unclassified' }
{ #category : #api }
NullStatsDClient >> increment: aName by: aCount rate: aRate [
^ self formatCounter: aName value: aCount rate: aRate
]

{ #category : #'as yet unclassified' }
NullStatsDClient >> increment: aName rate: aRate [
{ #category : #Tags }
NullStatsDClient >> increment: aName by: aCount rate: aRate withTags: aDictionary [
^ self
formatCounter: aName
value: aCount
rate: aRate
withTags: aDictionary
]

{ #category : #'accessing-initialize' }
NullStatsDClient >> initialize [
super initialize.
atomicContent := String new
]

{ #category : #'as yet unclassified' }
Expand Down
175 changes: 175 additions & 0 deletions source/StatsDClient/StatsDClientBase.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,50 @@ StatsDClientBase >> format: aName value: aValue rate: aRate type: aType [
nextPutAll: aType.
aRate < 1 ifTrue: [
"Formating a float is expensive. So maybe have a look for standard values"
"chrisT : | was missing in this case"
str
nextPut: $|;
nextPut: $@;
nextPutAll: aRate asString.
]]
]

{ #category : #Tags }
StatsDClientBase >> format: aName value: aValue rate: aRate type: aType withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

| keys |
^ String
streamContents: [ :str |
str
nextPutAll: prefix;
nextPutAll: aName;
nextPut: $:;
nextPutAll: aValue;
nextPut: $|;
nextPutAll: aType.
aRate < 1
ifTrue: [ "Formating a float is expensive. So maybe have a look for standard values"
str
nextPut: $|;
nextPut: $@;
nextPutAll: aRate asString ].
aDictionary isEmpty
ifFalse: [ str
nextPut: $|;
nextPut: $# ].
1 to: (keys := aDictionary keys) size do: [ :i |
| key |
i = 1
ifFalse: [ str nextPut: $, ].
key := keys at: i.
str nextPutAll: key.
str nextPut: $:.
str nextPutAll: (aDictionary at: key) asString ] ]
]

{ #category : #format }
StatsDClientBase >> formatCounter: aCounterName value: aValue [
^self formatCounter: aCounterName value: aValue rate: 1
Expand All @@ -47,6 +85,33 @@ StatsDClientBase >> formatCounter: aCounterName value: aValue rate: aRate [
^self format: aCounterName value: aValue asString rate: aRate type: 'c'
]

{ #category : #Tags }
StatsDClientBase >> formatCounter: aCounterName value: aValue rate: aRate withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
format: aCounterName
value: aValue asString
rate: aRate
type: 'c'
withTags: aDictionary
]

{ #category : #Tags }
StatsDClientBase >> formatCounter: aCounterName value: aValue withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
formatCounter: aCounterName
value: aValue
rate: 1
withTags: aDictionary
]

{ #category : #format }
StatsDClientBase >> formatGauge: aGaugeName value: aValue [
^self formatGauge: aGaugeName value: aValue rate: 1
Expand All @@ -57,6 +122,33 @@ StatsDClientBase >> formatGauge: aGaugeName value: aValue rate: aRate [
^self format: aGaugeName value: aValue asString rate: aRate type: 'g'
]

{ #category : #Tags }
StatsDClientBase >> formatGauge: aGaugeName value: aValue rate: aRate withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
format: aGaugeName
value: aValue asString
rate: aRate
type: 'g'
withTags: aDictionary
]

{ #category : #Tags }
StatsDClientBase >> formatGauge: aGaugeName value: aValue withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
formatGauge: aGaugeName
value: aValue
rate: 1
withTags: aDictionary
]

{ #category : #format }
StatsDClientBase >> formatSet: aSetName value: aValue [
^self formatSet: aSetName value: aValue rate: 1
Expand All @@ -67,6 +159,33 @@ StatsDClientBase >> formatSet: aSetName value: aValue rate: aRate [
^self format: aSetName value: aValue asString rate: aRate type: 's'
]

{ #category : #Tags }
StatsDClientBase >> formatSet: aSetName value: aValue rate: aRate withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
format: aSetName
value: aValue asString
rate: aRate
type: 's'
withTags: aDictionary
]

{ #category : #Tags }
StatsDClientBase >> formatSet: aSetName value: aValue withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
formatSet: aSetName
value: aValue
rate: 1
withTags: aDictionary
]

{ #category : #format }
StatsDClientBase >> formatTimer: aTimerName value: aValue [
^self formatTimer: aTimerName value: aValue rate: 1
Expand All @@ -77,6 +196,33 @@ StatsDClientBase >> formatTimer: aTimerName value: aValue rate: aRate [
^self format: aTimerName value: aValue asString rate: aRate type: 'ms'
]

{ #category : #Tags }
StatsDClientBase >> formatTimer: aTimerName value: aValue rate: aRate withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
format: aTimerName
value: aValue asString
rate: aRate
type: 'ms'
withTags: aDictionary
]

{ #category : #Tags }
StatsDClientBase >> formatTimer: aTimerName value: aValue withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
formatTimer: aTimerName
value: aValue
rate: 1
withTags: aDictionary
]

{ #category : #'as yet unclassified' }
StatsDClientBase >> forwardEvent: aRate [
^aRate < 1
Expand All @@ -98,11 +244,40 @@ StatsDClientBase >> increment: aName by: aCount rate: aRate [
self sendData: (self formatCounter: aName value: aCount rate: aRate)]
]

{ #category : #Tags }
StatsDClientBase >> increment: aName by: aCount rate: aRate withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

(self forwardEvent: aRate)
ifTrue: [ self
sendData:
(self
formatCounter: aName
value: aCount
rate: aRate
withTags: aDictionary) ]
]

{ #category : #api }
StatsDClientBase >> increment: aName rate: aRate [
^self increment: aName by: 1 rate: aRate.
]

{ #category : #Tags }
StatsDClientBase >> increment: aName rate: aRate withTags: aDictionary [
"Adding tags to the statistics generation
Argument added : aDictionary.
Tags are expressed under a key-value form"

^ self
increment: aName
by: 1
rate: aRate
withTags: aDictionary
]

{ #category : #'as yet unclassified' }
StatsDClientBase >> initialize [
super initialize.
Expand Down
Loading