Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMF Exporter does not forward metrics if IRSA is enabled #915

Merged
merged 14 commits into from
Oct 23, 2023
2 changes: 1 addition & 1 deletion plugins/inputs/logfile/logfile_test.go
Original file line number Diff line number Diff line change
@@ -434,7 +434,7 @@ func createWriteRead(t *testing.T, prefix string, logFile *LogFile, done chan bo
defer close(evts)
// Choose a large enough number of lines so that even high-spec hosts will not
// complete receiving logEvents before the 2nd createWriteRead() goroutine begins.
const numLines int = 1000000
const numLines int = 10000
dchappa marked this conversation as resolved.
Show resolved Hide resolved
const msg string = "this is the best log line ever written to a file"
writeLines(t, file, numLines, msg)
file.Close()
1 change: 1 addition & 0 deletions translator/translate/otel/exporter/awsemf/translator.go
Original file line number Diff line number Diff line change
@@ -93,6 +93,7 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) {
if credentialsFileKey, ok := agent.Global_Config.Credentials[agent.CredentialsFile_Key]; ok {
cfg.AWSSessionSettings.SharedCredentialsFile = []string{fmt.Sprintf("%v", credentialsFileKey)}
}
cfg.AWSSessionSettings.RoleARN = agent.Global_Config.Role_arn
SaxyPandaBear marked this conversation as resolved.
Show resolved Hide resolved
cfg.AWSSessionSettings.IMDSRetries = retryer.GetDefaultRetryNumber()

if isEcs(c) {
Original file line number Diff line number Diff line change
@@ -12,13 +12,16 @@ import (
"go.opentelemetry.io/collector/confmap"

legacytranslator "github.com/aws/amazon-cloudwatch-agent/translator"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/agent"
)

var nilSlice []string
var nilMetricDescriptorsSlice []awsemfexporter.MetricDescriptor

func TestTranslator(t *testing.T) {
tt := NewTranslator()
agent.Global_Config.Region = "us-east-1"
agent.Global_Config.Role_arn = "global_arn"
require.EqualValues(t, "awsemf", tt.ID().String())
testCases := map[string]struct {
env map[string]string
@@ -675,6 +678,8 @@ func TestTranslator(t *testing.T) {
require.Equal(t, testCase.want["resource_to_telemetry_conversion"], gotCfg.ResourceToTelemetrySettings)
require.ElementsMatch(t, testCase.want["metric_declarations"], gotCfg.MetricDeclarations)
require.ElementsMatch(t, testCase.want["metric_descriptors"], gotCfg.MetricDescriptors)
require.Equal(t, "global_arn", gotCfg.RoleARN)
require.Equal(t, "us-east-1", gotCfg.Region)
}
})
}