internal static Scope CreateScope(Tracer tracer, IntegrationId integrationId, string host, string port, string rawCommand)
        {
            if (!Tracer.Instance.Settings.IsIntegrationEnabled(integrationId))
            {
                // integration disabled, don't create a scope, skip this trace
                return(null);
            }

            var parent = tracer.ActiveScope?.Span;

            if (parent != null &&
                parent.Type == SpanTypes.Redis &&
                parent.GetTag(Tags.InstrumentationName) != null)
            {
                return(null);
            }

            string serviceName = tracer.Settings.GetServiceName(tracer, ServiceName);
            Scope  scope       = null;

            try
            {
                var tags = new RedisTags();

                scope = tracer.StartActiveInternal(OperationName, serviceName: serviceName, tags: tags);
                int    separatorIndex = rawCommand.IndexOf(' ');
                string command;

                if (separatorIndex >= 0)
                {
                    command = rawCommand.Substring(0, separatorIndex);
                }
                else
                {
                    command = rawCommand;
                }

                var span = scope.Span;
                span.Type         = SpanTypes.Redis;
                span.ResourceName = command;
                tags.RawCommand   = rawCommand;
                tags.Host         = host;
                tags.Port         = port;

                tags.SetAnalyticsSampleRate(integrationId, tracer.Settings, enabledWithGlobalSetting: false);
                tracer.TracerManager.Telemetry.IntegrationGeneratedSpan(integrationId);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error creating or populating scope.");
            }

            return(scope);
        }