@@ -128,7 +128,7 @@ ConfigReader.prototype._getFileConfig = function (file) {
128128
129129ConfigReader . prototype . _getVmConfig = function ( name ) {
130130 var vmConfig = { }
131- var cGroupContent = this . readProcFile ( '/self/cgroup' )
131+ var cGroupContent = this . _readProcFile ( '/self/cgroup' )
132132 var isRunningInVm
133133
134134 if ( cGroupContent ) {
@@ -163,7 +163,7 @@ ConfigReader.prototype.isRunningInVm = function (cGroupFile) {
163163 return false
164164}
165165
166- ConfigReader . prototype . readProcFile = function ( name ) {
166+ ConfigReader . prototype . _readProcFile = function ( name ) {
167167 var procFileContent
168168 try {
169169 procFileContent = fs . readFileSync ( '/proc' + name , 'utf-8' )
@@ -173,7 +173,7 @@ ConfigReader.prototype.readProcFile = function (name) {
173173 return procFileContent
174174}
175175
176- ConfigReader . prototype . checkApiToken = function ( token ) {
176+ ConfigReader . prototype . _checkApiToken = function ( token ) {
177177 var bearerTokenParts
178178
179179 if ( ! token ) {
@@ -187,6 +187,11 @@ ConfigReader.prototype.checkApiToken = function (token) {
187187 }
188188}
189189
190+ ConfigReader . prototype . _normalizeConfig = function ( ) {
191+ this . config . apiKey = this . config . apiKey . trim ( )
192+ this . config . serviceName = this . config . serviceName . trim ( )
193+ }
194+
190195ConfigReader . prototype . getConfig = function ( ) {
191196 var parameterConfig = this . parameterConfig
192197 var systemConfig = this . _getSystemConfig ( )
@@ -202,7 +207,7 @@ ConfigReader.prototype.getConfig = function () {
202207
203208 var vmConfig = this . _getVmConfig ( )
204209
205- config = defaults (
210+ this . config = config = defaults (
206211 config ,
207212 fileConfig ,
208213 cloudFoundryConfig ,
@@ -214,12 +219,14 @@ ConfigReader.prototype.getConfig = function () {
214219 url . parse ( config . collectorApiUrl ) . host
215220 ] . concat ( config . ignoreOutgoingHosts || [ ] )
216221
217- this . checkApiToken ( config . apiKey )
222+ this . _checkApiToken ( config . apiKey )
218223
219224 if ( ! config . serviceName ) {
220225 throw new Error ( 'Missing serviceName, please set the TRACE_SERVICE_NAME environment variable' )
221226 }
222227
228+ this . _normalizeConfig ( )
229+
223230 return config
224231}
225232
0 commit comments