io.micrometer.core.instrument.internal.DefaultMeter Java Examples

The following examples show how to use io.micrometer.core.instrument.internal.DefaultMeter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AtlasMeterRegistry.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<io.micrometer.core.instrument.Measurement> measurements) {
    Id spectatorId = spectatorId(id);
    com.netflix.spectator.api.AbstractMeter<Id> spectatorMeter = new com.netflix.spectator.api.AbstractMeter<Id>(registry.clock(), spectatorId, spectatorId) {
        @Override
        public Iterable<com.netflix.spectator.api.Measurement> measure() {
            return stream(measurements.spliterator(), false)
                    .map(m -> {
                        com.netflix.spectator.api.Statistic stat = AtlasUtils.toSpectatorStatistic(m.getStatistic());
                        Id idWithStat = stat == null ? id : id.withTag("statistic", stat.toString());
                        return new com.netflix.spectator.api.Measurement(idWithStat, clock.wallTime(), m.getValue());
                    })
                    .collect(toList());
        }
    };
    registry.register(spectatorMeter);
    return new DefaultMeter(id, type, measurements);
}
 
Example #2
Source File: StatsdMeterRegistry.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    measurements.forEach(ms -> {
        StatsdLineBuilder line = lineBuilder(id);
        Statistic stat = ms.getStatistic();
        switch (stat) {
            case COUNT:
            case TOTAL:
            case TOTAL_TIME:
                pollableMeters.put(id.withTag(stat), () -> fluxSink.next(line.count((long) ms.getValue(), stat)));
                break;
            case VALUE:
            case ACTIVE_TASKS:
            case DURATION:
            case UNKNOWN:
                pollableMeters.put(id.withTag(stat), () -> fluxSink.next(line.gauge(ms.getValue(), stat)));
                break;
        }
    });
    return new DefaultMeter(id, type, measurements);
}
 
Example #3
Source File: SkywalkingMeterRegistry.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    final MeterId meterId = convertId(id);
    final String baseName = meterId.getName();

    measurements.forEach(m -> {
        String meterName = baseName;
        boolean isCounter = false;
        switch (m.getStatistic()) {
            case TOTAL:
            case TOTAL_TIME:
                meterName = baseName + "_sum";
                isCounter = true;
                break;
            case COUNT:
                isCounter = true;
                break;
            case MAX:
                meterName = baseName + "_max";
                break;
            case ACTIVE_TASKS:
                meterName = baseName + "_active_count";
                break;
            case DURATION:
                meterName = baseName + "_duration_sum";
                break;
        }

        if (isCounter) {
            new SkywalkingCustomCounter.Builder(meterId.copyTo(meterName, MeterId.MeterType.COUNTER), m, config).build();
        } else {
            MeterFactory.gauge(meterId.copyTo(meterName, MeterId.MeterType.GAUGE), () -> m.getValue()).build();
        }
    });

    return new DefaultMeter(id, type, measurements);
}
 
Example #4
Source File: DropwizardMeterRegistry.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    measurements.forEach(ms -> registry.register(hierarchicalName(id.withTag(ms.getStatistic())), (Gauge<Double>) ms::getValue));
    return new DefaultMeter(id, type, measurements);
}
 
Example #5
Source File: StepMeterRegistry.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    return new DefaultMeter(id, type, measurements);
}
 
Example #6
Source File: SimpleMeterRegistry.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    return new DefaultMeter(id, type, measurements);
}
 
Example #7
Source File: OpenTSDBMeterRegistry.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    return new DefaultMeter(id, type, measurements);
}
 
Example #8
Source File: WavefrontMeterRegistry.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    return new DefaultMeter(id, type, measurements);
}
 
Example #9
Source File: PrometheusMeterRegistry.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(Meter.Id id, Meter.Type type, Iterable<Measurement> measurements) {
    Collector.Type promType = Collector.Type.UNTYPED;
    switch (type) {
        case COUNTER:
            promType = Collector.Type.COUNTER;
            break;
        case GAUGE:
            promType = Collector.Type.GAUGE;
            break;
        case DISTRIBUTION_SUMMARY:
        case TIMER:
            promType = Collector.Type.SUMMARY;
            break;
    }

    final Collector.Type finalPromType = promType;

    applyToCollector(id, (collector) -> {
        List<String> tagValues = tagValues(id);
        collector.add(tagValues, (conventionName, tagKeys) -> {
            List<String> statKeys = new LinkedList<>(tagKeys);
            statKeys.add("statistic");

            return Stream.of(new MicrometerCollector.Family(finalPromType, conventionName,
                    stream(measurements.spliterator(), false)
                            .map(m -> {
                                List<String> statValues = new LinkedList<>(tagValues);
                                statValues.add(m.getStatistic().toString());

                                String name = conventionName;
                                switch (m.getStatistic()) {
                                    case TOTAL:
                                    case TOTAL_TIME:
                                        name += "_sum";
                                        break;
                                    case MAX:
                                        name += "_max";
                                        break;
                                    case ACTIVE_TASKS:
                                        name += "_active_count";
                                        break;
                                    case DURATION:
                                        name += "_duration_sum";
                                        break;
                                }

                                return new Collector.MetricFamilySamples.Sample(name, statKeys, statValues, m.getValue());
                            })));
        });
    });

    return new DefaultMeter(id, type, measurements);
}
 
Example #10
Source File: DefaultDestinationPublishingMeterRegistry.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(Id id, Type type, Iterable<Measurement> measurements) {
	return new DefaultMeter(id, type, measurements);
}