All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.streamnative.pulsar.handlers.kop.schemaregistry.SchemaRegistryStats Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2019 - 2024 StreamNative, Inc.. All Rights Reserved.
 */
/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.streamnative.pulsar.handlers.kop.schemaregistry;

import com.google.common.annotations.VisibleForTesting;
import lombok.Builder;
import lombok.Getter;
import org.apache.bookkeeper.stats.Counter;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.stats.annotations.StatsDoc;

@Builder
@Getter
public class SchemaRegistryStats {

    public static final String SR_API_SUCCESS_COUNT = "SR_API_SUCCESS_COUNT";
    public static final String SR_API_FAILURE_COUNT = "SR_API_FAILURE_COUNT";
    public static final String SR_REGISTERED_COUNT = "SR_REGISTERED_COUNT";
    public static final String SR_DELETED_COUNT = "SR_DELETED_COUNT";
    public static final String SR_AVRO_SCHEMAS_CREATED = "SR_AVRO_SCHEMAS_CREATED";
    public static final String SR_AVRO_SCHEMAS_DELETED = "SR_AVRO_SCHEMAS_DELETED";
    public static final String SR_JSON_SCHEMAS_CREATED = "SR_JSON_SCHEMAS_CREATED";
    public static final String SR_JSON_SCHEMAS_DELETED = "SR_JSON_SCHEMAS_DELETED";
    public static final String SR_PB_SCHEMAS_CREATED = "SR_PROTOBUF_SCHEMAS_CREATED";
    public static final String SR_PB_SCHEMAS_DELETED = "SR_PROTOBUF_SCHEMAS_DELETED";

    @StatsDoc(
            name = SR_REGISTERED_COUNT,
            help = "Number of registered schemas"
    )
    private final Counter schemasCreated;
    @StatsDoc(
            name = SR_DELETED_COUNT,
            help = "Number of deleted schemas"
    )
    private final Counter schemasDeleted;
    @StatsDoc(
            name = SR_API_SUCCESS_COUNT,
            help = "Number of successful API calls"
    )
    private final Counter apiCallsSuccess;
    @StatsDoc(
            name = SR_API_FAILURE_COUNT,
            help = "Number of failed API calls"
    )
    private final Counter apiCallsFailure;
    @StatsDoc(
            name = SR_AVRO_SCHEMAS_CREATED,
            help = "Number of registered Avro schemas"
    )
    private final Counter avroSchemasCreated;
    @StatsDoc(
            name = SR_AVRO_SCHEMAS_DELETED,
            help = "Number of deleted Avro schemas"
    )
    private final Counter avroSchemasDeleted;
    @StatsDoc(
            name = SR_JSON_SCHEMAS_CREATED,
            help = "Number of registered JSON schemas"
    )
    private final Counter jsonSchemasCreated;
    @StatsDoc(
            name = SR_JSON_SCHEMAS_DELETED,
            help = "Number of deleted JSON schemas"
    )
    private final Counter jsonSchemasDeleted;
    @StatsDoc(
            name = SR_PB_SCHEMAS_CREATED,
            help = "Number of registered Protobuf schemas"
    )
    private final Counter protobufSchemasCreated;
    @StatsDoc(
            name = SR_PB_SCHEMAS_DELETED,
            help = "Number of deleted Protobuf schemas"
    )
    private final Counter protobufSchemasDeleted;

    // only for testing
    @VisibleForTesting
    public static SchemaRegistryStats nullSchemaRegistryStats() {
        return SchemaRegistryStats.builder()
                .schemasCreated(NullStatsLogger.INSTANCE.getCounter(""))
                .schemasDeleted(NullStatsLogger.INSTANCE.getCounter(""))
                .apiCallsSuccess(NullStatsLogger.INSTANCE.getCounter(""))
                .apiCallsFailure(NullStatsLogger.INSTANCE.getCounter(""))
                .avroSchemasCreated(NullStatsLogger.INSTANCE.getCounter(""))
                .avroSchemasDeleted(NullStatsLogger.INSTANCE.getCounter(""))
                .jsonSchemasCreated(NullStatsLogger.INSTANCE.getCounter(""))
                .jsonSchemasDeleted(NullStatsLogger.INSTANCE.getCounter(""))
                .protobufSchemasCreated(NullStatsLogger.INSTANCE.getCounter(""))
                .protobufSchemasDeleted(NullStatsLogger.INSTANCE.getCounter(""))
                .build();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy