-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client side aggregation for distribution, histogram and timing
- Loading branch information
Showing
17 changed files
with
987 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package statsd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Masterminds/semver" | ||
) | ||
|
||
var ( | ||
// multiple value per message was introduce in Dogstatsd protocol 1.1 | ||
// implemented since Agent 6.25+ and 7.25+ | ||
multiValuePerMessageCond *semver.Constraints | ||
) | ||
|
||
func init() { | ||
multiValuePerMessageCond, _ = semver.NewConstraint(">= 6.25 < 7.0.0 || >= 7.25") | ||
} | ||
|
||
type agentFeatures struct { | ||
multiValuePerMessage bool | ||
} | ||
|
||
func computeAgentFeature(version string) (*agentFeatures, error) { | ||
af := agentFeatures{} | ||
v, err := semver.NewVersion(version) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not parse version '%s': %s", version, err) | ||
} | ||
|
||
af.multiValuePerMessage = multiValuePerMessageCond.Check(v) | ||
|
||
return &af, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package statsd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAgentFeatureMultipleValue(t *testing.T) { | ||
af, err := computeAgentFeature("6.25.0") | ||
assert.Nil(t, err) | ||
assert.True(t, af.multiValuePerMessage) | ||
|
||
af, err = computeAgentFeature("7.25.0") | ||
assert.Nil(t, err) | ||
assert.True(t, af.multiValuePerMessage) | ||
|
||
af, err = computeAgentFeature("7.24.0") | ||
assert.Nil(t, err) | ||
assert.False(t, af.multiValuePerMessage) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.