private static void addActivityMetaData(EventData event, List<Object> metaData) { // adding server host or more correctly monitored server url nullCheckAndAdd(metaData, event.getRequestURL(), ""); nullCheckAndAdd(metaData, event.getRemoteAddress(), ""); nullCheckAndAdd(metaData, event.getContentType(), ""); nullCheckAndAdd(metaData, event.getUserAgent(), ""); nullCheckAndAdd(metaData, PublisherUtil.getHostAddress(), ""); nullCheckAndAdd(metaData, event.getReferer(), ""); }
private static void addStatisticsMetaData(EventData event, List<Object> metaData) { metaData.add(event.getRequestURL()); metaData.add(event.getRemoteAddress()); metaData.add(event.getContentType()); metaData.add(event.getUserAgent()); // adding server host or more correctly monitored server url metaData.add(PublisherUtil.getHostAddress()); metaData.add(event.getReferer()); }
public static void extractInfoFromHttpHeaders(EventData eventData, Object requestProperty) { if (requestProperty instanceof HttpServletRequest) { HttpServletRequest httpServletRequest = (HttpServletRequest) requestProperty; eventData.setRequestURL(httpServletRequest.getRequestURL().toString()); eventData.setRemoteAddress(PublisherUtil.getHostAddress()); eventData.setContentType(httpServletRequest.getContentType()); eventData.setUserAgent( httpServletRequest.getHeader(BAMDataPublisherConstants.HTTP_HEADER_USER_AGENT)); // eventData.setHost(httpServletRequest.getHeader( // BAMDataPublisherConstants.HTTP_HEADER_HOST)); eventData.setReferer( httpServletRequest.getHeader(BAMDataPublisherConstants.HTTP_HEADER_REFERER)); } }
private static void addStatisticEventData(EventData event, List<Object> eventData) { SystemStatistics systemStatistics = event.getSystemStatistics(); eventData.add(systemStatistics.getCurrentInvocationResponseTime()); eventData.add(systemStatistics.getCurrentInvocationRequestCount()); eventData.add(systemStatistics.getCurrentInvocationResponseCount()); eventData.add(systemStatistics.getCurrentInvocationFaultCount()); }
private static StatisticsType findTheStatisticType(EventData event) { StatisticsType statisticsType = null; if ((event.getMessageId() != null) && event.getSystemStatistics() == null) { statisticsType = StatisticsType.ACTIVITY_STATS; } else if (event.getMessageId() == null && event.getSystemStatistics() != null) { statisticsType = StatisticsType.SERVICE_STATS; } else if ((event.getMessageId() != null) && event.getSystemStatistics() != null) { statisticsType = StatisticsType.ACTIVITY_SERVICE_STATS; } return statisticsType; }
private static void addActivityCorrelationData(EventData event, List<Object> correlationData) { correlationData.add(event.getActivityId()); }
private static void addActivityEventData(EventData event, List<Object> eventData) { eventData.add(event.getMessageId()); eventData.add(event.getSOAPHeader()); eventData.add(event.getSOAPBody()); eventData.add(event.getMessageDirection()); }
private static void addCommonEventData(EventData event, List<Object> eventData) { eventData.add(event.getServiceName()); eventData.add(event.getOperationName()); eventData.add(event.getTimestamp().getTime()); }
@Override public Handler.InvocationResponse invoke(MessageContext messageContext) throws AxisFault { SystemStatisticsUtil systemStatisticsUtil; SystemStatistics systemStatistics; try { int tenantID = PublisherUtil.getTenantId(messageContext); Map<Integer, EventConfigNStreamDef> tenantSpecificEventConfig = TenantEventConfigData.getTenantSpecificEventingConfigData(); EventConfigNStreamDef eventingConfigData = tenantSpecificEventConfig.get(tenantID); // Check service stats enable -- if true -- go if (eventingConfigData != null && eventingConfigData.isServiceStatsEnable()) { systemStatisticsUtil = StatisticsServiceComponent.getSystemStatisticsUtil(); systemStatistics = systemStatisticsUtil.getSystemStatistics(messageContext); AxisOperation axisOperation = messageContext.getAxisOperation(); AxisService axisService = messageContext.getAxisService(); if (axisService == null || SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) || axisService.isClientSide()) { return Handler.InvocationResponse.CONTINUE; } MessageContext inMessageContext = MessageContext.getCurrentMessageContext(); // If already set in the activity handlers get it or create new publish data /* PublishData publishData = (PublishData) messageContext.getProperty( BAMDataPublisherConstants.PUBLISH_DATA); EventData eventData; if (publishData != null) { eventData = publishData.getEventData(); } else { publishData = new PublishData(); eventData = new EventData(); Date date = new Date(); Timestamp timestamp = new Timestamp(date.getTime()); eventData.setTimestamp(timestamp); if (axisOperation != null) { eventData.setOperationName(axisOperation.getName().getLocalPart()); } else { eventData.setOperationName(null); } if (axisService != null) { eventData.setServiceName(messageContext.getAxisService().getName()); } else { eventData.setServiceName(null); } //This is a hack for setting message id when sending request to a non-existing operation. if (eventingConfigData.isMsgDumpingEnable() && axisService != null && axisOperation == null) { eventData.setOutMessageId(new ActivityOutHandler().getUniqueId()); } } */ PublishData publishData = new PublishData(); EventData eventData = new EventData(); /* Date date = new Date(); Timestamp timestamp = new Timestamp(date.getTime()); eventData.setTimestamp(timestamp);*/ if (axisOperation != null) { eventData.setOperationName(axisOperation.getName().getLocalPart()); } else { eventData.setOperationName(null); } if (axisService != null) { eventData.setServiceName(messageContext.getAxisService().getName()); } else { eventData.setServiceName(null); } // This is a hack for setting message id when sending request to a non-existing operation. /* if (eventingConfigData.isMsgDumpingEnable() && axisService != null && axisOperation == null) { eventData.setOutMessageId(new ActivityOutHandler().getUniqueId()); }*/ // Skip resetting same info if already set by activity in/out handlers /* if (!eventingConfigData.isMsgDumpingEnable()) { Timestamp timestamp = null; if (inMessageContext != null) { timestamp = new Timestamp(Long.parseLong(inMessageContext.getProperty( StatisticsConstants.REQUEST_RECEIVED_TIME).toString())); Object requestProperty = inMessageContext.getProperty( HTTPConstants.MC_HTTP_SERVLETREQUEST); ServiceAgentUtil.extractInfoFromHttpHeaders(eventData, requestProperty); } else { Date date = new Date(); timestamp = new Timestamp(date.getTime()); } eventData.setTimestamp(timestamp); }*/ Timestamp timestamp = null; if (inMessageContext != null) { timestamp = new Timestamp( Long.parseLong( inMessageContext .getProperty(StatisticsConstants.REQUEST_RECEIVED_TIME) .toString())); Object requestProperty = inMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); ServiceAgentUtil.extractInfoFromHttpHeaders(eventData, requestProperty); } else { Date date = new Date(); timestamp = new Timestamp(date.getTime()); } eventData.setTimestamp(timestamp); eventData.setSystemStatistics(systemStatistics); publishData.setEventData(eventData); // Skip if bam server info already set at activity handlers if (!eventingConfigData.isMsgDumpingEnable()) { BAMServerInfo bamServerInfo = ServiceAgentUtil.addBAMServerInfo(eventingConfigData); publishData.setBamServerInfo(bamServerInfo); } Event event = ServiceAgentUtil.makeEventList(publishData, eventingConfigData); EventPublisher publisher = new EventPublisher(); publisher.publish(event, eventingConfigData); } } catch (Throwable ignore) { log.error( "Error at SystemStatisticsOutHandler. " + "But continuing message processing for message id: " + messageContext.getMessageID(), ignore); } return Handler.InvocationResponse.CONTINUE; }