void collectData ( ) { // Send data for any subscriptions if ( config . lwcEnabled ( ) ) { try { handleSubscriptions ( ) ; } catch ( Exception e ) { logger . warn ( "failed to handle subscriptions" , e ) ; } } else { logger . debug ( "lwc is disabled, skipping subscriptions" ) ; } // Publish to Atlas if ( config . enabled ( ) ) { try { for ( List < Measurement > batch : getBatches ( ) ) { PublishPayload p = new PublishPayload ( commonTags , batch ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "publish payload: {}" , jsonMapper . writeValueAsString ( p ) ) ; } HttpResponse res = client . post ( uri ) . withConnectTimeout ( connectTimeout ) . withReadTimeout ( readTimeout ) . withContent ( "application/x-jackson-smile" , smileMapper . writeValueAsBytes ( p ) ) . send ( ) ; Instant date = res . dateHeader ( "Date" ) ; recordClockSkew ( ( date == null ) ? 0L : date . toEpochMilli ( ) ) ; } } catch ( Exception e ) { logger . warn ( "failed to send metrics (uri={})" , uri , e ) ; } } else { logger . debug ( "publishing is disabled, skipping collection" ) ; } // Clean up any expired meters removeExpiredMeters ( ) ; }
Collect data and send to Atlas .