File tree 1 file changed +12
-3
lines changed
src/Agent/NewRelic/Agent/Core
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -200,18 +200,27 @@ private static string GetNewRelicLogLevel()
200
200
201
201
public static AgentInfo GetAgentInfo ( )
202
202
{
203
- var agentInfoPath = $@ "{ NewRelicHome } \agentinfo.json";
203
+ if ( string . IsNullOrEmpty ( NewRelicHome ) )
204
+ {
205
+ Log . Debug ( $ "Could not get agent info. NewRelicHome is null or empty.") ;
206
+ return null ;
207
+ }
208
+
209
+ var agentInfoPath = Path . Combine ( NewRelicHome , "agentinfo.json" ) ;
210
+
204
211
if ( File . Exists ( agentInfoPath ) )
205
212
{
206
213
try
207
214
{
208
215
return JsonConvert . DeserializeObject < AgentInfo > ( File . ReadAllText ( agentInfoPath ) ) ;
209
216
}
210
- catch
217
+ catch ( Exception e )
211
218
{
212
- // Fail silently
219
+ Log . Debug ( e , $ "Could not deserialize agent info from { agentInfoPath } ." ) ;
213
220
}
214
221
}
222
+ else
223
+ Log . Debug ( $ "Could not get agent info from { agentInfoPath } . File does not exist.") ;
215
224
216
225
return null ;
217
226
}
You can’t perform that action at this time.
0 commit comments