Start the StatsD reporter, if configured.

@throws URISyntaxException
8997
@PostConstruct
    public final void init() throws URISyntaxException {
        final String address = getConfig(ADDRESS, null);
        if (address != null) {
            final URI uri = new URI("udp://" + address);
            final String prefix = getConfig(PREFIX, "mapfish-print").replace("%h", getHostname());
            final int period = Integer.parseInt(getConfig(PERIOD, "10"));
            LOGGER.info("Starting a StatsD reporter targeting {} with prefix {} and period {}s",
                        uri, prefix, period);
            this.reporter = StatsDReporter.forRegistry(this.metricRegistry)
                    .prefixedWith(prefix)
                    .build(uri.getHost(), uri.getPort());
            this.reporter.start(period, TimeUnit.SECONDS);
        }
    }
484025
public void startCDATA() throws org.xml.sax.SAXException
  {
    m_inCData = true;
    append(m_doc.createCDATASection(""));
  }
936077
public void start(final Xid xid, final int flags) throws XAException {

        final String methodName = "start";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, new Object[] { xid, flags });
        }

        _siXaResource.start(xid, flags);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
1336197
public final void start() throws IOException {
        initialiseOffsets();

        dataFileBuffer = byteBufferFactory.build(getBufferLength());
        synchronized (globalLock) {
            populateDataBuffer(dataFileBuffer, metricData.values());
            preparePerMetricBufferSlices();
        }

        started = true;
    }
449751
@Override
    public final void startData(String id, long contentLength, String contentType) throws Exception {
        if (contentLength==-1){
            bos = new DyanmicByteArrayOutputStream();
        } else {
            bos = new FixedByteArrayOutputStream(contentLength);
        }
    }
693564
@Override
  public void start()
  {
    try {
      JournalClientEndpoint endpoint = connect();
      
      if (endpoint != null) {
        OutputStream os;
        
        _os = os = endpoint.startMessage();
        if (os != null) {
          os.write('M');
        }
      }
    } catch (Exception e) {
      log.finer(e.toString());
      //e.printStackTrace();
      // // throw new RuntimeException(e);
    }
  }
1373730
@Override
	public void start() {
		try {
			url = new URL(getStringSetting(SETTING_URL, DEFAULT_STACKDRIVER_API_URL));
		} catch (MalformedURLException e) {
			throw new EmbeddedJmxTransException(e);
		}

		apiKey = getStringSetting(SETTING_TOKEN);

		if (getStringSetting(SETTING_PROXY_HOST, null) != null && !getStringSetting(SETTING_PROXY_HOST).isEmpty()) {
			proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(getStringSetting(SETTING_PROXY_HOST), getIntSetting(SETTING_PROXY_PORT)));
		}
		
		logger.info("Starting Stackdriver writer connected to '{}', proxy {} ...", url, proxy);
		

		stackdriverApiTimeoutInMillis = getIntSetting(SETTING_STACKDRIVER_API_TIMEOUT_IN_MILLIS, DEFAULT_STACKDRIVER_API_TIMEOUT_IN_MILLIS);

		// try to get and instance ID
		if (getStringSetting(SETTING_SOURCE_INSTANCE, null) != null && !getStringSetting(SETTING_SOURCE_INSTANCE).isEmpty()) {
			// if one is set directly use that
			instanceId = getStringSetting(SETTING_SOURCE_INSTANCE);
			logger.info("Using instance ID {} from setting {}", instanceId, SETTING_SOURCE_INSTANCE);
		} else if (getStringSetting(SETTING_DETECT_INSTANCE, null) != null && "AWS".equalsIgnoreCase(getStringSetting(SETTING_DETECT_INSTANCE))) {
			// if setting is to detect, look on the local machine URL
			logger.info("Detect instance set to AWS, trying to determine AWS instance ID");
			instanceId = getLocalAwsInstanceId();
			if (instanceId != null) {
				logger.info("Detected instance ID as {}", instanceId);
			} else {
				logger.info("Unable to detect AWS instance ID for this machine, sending metrics without an instance ID");
			}
		} else {
			// no instance ID, the metrics will be sent as "bare" custom metrics and not associated with an instance
			instanceId = null;
			logger.info("No source instance ID passed, and not set to detect, sending metrics without and instance ID");
		}
		
	}
107593
void documentStart() throws SAXException{
        encoding = null;
        standalone = null;
        prefixLength = 0;
        value.setLength(0);
        valueStarted = false;
        entityValue = false;

        elem = elements[0];
        elemLock = elemDepth = 0;
        nsFree = 4;

        systemID = null;
        publicID = null;

        entities.clear();
        entityStack.clear();

        paramEntities.clear();
        paramEntityStack.clear();
        peReferenceOutsideMarkup = false;

        dtd = null;
        _dtd.reset();
        dtdElement = null;
        attributeList = null;
        dtdAttribute = null;

        if(contentHandler!=null){
            contentHandler.setDocumentLocator(this);
            contentHandler.startDocument();
        }
    }
