Class OpenTelemetryMetricsCollector.Builder

java.lang.Object
com.pyranid.otel.OpenTelemetryMetricsCollector.Builder
Enclosing class:
OpenTelemetryMetricsCollector

@NotThreadSafe public static final class OpenTelemetryMetricsCollector.Builder extends Object
Builder used to construct instances of OpenTelemetryMetricsCollector.
Since:
1.0.0
Author:
Mark Allen
  • Method Details

    • meter

      public @NonNull OpenTelemetryMetricsCollector.Builder meter(@NonNull io.opentelemetry.api.metrics.Meter meter)
      Sets a specific meter to use for metric instruments.
      Parameters:
      meter - the meter to use
      Returns:
      this builder
    • openTelemetry

      public @NonNull OpenTelemetryMetricsCollector.Builder openTelemetry(@NonNull io.opentelemetry.api.OpenTelemetry openTelemetry)
      Sets the OpenTelemetry API object used to construct a meter if meter(Meter) is not set.
      Parameters:
      openTelemetry - the OpenTelemetry instance
      Returns:
      this builder
    • instrumentationName

      public @NonNull OpenTelemetryMetricsCollector.Builder instrumentationName(@NonNull String instrumentationName)
      Sets the instrumentation scope name to use when constructing a meter.
      Parameters:
      instrumentationName - the instrumentation scope name
      Returns:
      this builder
    • instrumentationVersion

      public @NonNull OpenTelemetryMetricsCollector.Builder instrumentationVersion(@Nullable String instrumentationVersion)
      Sets an optional instrumentation scope version to use when constructing a meter.
      Parameters:
      instrumentationVersion - the instrumentation scope version, or null
      Returns:
      this builder
    • poolName

      public @NonNull OpenTelemetryMetricsCollector.Builder poolName(@Nullable String poolName)
      Sets the database connection pool name to emit as db.client.connection.pool.name.

      When unset or null, db.client.connection.wait_time and db.client.connection.use_time are not emitted, and notification metrics omit the pool-name attribute.

      Parameters:
      poolName - pool name, or null
      Returns:
      this builder
    • namespace

      public @NonNull OpenTelemetryMetricsCollector.Builder namespace(@Nullable String namespace)
      Sets the logical database namespace to emit as db.namespace.

      No JDBC metadata lookup is performed. When unset or null, the attribute is omitted.

      Parameters:
      namespace - logical database namespace, or null
      Returns:
      this builder
    • recordCollectionName

      public @NonNull OpenTelemetryMetricsCollector.Builder recordCollectionName(@NonNull Boolean recordCollectionName)
      Controls whether parsed collection/table names are emitted as db.collection.name.

      The default is false. When enabled, the flag applies consistently to db.client.operation.duration and db.client.response.returned_rows.

      Parameters:
      recordCollectionName - whether to record collection/table names
      Returns:
      this builder
    • recordFullSqlState

      public @NonNull OpenTelemetryMetricsCollector.Builder recordFullSqlState(@NonNull Boolean recordFullSqlState)
      Controls whether full SQLSTATE values are emitted as db.response.status_code.

      The default is true. Set this to false to record only the two-character SQLSTATE class.

      Parameters:
      recordFullSqlState - whether to record full SQLSTATE values
      Returns:
      this builder
    • build

      Builds the collector.
      Returns:
      the collector instance