Skip to content

Commit

Permalink
feat: Support runtime metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
adebayor123 committed Sep 10, 2024
1 parent dd1c1bf commit 3489a58
Show file tree
Hide file tree
Showing 16 changed files with 3,384 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func (n *attributesNormalizer) copyResourceAttributesToAttributes(attributes, re
}
}
}
// runtime metrics do not have service attribute, so need to manually add
if serviceAttribute, ok := resourceAttributes.Get("aws.local.service"); ok {
attributes.PutStr(attr.AWSLocalService, serviceAttribute.AsString())
}
}

func (n *attributesNormalizer) normalizeTelemetryAttributes(attributes, resourceAttributes pcommon.Map, isTrace bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestCopyResourceAttributesToAttributes(t *testing.T) {
resourceAttributes.PutStr(resourceAttrKey, attrKey+"-value")
}
resourceAttributes.PutStr("host.id", "i-01ef7d37f42caa168")
resourceAttributes.PutStr("aws.local.service", "PetClinic")

// Create a pcommon.Map for attributes
attributes := pcommon.NewMap()
Expand All @@ -107,6 +108,10 @@ func TestCopyResourceAttributesToAttributes(t *testing.T) {
if value, ok := attributes.Get("K8s.Node"); !ok || value.AsString() != "i-01ef7d37f42caa168" {
t.Errorf("Attribute was not copied correctly: got %v, want %v", value.AsString(), "i-01ef7d37f42caa168")
}

if value, ok := attributes.Get("aws.local.service"); !ok || value.AsString() != "PetClinic" {
t.Errorf("Attribute was not copied correctly: got %v, want %v", value.AsString(), "PetClinic")
}
}

func TestTruncateAttributes(t *testing.T) {
Expand Down
6 changes: 5 additions & 1 deletion plugins/processors/awsapplicationsignals/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package awsapplicationsignals

import (
"context"
"unicode"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/pcommon"
Expand Down Expand Up @@ -137,7 +138,10 @@ func (ap *awsapplicationsignalsprocessor) processMetrics(ctx context.Context, md
metrics := ils.Metrics()
for k := 0; k < metrics.Len(); k++ {
m := metrics.At(k)
m.SetName(metricCaser.String(m.Name())) // Ensure metric name is in sentence case
// Check if the first letter of the metric name is not capitalized
if len(m.Name()) > 0 && !unicode.IsUpper(rune(m.Name()[0])) {
m.SetName(metricCaser.String(m.Name())) // Ensure metric name is in sentence case
}
ap.processMetricAttributes(ctx, m, resourceAttributes)
}
}
Expand Down
Loading

0 comments on commit 3489a58

Please sign in to comment.