From 444d8f99b5d1f008ef51d50d87152a7070a7ad01 Mon Sep 17 00:00:00 2001 From: Tejas Kokje Date: Mon, 10 Jun 2024 16:30:30 -0700 Subject: [PATCH] Add middleware.io specific resource attributes for cloudwatchreceiver --- receiver/awscloudwatchreceiver/go.mod | 1 + receiver/awscloudwatchreceiver/go.sum | 2 ++ receiver/awscloudwatchreceiver/logs.go | 10 +++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/receiver/awscloudwatchreceiver/go.mod b/receiver/awscloudwatchreceiver/go.mod index 4532d611bbfb..1ba851ad8a5c 100644 --- a/receiver/awscloudwatchreceiver/go.mod +++ b/receiver/awscloudwatchreceiver/go.mod @@ -17,6 +17,7 @@ require ( go.opentelemetry.io/collector/consumer v0.84.0 go.opentelemetry.io/collector/pdata v1.0.0-rcv0014 go.opentelemetry.io/collector/receiver v0.84.0 + go.opentelemetry.io/collector/semconv v0.84.0 go.uber.org/zap v1.25.0 ) diff --git a/receiver/awscloudwatchreceiver/go.sum b/receiver/awscloudwatchreceiver/go.sum index d955dc8c4d78..78b6d240a103 100644 --- a/receiver/awscloudwatchreceiver/go.sum +++ b/receiver/awscloudwatchreceiver/go.sum @@ -293,6 +293,8 @@ go.opentelemetry.io/collector/pdata v1.0.0-rcv0014 h1:iT5qH0NLmkGeIdDtnBogYDx7L5 go.opentelemetry.io/collector/pdata v1.0.0-rcv0014/go.mod h1:BRvDrx43kiSoUx3mr7SoA7h9B8+OY99mUK+CZSQFWW4= go.opentelemetry.io/collector/receiver v0.84.0 h1:5bN0A18UMAVu9AsFv5AYDgzEFEJ/nFaD1OK2rk7Ygy0= go.opentelemetry.io/collector/receiver v0.84.0/go.mod h1:QvjpfmMUA4tW59QJBagoNEbRT5JGYZN333GAOuWIRr4= +go.opentelemetry.io/collector/semconv v0.84.0 h1:sI1B8ebHhfJPd87iyba66TDnluVFvYu8CEpSjKHqIDc= +go.opentelemetry.io/collector/semconv v0.84.0/go.mod h1:j/8THcqVxFna1FpvA2zYIsUperEtOaRaqoLYIN4doWw= go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= diff --git a/receiver/awscloudwatchreceiver/logs.go b/receiver/awscloudwatchreceiver/logs.go index ae7f268e802c..41709a14ed6c 100644 --- a/receiver/awscloudwatchreceiver/logs.go +++ b/receiver/awscloudwatchreceiver/logs.go @@ -17,6 +17,8 @@ import ( "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/plog" "go.uber.org/zap" + + conventions "go.opentelemetry.io/collector/semconv/v1.6.1" ) const ( @@ -275,9 +277,15 @@ func (l *logsReceiver) processEvents(now pcommon.Timestamp, logGroupName string, rl := logs.ResourceLogs().AppendEmpty() resourceLogs = &rl resourceAttributes := resourceLogs.Resource().Attributes() - resourceAttributes.PutStr("aws.region", l.region) + resourceAttributes.PutStr(conventions.AttributeCloudProvider, conventions.AttributeCloudProviderAWS) + resourceAttributes.PutStr(conventions.AttributeCloudRegion, l.region) resourceAttributes.PutStr("cloudwatch.log.group.name", logGroupName) resourceAttributes.PutStr("cloudwatch.log.stream", logStreamName) + + //middleware.io specific attributes + resourceAttributes.PutStr("channel", conventions.AttributeCloudProviderAWS) + resourceAttributes.PutStr("aws.scraping_approach", "api_polling") + resourceAttributes.PutStr("aws.polling_approach", l.pollingApproach) group[logStreamName] = resourceLogs // Ensure one scopeLogs is initialized so we can handle in standardized way going forward.