### Question:
GpuMetrics implements MeterBinder { @Override public void bindTo(@NonNull MeterRegistry registry) { checkReturn(nvmlInit_v2()); int[] resultArr = new int[1]; checkReturn(nvmlSystemGetCudaDriverVersion(resultArr)); StringBuilder baseName = new StringBuilder(); baseName.append("pipeline.cuda.device."); int deviceCount; checkReturn(nvmlDeviceGetCount_v2(resultArr)); deviceCount = resultArr[0]; for (int i = 0; i < deviceCount; i++) { nvmlDevice_st device = new nvmlDevice_st(); nvmlDeviceGetHandleByIndex_v2(i, device); StringBuilder deviceStats = new StringBuilder(); deviceStats.append(baseName); deviceStats.append(resultArr[0]); resultArr[0] = 0; nvmlProcessInfo_t processInfoT = new nvmlProcessInfo_t(); int result = nvmlDeviceGetGraphicsRunningProcesses(device, resultArr, processInfoT); if (result != NVML_ERROR_INSUFFICIENT_SIZE && result != NVML_SUCCESS) { throw new IllegalStateException("Number of running processes query failed " + nvmlErrorString(result)); } final int numRunningProcesses = resultArr[0]; Gauge.builder(".processes.count", () -> numRunningProcesses) .tags(tags) .description("Number of running processes on the gpu") .baseUnit(deviceStats.toString()) .register(registry); nvmlUtilization_t nvmlUtilizationT = new nvmlUtilization_t(); checkReturn(nvmlDeviceGetUtilizationRates(device, nvmlUtilizationT)); final int percentMemoryUsed = nvmlUtilizationT.memory(); Gauge.builder(".percent.memory.used", () -> percentMemoryUsed) .tags(tags) .description("Percent memory used for device by index") .baseUnit(deviceStats.toString()) .register(registry); final int percentKernelExecuted = nvmlUtilizationT.gpu(); Gauge.builder(".percent.kernel.executed", () -> percentKernelExecuted) .tags(tags) .description("Percent time kernel was being executed on gpu") .baseUnit(deviceStats.toString()) .register(registry); nvmlMemory_t memory = new nvmlMemory_t(); nvmlDeviceGetMemoryInfo(device, memory); final long deviceUsedMemoryInBytes = memory.used(); Gauge.builder(".memory.used", () -> deviceUsedMemoryInBytes) .tags(tags) .description("Device memory used in bytes") .baseUnit(deviceStats.toString()) .register(registry); checkReturn(nvmlDeviceGetTemperature(device,NVML_TEMPERATURE_GPU,resultArr)); final int tempC = resultArr[0]; Gauge.builder(".temp.celsius",() -> tempC) .tags(tags) .description("Temperature of gpu in celsius") .baseUnit(deviceStats.toString()) .register(registry); final int tempF = tempC * 9 / 5 + 32; Gauge.builder(".temp.farenheit", () -> tempF) .tags(tags) .description("Temperature of gpu in farenheit") .baseUnit(deviceStats.toString()) .register(registry); checkReturn(nvmlDeviceGetPowerUsage(device, resultArr)); final int powerUsedMilliWatts = resultArr[0]; Gauge.builder(".power.used.milliwatts", () -> powerUsedMilliWatts) .tags(tags) .description("Power used by gpu in milliwatts") .baseUnit(deviceStats.toString()) .register(registry); } nvmlShutdown(); } GpuMetrics();  GpuMetrics(Iterable<Tag> tags); @Override void bindTo(@NonNull MeterRegistry registry);  }### Answer:
@Test public void testMetrics() { GpuMetrics gpuMetrics = new GpuMetrics(); SimpleMeterRegistry simpleMeterRegistry = new SimpleMeterRegistry(); gpuMetrics.bindTo(simpleMeterRegistry); }