586003
public void startDocument() throws IOException {
        ResponseWriter writer = getWrapped();
        String encoding = writer.getCharacterEncoding( );
        if( encoding == null ) {
            encoding = "utf-8";
        }
        writer.writePreamble("<?xml version='1.0' encoding='" + encoding + "'?>\n");
        writer.startElement("partial-response", null);
        FacesContext ctx = FacesContext.getCurrentInstance();
        if (null != ctx && null != ctx.getViewRoot()) {
            String id = ctx.getViewRoot().getContainerClientId(ctx);
            writer.writeAttribute("id", id, "id");
        }
    }
21034
public void run() {
        // Reset the stats managed by the client.
        periodicStatsContext.fetchAndResetBaseline();

        // Run in a loop for config.duration seconds.
        final long benchmarkEndTime = app.startTS + (1000l * app.config.duration);
        while (benchmarkEndTime > System.currentTimeMillis()) {

            // GENERATE A RANDOM ROW

            // unique identifier and partition key
            String uuid = UUID.randomUUID().toString();

            // millisecond timestamp
            Date now = new Date();

            // for some odd reason, this will give LONG_MAX if the
            // computed value is > LONG_MAX.
            long val = (long) (rand.nextGaussian() * 1000.0);

            // CALL THE USER'S SELECTED FLAVOR OF INSERT

            try {
                // Do an vanilla insert.
                if (!app.config.inline) {
                    basicInsert(uuid, val, now);
                }
                // Do an insert with date-based deleting
                else if (app.config.historyseconds > 0) {
                    insertWithDateDelete(uuid, val, now);
                }
                // Do an insert with timestamp-based deleting
                else if (app.config.maxrows > 0) {
                    insertWithRowcountDelete(uuid, val, now);
                }
            }
            catch (IOException e) {
                // Not being super picky about failure handling. If this
                // fails, it will show up in the client-side statistics we
                // print out in printReport().
            }
        }

        // When ready to end processing...
        try {
            // Block until all async calls have returned.
            client.drain();
            // Clean close of the client connection.
            client.close();
        }
        catch (IOException | InterruptedException e) {
            // Live dangerously and ignore this error that probably
            // won't happen at shutdown time.
        }

    }
8650
public void startQueryService(RpcService rpcService, ResourceID resourceID) {
		synchronized (lock) {
			Preconditions.checkState(!isShutdown(), "The metric registry has already been shut down.");

			try {
				metricQueryServiceRpcService = rpcService;
				queryService = MetricQueryService.createMetricQueryService(rpcService, resourceID, maximumFramesize);
				queryService.start();
			} catch (Exception e) {
				LOG.warn("Could not start MetricDumpActor. No metrics will be submitted to the WebInterface.", e);
			}
		}
	}
1063815
public void startDocument(OutputStream os) throws ODataRenderException {
        try {
            outputStream = os;
            xmlWriter = XML_OUTPUT_FACTORY.createXMLStreamWriter(os, UTF_8.name());
            metadataWriter = new AtomMetadataWriter(xmlWriter, oDataUri, entityDataModel, nsConfigurationProvider);
            dataWriter = new AtomDataWriter(xmlWriter, entityDataModel, nsConfigurationProvider);
            xmlWriter.writeStartDocument(UTF_8.name(), XML_VERSION);
            xmlWriter.setPrefix(METADATA, nsConfigurationProvider.getOdataMetadataNs());
            xmlWriter.setPrefix(ODATA_DATA, nsConfigurationProvider.getOdataDataNs());
        } catch (XMLStreamException e) {
            LOG.error("Not possible to start stream XML");
            throw new ODataRenderException("Not possible to start stream XML: ", e);
        }
    }
469366
public void startMetricReporting(Properties properties) {
    if (this.metricsReportingStarted) {
      LOGGER.warn("Metric reporting has already started");
      return;
    }

    TimeUnit reportTimeUnit = TimeUnit.MILLISECONDS;
    long reportInterval = Long.parseLong(properties
        .getProperty(ConfigurationKeys.METRICS_REPORT_INTERVAL_KEY, ConfigurationKeys.DEFAULT_METRICS_REPORT_INTERVAL));
    ScheduledReporter.setReportingInterval(properties, reportInterval, reportTimeUnit);

    long startTime = System.currentTimeMillis();

    try {
      // Build and start the JMX reporter
      buildJmxMetricReporter(properties);
      if (this.jmxReporter.isPresent()) {
        LOGGER.info("Will start reporting metrics to JMX");
        this.jmxReporter.get().start();
      }

      // Build all other reporters
      buildFileMetricReporter(properties);
      buildKafkaMetricReporter(properties);
      buildGraphiteMetricReporter(properties);
      buildInfluxDBMetricReporter(properties);
      buildCustomMetricReporters(properties);
      buildFileFailureEventReporter(properties);

      // Start reporters that implement org.apache.gobblin.metrics.report.ScheduledReporter
      RootMetricContext.get().startReporting();

      // Start reporters that implement com.codahale.metrics.ScheduledReporter
      for (com.codahale.metrics.ScheduledReporter scheduledReporter : this.codahaleScheduledReporters) {
        scheduledReporter.start(reportInterval, reportTimeUnit);
      }
    } catch (Exception e) {
      LOGGER.error("Metrics reporting cannot be started due to {}", ExceptionUtils.getFullStackTrace(e));
      throw e;
    }

    this.metricsReportingStarted = true;
    LOGGER.info("Metrics reporting has been started in {} ms: GobblinMetrics {}",
        System.currentTimeMillis() - startTime, this.toString());
  }
