Class JavaHttpServerTelemetryBuilder
java.lang.Object
io.opentelemetry.instrumentation.javahttpserver.JavaHttpServerTelemetryBuilder
-
Method Summary
Modifier and TypeMethodDescriptionaddAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<com.sun.net.httpserver.HttpExchange, com.sun.net.httpserver.HttpExchange> attributesExtractor) Adds an extraAttributesExtractorto invoke to set attributes to instrumented items.build()setCapturedRequestHeaders(Collection<String> requestHeaders) Configures the HTTP server request headers that will be captured as span attributes.setCapturedResponseHeaders(Collection<String> responseHeaders) Configures the HTTP server response headers that will be captured as span attributes.setKnownMethods(Collection<String> knownMethods) Configures the instrumentation to recognize an alternative set of HTTP request methods.setSpanNameExtractor(Function<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<? super com.sun.net.httpserver.HttpExchange>, ? extends io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<? super com.sun.net.httpserver.HttpExchange>> serverSpanNameExtractor) Sets custom serverSpanNameExtractorvia transform function.setStatusExtractor(Function<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<? super com.sun.net.httpserver.HttpExchange, ? super com.sun.net.httpserver.HttpExchange>, ? extends io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<? super com.sun.net.httpserver.HttpExchange, ? super com.sun.net.httpserver.HttpExchange>> statusExtractor) Sets the status extractor for server spans.
-
Method Details
-
setStatusExtractor
@CanIgnoreReturnValue public JavaHttpServerTelemetryBuilder setStatusExtractor(Function<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<? super com.sun.net.httpserver.HttpExchange, ? super com.sun.net.httpserver.HttpExchange>, ? extends io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<? super com.sun.net.httpserver.HttpExchange, ? super com.sun.net.httpserver.HttpExchange>> statusExtractor) Sets the status extractor for server spans. -
addAttributesExtractor
@CanIgnoreReturnValue public JavaHttpServerTelemetryBuilder addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<com.sun.net.httpserver.HttpExchange, com.sun.net.httpserver.HttpExchange> attributesExtractor) Adds an extraAttributesExtractorto invoke to set attributes to instrumented items. TheAttributesExtractorwill be executed after all default extractors. -
setCapturedRequestHeaders
@CanIgnoreReturnValue public JavaHttpServerTelemetryBuilder setCapturedRequestHeaders(Collection<String> requestHeaders) Configures the HTTP server request headers that will be captured as span attributes.- Parameters:
requestHeaders- A list of HTTP header names.
-
setCapturedResponseHeaders
@CanIgnoreReturnValue public JavaHttpServerTelemetryBuilder setCapturedResponseHeaders(Collection<String> responseHeaders) Configures the HTTP server response headers that will be captured as span attributes.- Parameters:
responseHeaders- A list of HTTP header names.
-
setKnownMethods
@CanIgnoreReturnValue public JavaHttpServerTelemetryBuilder setKnownMethods(Collection<String> knownMethods) Configures the instrumentation to recognize an alternative set of HTTP request methods.By default, this instrumentation defines "known" methods as the ones listed in RFC9110 and the PATCH method defined in RFC5789.
Note: calling this method overrides the default known method sets completely; it does not supplement it.
- Parameters:
knownMethods- A set of recognized HTTP request methods.- See Also:
-
setSpanNameExtractor
@CanIgnoreReturnValue public JavaHttpServerTelemetryBuilder setSpanNameExtractor(Function<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<? super com.sun.net.httpserver.HttpExchange>, ? extends io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<? super com.sun.net.httpserver.HttpExchange>> serverSpanNameExtractor) Sets custom serverSpanNameExtractorvia transform function. -
build
-