/// <summary>
        /// 1.Instrument configurations from appsettings.json
        /// 2.Subscribe AspNetCoreDiagnosticListener, HttpOutDiagnosticListener, SqlDiagnosticListener(SDS and MDS),
        /// EntityFrameworkCoreDiagnosticListener for tacing AspNetCore incoming request, Http outgpingrequest, and Sql request.
        /// 3.Register XRay for AWS services
        /// </summary>
        internal static void Initialize()
        {
            var xrayAutoInstrumentationOptions = XRayConfiguration.Register();

            var serviceName = xrayAutoInstrumentationOptions.ServiceName;

            var subscriptions = new List <DiagnosticListenerBase>();

            // Subscribe diagnostic listener for tracing Asp.Net Core request
            subscriptions.Add(new AspNetCoreDiagnosticListener(serviceName));

            // Subscribe diagnostic listener for tracing Http outgoing request
            if (xrayAutoInstrumentationOptions.TraceHttpRequests)
            {
                subscriptions.Add(new HttpOutDiagnosticListenerNetstandard());
            }

            // Subscribe diagnostic listener for tracing Sql request
            if (xrayAutoInstrumentationOptions.TraceSqlRequests)
            {
                subscriptions.Add(new SqlDiagnosticListener());
            }

            // Subscribe diagnostic listener for tracing EF Core request
            if (xrayAutoInstrumentationOptions.TraceEFRequests)
            {
                subscriptions.Add(new EntityFrameworkCoreDiagnosticListener());
            }

            DiagnosticListener.AllListeners.Subscribe(new DiagnosticListenerObserver(subscriptions));

            // Enable tracing for AWS request
            if (xrayAutoInstrumentationOptions.TraceAWSRequests)
            {
                AWSSDKRequestRegister.Register();
            }
        }
        /// <summary>
        /// 1.Add HttpOutDiagnosticListenerNetframework, EntityFramework and Sql tracing handler for tracing Http outgping request and Sql query.
        /// 2.Register XRay for AWS services
        /// </summary>
        internal static void Initialize(XRayAutoInstrumentationOptions options)
        {
            if (options.TraceHttpRequests)
            {
                DiagnosticListenerBase[] subscriptions = { new HttpOutDiagnosticListenerNetframework() };

                DiagnosticListener.AllListeners.Subscribe(new DiagnosticListenerObserver(subscriptions));
            }

            if (options.TraceSqlRequests)
            {
                _ = new SqlEventListener();
            }

            if (options.TraceEFRequests)
            {
                DbInterception.Add(new EntityFrameworkHandler());
            }

            if (options.TraceAWSRequests)
            {
                AWSSDKRequestRegister.Register();
            }
        }