@@ -68,7 +68,7 @@ public EcsLayout()
68
68
_defaultAgent = EcsDocument . CreateAgent ( typeof ( EcsLayout ) ) ;
69
69
70
70
// These values are set by the Elastic.Apm.NLog package
71
- if ( NLogApmLoaded ( ) )
71
+ if ( NLogApmLoaded . Value )
72
72
{
73
73
ApmTraceId = "${ElasticApmTraceId}" ;
74
74
ApmTransactionId = "${ElasticApmTransactionId}" ;
@@ -88,7 +88,7 @@ protected override void InitializeLayout()
88
88
{
89
89
if ( CanIncludeAspNetProperties ( ) )
90
90
{
91
- if ( NLogWeb5Registered ( ) )
91
+ if ( NLogWeb5Registered . Value )
92
92
EventDurationMs = "${aspnet-request-duration}" ;
93
93
94
94
HttpRequestId = "${aspnet-TraceIdentifier}" ;
@@ -104,25 +104,25 @@ protected override void InitializeLayout()
104
104
UrlQuery = "${aspnet-request-url:IncludeScheme=false:IncludeHost=false:IncludePath=false:IncludeQueryString=true}" ;
105
105
UrlUserName = "${aspnet-user-identity}" ;
106
106
107
- if ( ! NLogApmLoaded ( ) )
107
+ if ( ! NLogApmLoaded . Value )
108
108
ApmTraceId = "${scopeproperty:item=RequestId:whenEmpty=${aspnet-TraceIdentifier}}" ;
109
109
}
110
110
111
111
base . InitializeLayout ( ) ;
112
112
}
113
113
114
- private static bool NLogApmLoaded ( ) => Type . GetType ( "Elastic.Apm.NLog.ApmTraceIdLayoutRenderer, Elastic.Apm.NLog" ) != null ;
114
+ private static Lazy < bool > NLogApmLoaded { get ; } = new Lazy < bool > ( ( ) => Type . GetType ( "Elastic.Apm.NLog.ApmTraceIdLayoutRenderer, Elastic.Apm.NLog" ) != null ) ;
115
115
116
116
#if NETFRAMEWORK
117
- private static bool NLogWeb4Registered ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestCookieLayoutRenderer, NLog.Web" ) != null ;
117
+ private static Lazy < bool > NLogWeb4Registered { get ; } = new Lazy < bool > ( ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestCookieLayoutRenderer, NLog.Web" ) != null ) ;
118
118
#else
119
- private static bool NLogWeb4Registered ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestCookieLayoutRenderer, NLog.Web.AspNetCore" ) != null ;
119
+ private static Lazy < bool > NLogWeb4Registered { get ; } = new Lazy < bool > ( ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestCookieLayoutRenderer, NLog.Web.AspNetCore" ) != null ) ;
120
120
#endif
121
121
122
122
#if NETFRAMEWORK
123
- private static bool NLogWeb5Registered ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestDurationLayoutRenderer, NLog.Web" ) != null ;
123
+ private static Lazy < bool > NLogWeb5Registered { get ; } = new Lazy < bool > ( ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestDurationLayoutRenderer, NLog.Web" ) != null ) ;
124
124
#else
125
- private static bool NLogWeb5Registered ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestDurationLayoutRenderer, NLog.Web.AspNetCore" ) != null ;
125
+ private static Lazy < bool > NLogWeb5Registered { get ; } = new Lazy < bool > ( ( ) => Type . GetType ( "NLog.Web.LayoutRenderers.AspNetRequestDurationLayoutRenderer, NLog.Web.AspNetCore" ) != null ) ;
126
126
#endif
127
127
128
128
/// <summary></summary>
@@ -216,7 +216,7 @@ protected override void InitializeLayout()
216
216
/// <summary>
217
217
/// Tests if aspnet properties would be rendered
218
218
/// </summary>
219
- public bool CanIncludeAspNetProperties ( ) => IncludeAspNetProperties && NLogWeb4Registered ( ) ;
219
+ public bool CanIncludeAspNetProperties ( ) => IncludeAspNetProperties && NLogWeb4Registered . Value ;
220
220
221
221
/// <summary></summary>
222
222
[ ArrayParameter ( typeof ( TargetPropertyWithContext ) , "label" ) ]
0 commit comments