Class MetricsCollector
java.lang.Object
java.util.concurrent.SubmissionPublisher<RECORD>
io.mishmash.opentelemetry.server.collector.AbstractCollector<io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest,io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse,MetricDataPoint>
io.mishmash.opentelemetry.server.collector.MetricsCollector
- All Implemented Interfaces:
AutoCloseable,Flow.Publisher<MetricDataPoint>
public class MetricsCollector
extends AbstractCollector<io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest,io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse,MetricDataPoint>
Processes incoming OpenTelemetry metrics packets - extracts all
data points of all metrics contained in a packet and queues them
to all
MetricsSubscribers.
Also notifies the client on potential errors.-
Field Summary
Fields inherited from class io.mishmash.opentelemetry.server.collector.AbstractCollector
DEFAULT_CLOSE_TIMETOUT_SEC, DEFAULT_MAX_BODY_LEN, DEFAULT_SUBSCRIBER_QUEUE_SIZE, DEFAULT_TIMEOUT_SEC, HTTP_BAD_GATEWAY, HTTP_BAD_REQUEST, HTTP_EXPECTATION_FAILED, HTTP_GATEWAY_TIMEOUT, HTTP_INTERNAL_ERROR, HTTP_OK, HTTP_PAYLOAD_TOO_LARGE, HTTP_SERVICE_UNAVAILABLE, HTTP_TOO_MANY_REQUESTS -
Constructor Summary
ConstructorsConstructorDescriptionMetricsCollector(io.grpc.MethodDescriptor<io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest, io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse> exportMethod, Instrumentation otel) Creates a new metrics collector to be added to a Vert.x routing context. -
Method Summary
Modifier and TypeMethodDescriptionio.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponsegetBatchResponse(io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest request, Batch<MetricDataPoint> completedBatch, String transport, String encoding) Called to compute the correct response to the client after an entire batch (or packet) of OpenTelemetry logs, metrics or spans has been processed.loadBatch(io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest request, String transport, String encoding, io.opentelemetry.context.Context otelContext) Processes incoming packets (or batches) - extracts and publishes the contained OpenTelemetry metric data points (one by one) to allMetricsSubscribers.protected booleanofferDataPoint(Batch<MetricDataPoint> batch, MetricDataPoint m, String uuid, String transport, String encoding) Actually sumbit a data point to all subscribers.protected StringReturns "metrics" as the signal type for this collector's own telemetry.Methods inherited from class io.mishmash.opentelemetry.server.collector.AbstractCollector
addDroppedRequestItems, addFailedRequests, addGrpcFailedRequests, addHttpFailedRequests, addPartiallySucceededRequests, addRequestItems, addRequestsInProcess, addSucceededRequests, bind, bind, checkBody, checkContentType, checkSubscribers, close, closeExceptionally, getErrorCode, getInstrumentation, getOtelContext, getOtelRequest, getOtelResponse, handle, httpEncoding, initInstrumentation, isError, isJsonContent, isJsonRequest, isProtobufContent, isRetryable, isRetryable, parseContentLengthHeader, parseHttpJson, parseHttpProtobuf, parseHttpRequest, publish, publish, respond, respond, responseToJson, responseToProtobuf, setErrorCode, setJsonRequest, setOtelContext, setOtelRequest, setOtelResponseMethods inherited from class java.util.concurrent.SubmissionPublisher
consume, estimateMaximumLag, estimateMinimumDemand, getClosedException, getExecutor, getMaxBufferCapacity, getNumberOfSubscribers, getSubscribers, hasSubscribers, isClosed, isSubscribed, offer, offer, submit, subscribe
-
Constructor Details
-
MetricsCollector
public MetricsCollector(io.grpc.MethodDescriptor<io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest, io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse> exportMethod, Instrumentation otel) Creates a new metrics collector to be added to a Vert.x routing context.- Parameters:
exportMethod- the gRPC method to be attached tootel- a helper for own telemetry needs
-
-
Method Details
-
loadBatch
public Batch<MetricDataPoint> loadBatch(io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest request, String transport, String encoding, io.opentelemetry.context.Context otelContext) Processes incoming packets (or batches) - extracts and publishes the contained OpenTelemetry metric data points (one by one) to allMetricsSubscribers.- Specified by:
loadBatchin classAbstractCollector<io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest,io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse, MetricDataPoint> - Parameters:
request- the client's OTLP requesttransport- the OTLP transport - "grpc" or "http"encoding- the OTLP encoding - "protobuf" or "json"otelContext- theContextused for own telemetry- Returns:
- a new
Batchwith all items of the request
-
offerDataPoint
protected boolean offerDataPoint(Batch<MetricDataPoint> batch, MetricDataPoint m, String uuid, String transport, String encoding) Actually sumbit a data point to all subscribers.- Parameters:
batch- the batchm- the data pointuuid- id of the batchtransport- OTLP transport usedencoding- OTLP transport encoding used- Returns:
- true if successful
-
getBatchResponse
public io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse getBatchResponse(io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest request, Batch<MetricDataPoint> completedBatch, String transport, String encoding) Called to compute the correct response to the client after an entire batch (or packet) of OpenTelemetry logs, metrics or spans has been processed.- Specified by:
getBatchResponsein classAbstractCollector<io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest,io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse, MetricDataPoint> - Parameters:
request- the original request from the clientcompletedBatch- the completed batch of recordstransport- the OTLP transport used - "grpc" or "http"encoding- - the OTLP encoding - "protobuf" or "json"- Returns:
- the correct OTLP reposne to be sent back to the client
-
telemetrySignalType
Returns "metrics" as the signal type for this collector's own telemetry.- Specified by:
telemetrySignalTypein classAbstractCollector<io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest,io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse, MetricDataPoint> - Returns:
- the signal type
-