Package io.opentelemetry.sdk.metrics
Class SdkMeterProviderBuilder
java.lang.Object
io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder
Builder class for the
SdkMeterProvider.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns a newSdkMeterProviderbuilt with the configuration of thisSdkMeterProviderBuilder.Returns a newSdkMeterProviderbuilt with the configuration of thisSdkMeterProviderBuilderand registers it as the globalMeterProvider.Registers aMetricReaderfor this SDK.registerView(InstrumentSelector selector, View view) Register a view with the givenInstrumentSelector.setClock(io.opentelemetry.sdk.common.Clock clock) Assign aClock.setExemplarFilter(ExemplarFilter filter) Assign anExemplarFilterfor all metrics created by Meters.setMinimumCollectionInterval(Duration duration) Configure the minimum duration between synchronous collections.setResource(io.opentelemetry.sdk.resources.Resource resource) Assign aResourceto be attached to all metrics created by Meters.
-
Method Details
-
setClock
Assign aClock.- Parameters:
clock- The clock to use for all temporal needs.- Returns:
- this
-
setResource
Assign aResourceto be attached to all metrics created by Meters.- Parameters:
resource- A Resource implementation.- Returns:
- this
-
setExemplarFilter
Assign anExemplarFilterfor all metrics created by Meters.- Returns:
- this
-
registerView
Register a view with the givenInstrumentSelector.Example on how to register a view:
// create a SdkMeterProviderBuilder SdkMeterProviderBuilder meterProviderBuilder = SdkMeterProvider.builder(); // create a selector to select which instruments to customize: InstrumentSelector instrumentSelector = InstrumentSelector.builder() .setInstrumentType(InstrumentType.COUNTER) .build(); // create a specification of how you want the metrics aggregated: AggregatorFactory aggregatorFactory = AggregatorFactory.minMaxSumCount(); // register the view with the SdkMeterProviderBuilder meterProviderBuilder.registerView(instrumentSelector, View.builder() .setAggregatorFactory(aggregatorFactory).build());- Since:
- 1.1.0
-
buildAndRegisterGlobal
Returns a newSdkMeterProviderbuilt with the configuration of thisSdkMeterProviderBuilderand registers it as the globalMeterProvider.- See Also:
-
GlobalMeterProvider
-
registerMetricReader
Registers aMetricReaderfor this SDK.- Parameters:
reader- The factory for a reader of metrics.- Returns:
- this
-
setMinimumCollectionInterval
Configure the minimum duration between synchronous collections. If collections occur more frequently than this, synchronous collection will be suppressed.- Parameters:
duration- The duration.- Returns:
- this
-
build
Returns a newSdkMeterProviderbuilt with the configuration of thisSdkMeterProviderBuilder. This provider is not registered as the globalMeterProvider. It is recommended that you register one provider usingbuildAndRegisterGlobal()for use by instrumentation when that requires access to a global instance ofMeterProvider.- See Also:
-
GlobalMeterProvider
-