use of wavefront.report.ReportEvent in project java by wavefrontHQ.
the class WavefrontPortUnificationHandler method processLine.
/**
* @param ctx ChannelHandler context (to retrieve remote client's IP in case of errors)
* @param message line being processed
*/
@Override
protected void processLine(final ChannelHandlerContext ctx, @Nonnull String message, @Nullable DataFormat format) {
DataFormat dataFormat = format == null ? DataFormat.autodetect(message) : format;
switch(dataFormat) {
case SOURCE_TAG:
ReportableEntityHandler<ReportSourceTag, SourceTag> sourceTagHandler = sourceTagHandlerSupplier.get();
if (sourceTagHandler == null || sourceTagDecoder == null) {
wavefrontHandler.reject(message, "Port is not configured to accept " + "sourceTag-formatted data!");
return;
}
List<ReportSourceTag> output = new ArrayList<>(1);
try {
sourceTagDecoder.decode(message, output, "dummy");
for (ReportSourceTag tag : output) {
sourceTagHandler.report(tag);
}
} catch (Exception e) {
sourceTagHandler.reject(message, formatErrorMessage("WF-300 Cannot parse sourceTag: \"" + message + "\"", e, ctx));
}
return;
case EVENT:
ReportableEntityHandler<ReportEvent, ReportEvent> eventHandler = eventHandlerSupplier.get();
if (eventHandler == null || eventDecoder == null) {
wavefrontHandler.reject(message, "Port is not configured to accept event data!");
return;
}
List<ReportEvent> events = new ArrayList<>(1);
try {
eventDecoder.decode(message, events, "dummy");
for (ReportEvent event : events) {
eventHandler.report(event);
}
} catch (Exception e) {
eventHandler.reject(message, formatErrorMessage("WF-300 Cannot parse event: \"" + message + "\"", e, ctx));
}
return;
case SPAN:
ReportableEntityHandler<Span, String> spanHandler = spanHandlerSupplier.get();
if (spanHandler == null || spanDecoder == null) {
wavefrontHandler.reject(message, "Port is not configured to accept " + "tracing data (spans)!");
return;
}
message = annotator == null ? message : annotator.apply(ctx, message);
receivedSpansTotal.get().inc();
preprocessAndHandleSpan(message, spanDecoder, spanHandler, spanHandler::report, preprocessorSupplier, ctx, span -> sampler.sample(span, discardedSpansBySampler.get()));
return;
case SPAN_LOG:
if (isFeatureDisabled(spanLogsDisabled, SPANLOGS_DISABLED, discardedSpanLogs.get()))
return;
ReportableEntityHandler<SpanLogs, String> spanLogsHandler = spanLogsHandlerSupplier.get();
if (spanLogsHandler == null || spanLogsDecoder == null || spanDecoder == null) {
wavefrontHandler.reject(message, "Port is not configured to accept " + "tracing data (span logs)!");
return;
}
handleSpanLogs(message, spanLogsDecoder, spanDecoder, spanLogsHandler, preprocessorSupplier, ctx, span -> sampler.sample(span, discardedSpanLogsBySampler.get()));
return;
case HISTOGRAM:
if (isFeatureDisabled(histogramDisabled, HISTO_DISABLED, discardedHistograms.get()))
return;
ReportableEntityHandler<ReportPoint, String> histogramHandler = histogramHandlerSupplier.get();
if (histogramHandler == null || histogramDecoder == null) {
wavefrontHandler.reject(message, "Port is not configured to accept " + "histogram-formatted data!");
return;
}
message = annotator == null ? message : annotator.apply(ctx, message);
preprocessAndHandlePoint(message, histogramDecoder, histogramHandler, preprocessorSupplier, ctx, "histogram");
return;
default:
message = annotator == null ? message : annotator.apply(ctx, message);
preprocessAndHandlePoint(message, wavefrontDecoder, wavefrontHandler, preprocessorSupplier, ctx, "metric");
}
}
use of wavefront.report.ReportEvent in project java by wavefrontHQ.
the class EventHandlerImpl method reportInternal.
@Override
protected void reportInternal(ReportEvent event) {
if (!annotationKeysAreValid(event)) {
throw new IllegalArgumentException("WF-401: Event annotation key has illegal characters.");
}
getTask().add(new Event(event));
getReceivedCounter().inc();
if (validItemsLogger != null && validItemsLogger.isLoggable(Level.FINEST)) {
validItemsLogger.info(EVENT_SERIALIZER.apply(event));
}
}
Aggregations