@@ -44,15 +44,17 @@ public SimpleWSServer(SslContext context, IPAddress address, int port) : base(co
4444 /// </summary>
4545 /// <param name="error"></param>
4646 protected override void OnError ( SocketError error ) {
47- Activity ? activity = source . StartActivity ( ) ;
48- if ( activity != null ) {
49- activity . DisplayName = "Server OnError()" ;
50- activity . SetStatus ( ActivityStatusCode . Error ) ;
51- ActivityTagsCollection tagsCollection = new ( ) {
52- { "exception.type" , nameof ( SocketError ) } ,
53- } ;
54- activity . AddEvent ( new ActivityEvent ( "exception" , default , tagsCollection ) ) ;
55- activity . Stop ( ) ;
47+ if ( EnableTelemetry ) {
48+ Activity ? activity = source . StartActivity ( ) ;
49+ if ( activity != null ) {
50+ activity . DisplayName = "Server OnError()" ;
51+ activity . SetStatus ( ActivityStatusCode . Error ) ;
52+ ActivityTagsCollection tagsCollection = new ( ) {
53+ { "exception.type" , nameof ( SocketError ) } ,
54+ } ;
55+ activity . AddEvent ( new ActivityEvent ( "exception" , default , tagsCollection ) ) ;
56+ activity . Stop ( ) ;
57+ }
5658 }
5759 }
5860
@@ -456,6 +458,11 @@ public void AddCORS(string origin="*", string headers = "*", string methods = "G
456458
457459 #region OpenTelemetry
458460
461+ /// <summary>
462+ /// True to enable telemetry
463+ /// </summary>
464+ public bool EnableTelemetry { get ; set ; } = false ;
465+
459466 /// <summary>
460467 /// ActivitySource
461468 /// </summary>
0 commit comments