internal static Scope CreateScopeFromValidate(Tracer tracer, IDocument document)
        {
            if (!tracer.Settings.IsIntegrationEnabled(IntegrationId))
            {
                // integration disabled, don't create a scope, skip this trace
                return(null);
            }

            Scope scope = null;

            try
            {
                var    tags        = new GraphQLTags();
                string serviceName = tracer.Settings.GetServiceName(tracer, ServiceName);
                scope = tracer.StartActiveWithTags(ValidateOperationName, serviceName: serviceName, tags: tags);

                var span = scope.Span;
                span.Type   = SpanTypes.GraphQL;
                tags.Source = document.OriginalQuery;

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

            return(scope);
        }
        private static Scope CreateScopeFromExecuteAsync(Tracer tracer, string operationName, string source, string operationType)
        {
            Scope scope;

            var operation = string.IsNullOrEmpty(operationName)
                    ? operationType
                    : $"{operationType} {operationName}";

            var tags        = new GraphQLTags();
            var serviceName = tracer.Settings.GetServiceName(tracer, ServiceName);

            scope = tracer.StartActiveInternal(operation, serviceName: serviceName, tags: tags);

            var span = scope.Span;

            span.Type         = SpanTypes.GraphQL;
            span.ResourceName = $"{operationType} {operationName ?? "operation"}";
            span.LogicScope   = ExecuteOperationName;

            tags.Source        = source;
            tags.OperationName = operationName;
            tags.OperationType = operationType;

            tags.SetAnalyticsSampleRate(IntegrationId, tracer.Settings, enabledWithGlobalSetting: false);
            tracer.TracerManager.Telemetry.IntegrationGeneratedSpan(IntegrationId);

            return(scope);
        }
        internal static Scope CreateScopeFromExecuteAsync(Tracer tracer, IExecutionContext executionContext)
        {
            if (!tracer.Settings.IsIntegrationEnabled(IntegrationId))
            {
                // integration disabled, don't create a scope, skip this trace
                return(null);
            }

            Scope scope = null;

            try
            {
                string source        = executionContext.Document.OriginalQuery;
                string operationName = executionContext.Operation.Name;
                string operationType = executionContext.Operation.OperationType.ToString();

                var    tags        = new GraphQLTags();
                string serviceName = tracer.Settings.GetServiceName(tracer, ServiceName);
                scope = tracer.StartActiveInternal(ExecuteOperationName, serviceName: serviceName, tags: tags);

                var span = scope.Span;
                span.Type         = SpanTypes.GraphQL;
                span.ResourceName = $"{operationType} {operationName ?? "operation"}";

                tags.Source        = source;
                tags.OperationName = operationName;
                tags.OperationType = operationType;

                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);
        }