This documentation has an index for AI agents at /llms.txt. A Markdown version of this page is available at https://explorer.opentelemetry.io/java-agent/instrumentation/servlet-3.0.md.

Servlet

OpenTelemetry Java agent instrumentation

This instrumentation enables HTTP server spans and metrics for Java Servlet API.

  • Name: servlet-3.0
  • Scope: io.opentelemetry.servlet-3.0
  • Target versions: javax.servlet:javax.servlet-api:[3.0,)
  • Library: https://javaee.github.io/servlet-spec/

Telemetry

When default

Metrics

MetricInstrumentTypeUnitDescription
http.server.request.durationhistogramHISTOGRAMsDuration of HTTP server requests.
MetricAttributes
http.server.request.durationhttp.request.method (STRING), http.response.status_code (LONG), http.route (STRING), network.protocol.version (STRING), url.scheme (STRING)

Spans

Span kindAttributes
INTERNALcode.function (STRING), code.namespace (STRING)
SERVERclient.address (STRING), error.type (STRING), http.request.method (STRING), http.request.method_original (STRING), http.response.status_code (LONG), http.route (STRING), network.peer.address (STRING), network.peer.port (LONG), network.protocol.version (STRING), server.address (STRING), server.port (LONG), url.path (STRING), url.query (STRING), url.scheme (STRING), user_agent.original (STRING)

Configuration

OptionTypeDefaultDescription
otel.experimental.javascript-snippetstringExperimental setting to inject a JavaScript snippet into HTML responses after the opening <head> tag.
otel.instrumentation.servlet.experimental-span-attributesbooleanfalseEnables capturing the experimental servlet.timeout span attribute.
otel.instrumentation.servlet.experimental.capture-request-parameterslistDeprecated include-only alias for otel.instrumentation.servlet.experimental.request-parameters.included. It does not support glob patterns: an entry containing * or ? is ignored with a warning, and every other entry is matched as a literal request parameter name. It may be removed in the next minor release.
otel.instrumentation.servlet.experimental.request-parameters.excludedlistA comma-separated list of case-sensitive request parameter name patterns to exclude from span attributes. ? matches one character and * matches zero or more characters. Excluded patterns take precedence over included patterns. No request parameters are captured unless an included or excluded pattern is configured; configuring only excluded patterns captures all request parameters that do not match them, which may expose sensitive information.
otel.instrumentation.servlet.experimental.request-parameters.includedlistA comma-separated list of case-sensitive request parameter name patterns to capture as span attributes. ? matches one character and * matches zero or more characters. Excluded patterns take precedence over included patterns. No request parameters are captured unless an included or excluded pattern is configured; configuring only excluded patterns captures all request parameters that do not match them, which may expose sensitive information.
otel.instrumentation.servlet.experimental.trace-id-request-attribute.enabledbooleantrueEnables adding the trace ID and span ID as request attributes for downstream servlet access.

Data

  • JSON (latest): /data/javaagent/instrumentations/servlet-3.0/latest.json
  • JSON (pinned): /data/javaagent/instrumentations/servlet-3.0/servlet-3.0-4e4d1bfff090.json
  • Explore: /java-agent/instrumentation/servlet-3.0