Skip to content

Commit

Permalink
aggregation/spanmetrics: set metricset.name
Browse files Browse the repository at this point in the history
  • Loading branch information
axw committed Feb 22, 2021
1 parent e99fed6 commit 998a09b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions model/modeldecoder/rumv3/metricset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestDecodeMapToMetricsetModel(t *testing.T) {
strings.HasPrefix(key, "Transaction") ||
// only set by aggregator
strings.HasPrefix(key, "Event") ||
key == "Name" ||
key == "TimeseriesInstanceID" ||
strings.HasPrefix(key, "Span.DestinationService") ||
// test Samples separately
Expand Down
1 change: 1 addition & 0 deletions model/modeldecoder/v2/metricset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestDecodeMapToMetricsetModel(t *testing.T) {
if strings.HasPrefix(key, "Metadata") ||
// only set by aggregator
strings.HasPrefix(key, "Event") ||
key == "Name" ||
key == "TimeseriesInstanceID" ||
key == "Transaction.Result" ||
key == "Transaction.Root" ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"metricset": {
"period": 1000
},
"metricset.name": "service_destination",
"observer": {
"ephemeral_id": "dynamic",
"hostname": "dynamic",
Expand Down
5 changes: 5 additions & 0 deletions x-pack/apm-server/aggregation/spanmetrics/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
"github.com/elastic/beats/v7/libbeat/logp"
)

const (
metricsetName = "service_destination"
)

// AggregatorConfig holds configuration for creating an Aggregator.
type AggregatorConfig struct {
// Report is a publish.Reporter for reporting metrics documents.
Expand Down Expand Up @@ -260,6 +264,7 @@ type spanMetrics struct {
func makeMetricset(timestamp time.Time, key aggregationKey, metrics spanMetrics, interval int64) model.Metricset {
out := model.Metricset{
Timestamp: timestamp,
Name: metricsetName,
Metadata: model.Metadata{
Service: model.Service{
Name: key.serviceName,
Expand Down
5 changes: 5 additions & 0 deletions x-pack/apm-server/aggregation/spanmetrics/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func TestAggregatorRun(t *testing.T) {
}

assert.ElementsMatch(t, []*model.Metricset{{
Name: "service_destination",
Metadata: model.Metadata{
Service: model.Service{Name: "service-A", Agent: model.Agent{Name: "java"}},
},
Expand All @@ -141,6 +142,7 @@ func TestAggregatorRun(t *testing.T) {
{Name: "metricset.period", Value: 10},
},
}, {
Name: "service_destination",
Metadata: model.Metadata{
Service: model.Service{Name: "service-A", Agent: model.Agent{Name: "java"}},
},
Expand All @@ -156,6 +158,7 @@ func TestAggregatorRun(t *testing.T) {
{Name: "metricset.period", Value: 10},
},
}, {
Name: "service_destination",
Metadata: model.Metadata{
Service: model.Service{Name: "service-A", Agent: model.Agent{Name: "java"}},
},
Expand All @@ -171,6 +174,7 @@ func TestAggregatorRun(t *testing.T) {
{Name: "metricset.period", Value: 10},
},
}, {
Name: "service_destination",
Metadata: model.Metadata{
Service: model.Service{Name: "service-B", Agent: model.Agent{Name: "python"}},
},
Expand Down Expand Up @@ -231,6 +235,7 @@ func TestAggregatorOverflow(t *testing.T) {

m.Timestamp = time.Time{}
assert.Equal(t, &model.Metricset{
Name: "service_destination",
Metadata: model.Metadata{
Service: model.Service{Name: "service", Agent: model.Agent{Name: "agent"}},
},
Expand Down

0 comments on commit 998a09b

Please sign in to comment.