in translator/translate/otel/exporter/awsxray/translator.go [61:116]
func (t *translator) Translate(conf *confmap.Conf) (component.Config, error) {
if conf == nil || !conf.IsSet(common.TracesKey) {
return nil, &common.MissingKeyError{ID: t.ID(), JsonKey: common.TracesKey}
}
cfg := t.factory.CreateDefaultConfig().(*awsxrayexporter.Config)
if isAppSignals(conf) {
cfg.IndexedAttributes = indexedAttributes
}
c := confmap.NewFromStringMap(map[string]interface{}{
"telemetry": map[string]interface{}{
"enabled": true,
"include_metadata": true,
},
})
if err := c.Unmarshal(&cfg); err != nil {
return nil, fmt.Errorf("unable to unmarshal into awsxrayexporter config: %w", err)
}
cfg.AWSSessionSettings.CertificateFilePath = os.Getenv(envconfig.AWS_CA_BUNDLE)
if endpointOverride, ok := common.GetString(conf, common.ConfigKey(common.TracesKey, common.EndpointOverrideKey)); ok {
cfg.AWSSessionSettings.Endpoint = endpointOverride
}
cfg.AWSSessionSettings.IMDSRetries = retryer.GetDefaultRetryNumber()
if context.CurrentContext().Mode() == config.ModeOnPrem || context.CurrentContext().Mode() == config.ModeOnPremise {
cfg.AWSSessionSettings.LocalMode = true
}
if localMode, ok := common.GetBool(conf, common.ConfigKey(common.TracesKey, common.LocalModeKey)); ok {
cfg.AWSSessionSettings.LocalMode = localMode
}
if insecure, ok := common.GetBool(conf, common.ConfigKey(common.TracesKey, common.InsecureKey)); ok {
cfg.AWSSessionSettings.NoVerifySSL = insecure
}
if concurrency, ok := common.GetNumber(conf, common.ConfigKey(common.TracesKey, concurrencyKey)); ok {
cfg.AWSSessionSettings.NumberOfWorkers = int(concurrency)
}
if profileKey, ok := agent.Global_Config.Credentials[agent.Profile_Key]; ok {
cfg.AWSSessionSettings.Profile = fmt.Sprintf("%v", profileKey)
}
if proxyAddress, ok := common.GetString(conf, common.ConfigKey(common.TracesKey, common.ProxyOverrideKey)); ok {
cfg.AWSSessionSettings.ProxyAddress = proxyAddress
}
if resourceARN, ok := common.GetString(conf, common.ConfigKey(common.TracesKey, resourceARNKey)); ok {
cfg.AWSSessionSettings.ResourceARN = resourceARN
}
if transitOtlp, ok := common.GetBool(conf, common.ConfigKey(common.TracesKey, transitSpansInOtlpFormatKey)); ok {
cfg.TransitSpansInOtlpFormat = transitOtlp
}
cfg.AWSSessionSettings.Region = getRegion(conf)
cfg.AWSSessionSettings.RoleARN = getRoleARN(conf)
if credentialsFileKey, ok := agent.Global_Config.Credentials[agent.CredentialsFile_Key]; ok {
cfg.AWSSessionSettings.SharedCredentialsFile = []string{fmt.Sprintf("%v", credentialsFileKey)}
}
cfg.MiddlewareID = &agenthealth.TracesID
return cfg, nil
}