parameters: (self, channels: Optional[List[str]] = None)
return_statement: return 0, report, ''
docstring: Preview a sample report of the most recent collections available (except for 'device')
docstring_summary: Preview a sample report of the most recent collections available (except for 'device')
docstring_tokens: Preview a sample report of the most recent collections available ( except for device )
function: def preview(self, channels: Optional[List[str]] = None) -> Tuple[int, str, str]:
          '''
          Preview a sample report of the most recent collections available (except for 'device')
          '''
          report = {}
  
          # We use a lock to prevent a scenario where the user wishes to preview
          # the report, and at the same time the module hits the interval of
          # sending a report with the opted-in collection, which has less data
          # than in the preview report.
          col_delta = self.collection_delta()
          with self.get_report_lock:
              if col_delta is not None and len(col_delta) == 0:
                  # user is already opted-in to the most recent collection
                  msg = 'Telemetry is up to date, see report with `ceph telemetry show`.'
                  return 0, msg, ''
              else:
                  # there are collections the user is not opted-in to
                  next_collection = []
  
                  for c in MODULE_COLLECTION:
                      next_collection.append(c['name'].name)
  
                  opted_in_collection = self.db_collection
                  self.db_collection = next_collection
                  report = self.get_report(channels=channels)
                  self.db_collection = opted_in_collection
  
          self.format_perf_histogram(report)
          report = json.dumps(report, indent=4, sort_keys=True)
  
          if self.channel_device:
              report += '''\nDevice report is generated separately. To see it run 'ceph telemetry preview-device'.'''
  
          return 0, report, ''
function_tokens: def preview ( self , channels : Optional [ List [ str ] ] = None ) -> Tuple [ int , str , str ] : report = { } # We use a lock to prevent a scenario where the user wishes to preview # the report, and at the same time the module hits the interval of # sending a report with the opted-in collection, which has less data # than in the preview report. col_delta = self . collection_delta ( ) with self . get_report_lock : if col_delta is not None and len ( col_delta ) == 0 : # user is already opted-in to the most recent collection msg = 'Telemetry is up to date, see report with `ceph telemetry show`.' return 0 , msg , '' else : # there are collections the user is not opted-in to next_collection = [ ] for c in MODULE_COLLECTION : next_collection . append ( c [ 'name' ] . name ) opted_in_collection = self . db_collection self . db_collection = next_collection report = self . get_report ( channels = channels ) self . db_collection = opted_in_collection self . format_perf_histogram ( report ) report = json . dumps ( report , indent = 4 , sort_keys = True ) if self . channel_device : report += '''\nDevice report is generated separately. To see it run 'ceph telemetry preview-device'.''' return 0 , report , ''