Class DbServerTarget

java.lang.Object
io.opentelemetry.instrumentation.api.incubator.semconv.db.internal.DbServerTarget

public abstract class DbServerTarget extends Object
A database endpoint set rendered as an address and a port.

A target usually names the logical server a database client was configured to talk to, rendered as server.address and server.port. Such a target stays the same across routing, node selection, and retries, so it is derived from client configuration rather than from the endpoint that served an individual operation.

An instrumentation that knows which endpoint served an individual operation renders that one endpoint the same way and reports it as network.peer.address and network.peer.port.

This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

  • Method Details

    • create

      public static DbServerTarget create(String address, @Nullable Integer port)
      Creates a target from already parsed and sanitized attribute values without further normalization. Use builder() when collecting raw endpoints.
    • builder

      public static DbServerTargetBuilder builder(int defaultPort)
      Returns a builder for a target whose endpoints listen on defaultPort unless they are configured otherwise.
    • builder

      public static DbServerTargetBuilder builder()
      Returns a builder for a target whose default port is unknown. Endpoints without configured ports are kept without ports.
    • unixSocket

      @Nullable public static DbServerTarget unixSocket(@Nullable String path)
      Returns a target for an already-extracted Unix socket path, or null when the path is invalid. Accepted paths are preserved verbatim and are not parsed as URIs or connection strings.
    • getAddress

      public abstract String getAddress()
      Returns the value for server.address, or for network.peer.address.
    • getPort

      @Nullable public abstract Integer getPort()
      Returns the value for server.port, or for network.peer.port, or null when no separate port is reported. Targets built with DbServerTargetBuilder omit default ports and ports already carried inside getAddress().