37462
@SuppressWarnings("unused")
  final void startRecording() {
    if (firstTime) {
      Object obj;
      doStartRecording();
      obj = new Object();
      AllocationStats stats = stopRecording(1);
      if (stats.getAllocationCount() != 1 || stats.getAllocationSize() < 1) {
        throw new IllegalStateException(
            String.format("The allocation recording infrastructure appears to be broken. "
                + "Expected to find exactly one allocation of a java/lang/Object instead found %s",
                stats));
      }
      firstTime = false;
    }
    doStartRecording();
  }
501316
public static void start() throws Exception {
        MetricRegistry registry = new MetricRegistry();

        QueuedThreadPool threadPool = new InstrumentedQueuedThreadPool(registry);
        threadPool.setName("esigate");
        threadPool.setMaxThreads(maxThreads);
        threadPool.setMinThreads(minThreads);

        srv = new Server(threadPool);
        srv.setStopAtShutdown(true);
        srv.setStopTimeout(5000);

        // HTTP Configuration
        HttpConfiguration httpConfig = new HttpConfiguration();
        httpConfig.setOutputBufferSize(outputBufferSize);
        httpConfig.setSendServerVersion(false);
        Timer processTime = registry.timer("processTime");

        try (ServerConnector connector =
                new InstrumentedServerConnector("main", EsigateServer.port, srv, registry,
                        new InstrumentedConnectionFactory(new HttpConnectionFactory(httpConfig), processTime));
                ServerConnector controlConnector = new ServerConnector(srv)) {

            // Main connector
            connector.setIdleTimeout(EsigateServer.idleTimeout);
            connector.setSoLingerTime(-1);
            connector.setName("main");
            connector.setAcceptQueueSize(200);

            // Control connector
            controlConnector.setHost("127.0.0.1");
            controlConnector.setPort(EsigateServer.controlPort);
            controlConnector.setName("control");

            srv.setConnectors(new Connector[] {connector, controlConnector});
            // War
            ProtectionDomain protectionDomain = EsigateServer.class.getProtectionDomain();
            String warFile = protectionDomain.getCodeSource().getLocation().toExternalForm();
            String currentDir = new File(protectionDomain.getCodeSource().getLocation().getPath()).getParent();

            File workDir = resetTempDirectory(currentDir);

            WebAppContext context = new WebAppContext(warFile, EsigateServer.contextPath);
            context.setServer(srv);
            context.setTempDirectory(workDir);
            if (StringUtils.isNoneEmpty(sessionCookieName)) {
                context.getSessionHandler().getSessionManager().getSessionCookieConfig().setName(sessionCookieName);
            }
            // Add extra classpath (allows to add extensions).
            if (EsigateServer.extraClasspath != null) {
                context.setExtraClasspath(EsigateServer.extraClasspath);
            }

            // Add the handlers
            HandlerCollection handlers = new HandlerList();
            // control handler must be the first one.
            // Work in progress, currently disabled.
            handlers.addHandler(new ControlHandler(registry));
            InstrumentedHandler ih = new InstrumentedHandler(registry);
            ih.setName("main");
            ih.setHandler(context);
            handlers.addHandler(ih);

            srv.setHandler(handlers);
            srv.start();
            srv.join();

        }

    }
573625
public void subscribe() throws URISyntaxException, TransportConfigException {

    /*
     * if this instance of the transport (as there could be several - each with
     * a different topic) is in shutdown mode then don't subscribe. This is a
     * side effect of when you shutdown a sns transport and the listener gets an
     * UnsubscribeConfirmation. In normal operation, when the topic does
     * occasional house keeping and clears out the subscriptions, running
     * transports will just re-subscribe.
     */
    if (_inShutdown)
      return;

    URI url = getBaseSubscriptionURI();

    String subscriptionURL = url.toString() + "listener/sns";
    LOGGER.info("Subscription  URI - " + subscriptionURL);

    SubscribeRequest subRequest = new SubscribeRequest(_argoTopicName, "http", subscriptionURL);
    try {
      getSNSClient().subscribe(subRequest);
    } catch (AmazonServiceException e) {
      throw new TransportConfigException("Error subscribing to SNS topic.", e);
    }
    // get request id for SubscribeRequest from SNS metadata
    this._subscriptionArn = getSNSClient().getCachedResponseMetadata(subRequest).toString();
    LOGGER.info("SubscribeRequest - " + _subscriptionArn);
  }
897246
def add_reporter(self, reporter):
        """"""
        with self._lock:
            reporter.init(list(self.metrics.values()))
            self._reporters.append(reporter)