private void determinePeriod( List<MetricsDuration> durations ) { periodStart = null; periodEnd = null; for ( MetricsDuration duration : durations ) { long periodStartTime = duration.getDate().getTime(); if ( periodStart == null || periodStartTime < periodStart ) { periodStart = periodStartTime; } long periodEndTime = duration.getEndDate().getTime(); if ( periodEnd == null || periodEnd < periodEndTime ) { periodEnd = periodEndTime; } } }
private void drawDurations( List<MetricsDuration> durations, List<MetricsDrawArea> areas, double pixelsPerMs ) { // set top indent int y = 20; for ( MetricsDuration duration : durations ) { Long realDuration = duration.getEndDate().getTime() - duration.getDate().getTime(); // How many pixels does it take to drawn this duration? // int durationWidth = (int) ( realDuration * pixelsPerMs ); int x = 2 + (int) ( ( duration.getDate().getTime() - periodStart ) * pixelsPerMs ); getGc().setBackground( EColor.BACKGROUND ); getGc().setForeground( EColor.LIGHTBLUE ); getGc().fillGradientRectangle( x, y, durationWidth, barHeight, false ); getGc().setForeground( EColor.BLACK ); getGc().drawRectangle( x, y, durationWidth, barHeight ); areas.add( new MetricsDrawArea( new Rectangle( x, y, durationWidth, barHeight ), duration ) ); LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( duration.getLogChannelId() ); String message = duration.getDescription() + " - " + loggingObject.getObjectName() + " : " + duration.getDuration() + "ms"; if ( duration.getCount() > 1 ) { message += " " + duration.getCount() + " calls, avg=" + ( duration.getDuration() / duration.getCount() ); } getGc().setFont( EFont.GRAPH ); getGc().textExtent( message ); getGc().drawText( message, x + 3, y + 4, true ); y += barHeight + 5; } }
if ( metricsDuration == null ) { metricsDuration = new MetricsDuration( lastSnapshot.getDate(), metric.getDescription(), lastSnapshot.getSubject(), logChannelId, extraDuration ); } else { metricsDuration.setDuration( metricsDuration.getDuration() + extraDuration ); metricsDuration.incrementCount(); if ( metricsDuration.getEndDate().getTime() < snapshot.getDate().getTime() ) { metricsDuration.setEndDate( snapshot.getDate() );
if ( start != null ) { durations.add( new MetricsDuration( start.getDate(), snapshot.getMetric().getDescription(), snapshot .getSubject(), logChannelId, null ) ); } else { long duration = snapshot.getDate().getTime() - start.getDate().getTime(); durations.add( new MetricsDuration( start.getDate(), snapshot.getMetric().getDescription(), snapshot .getSubject(), logChannelId, duration ) ); start = null; for ( MetricsDuration duration : durations ) { String key = duration.getSubject() == null ? duration.getDescription() : duration.getDescription() + " / " + duration.getSubject(); MetricsDuration agg = map.get( key ); if ( agg == null ) { map.put( key, duration ); } else { agg.setDuration( agg.getDuration() + duration.getDuration() );
@Override public void mouseDown( MouseEvent event ) { if ( drawAreas == null ) { return; } for ( int i = drawAreas.size() - 1; i >= 0; i-- ) { MetricsDrawArea drawArea = drawAreas.get( i ); if ( drawArea.getArea().contains( event.x, event.y ) ) { MetricsDuration duration = drawArea.getDuration(); if ( duration == null ) { continue; } System.out.println( duration.toString() ); LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( duration.getLogChannelId() ); if ( loggingObject == null ) { return; } System.out.println( loggingObject.getObjectType() + " : " + loggingObject.getObjectName() ); } } } } );
MetricsUtil.getDuration( log.getLogChannelId(), Metrics.METRIC_PLUGIN_REGISTRY_REGISTER_EXTENSIONS_START ); if ( ( log.isDebug() ) && !metricsList.isEmpty() ) { log.logDebug( metricsList.get( 0 ).toString() ); MetricsUtil.getDuration( log.getLogChannelId(), Metrics.METRIC_PLUGIN_REGISTRY_PLUGIN_REGISTRATION_START ); if ( ( log != null ) && ( log.isDebug() ) && !metricsList.isEmpty() ) { log.logDebug( metricsList.get( 0 ).toString() ); if ( ( log != null ) && ( log.isDebug() ) && metricsList != null && !metricsList.isEmpty() ) { for ( MetricsDuration duration : metricsList ) { total += duration.getDuration(); log.logDebug( " - " + duration.toString() + " Total=" + total );
@Override public void mouseDown( MouseEvent event ) { if ( drawAreas == null ) { return; } for ( int i = drawAreas.size() - 1; i >= 0; i-- ) { MetricsDrawArea drawArea = drawAreas.get( i ); if ( drawArea.getArea().contains( event.x, event.y ) ) { MetricsDuration duration = drawArea.getDuration(); if ( duration == null ) { continue; } System.out.println( duration.toString() ); LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( duration.getLogChannelId() ); if ( loggingObject == null ) { continue; } System.out.println( loggingObject.getObjectType() + " : " + loggingObject.getObjectName() ); } } } } );