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

com.hazelcast.internal.metrics.Probe Maven / Gradle / Ivy

There is a newer version: 5.4.0
Show newest version
/*
 * Copyright (c) 2008-2016, Hazelcast, 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 com.hazelcast.internal.metrics;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static com.hazelcast.internal.metrics.ProbeLevel.INFO;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Annotation that can be placed on a field or method of an object to indicate that it should be tracked by the
 * MetricsRegistry when the {@link MetricsRegistry#scanAndRegister(Object, String)} is called.
 *
 * The MetricsRegistry will automatically scan all interfaces and super classes of an object (recursively). So it is possible
 * to define a Probe on e.g. an interface or abstract class.
 *
 * 

Prefer field

* Prefer placing a Probe to a field above a method if the type is a primitive. The {@link java.lang.reflect.Field} * provides access to the actual field without the need for autoboxing. With the {@link java.lang.reflect.Method} a wrapper * object is created when a primitive is returned by the method. Therefor fields produce less garbage than methods. * * A Probe can be placed on field or methods with the following (return) type: *
    *
  1. byte
  2. *
  3. short
  4. *
  5. int
  6. *
  7. float
  8. *
  9. long
  10. *
  11. double
  12. *
  13. {@link java.util.concurrent.atomic.AtomicInteger}
  14. *
  15. {@link java.util.concurrent.atomic.AtomicLong}
  16. *
  17. {@link com.hazelcast.util.counters.Counter}
  18. *
  19. {@link Byte}
  20. *
  21. {@link Short}
  22. *
  23. {@link Integer}
  24. *
  25. {@link Float}
  26. *
  27. {@link Double}
  28. *
  29. {@link java.util.Collection}: it will return the size
  30. *
  31. {@link java.util.Map}: it will return the size
  32. *
  33. {@link java.util.concurrent.Semaphore}: it will return the number of available permits
  34. *
* * If the field or method points to a null reference, it is interpreted as 0. */ @Retention(value = RUNTIME) @Target({FIELD, METHOD }) public @interface Probe { /** * The name of the Probe. By default the name of the field or method is used. * * @return the name of the Probe. */ String name() default ""; /** * Returns the ProbeLevel. * * Using ProbeLevel one can indicate how 'important' this Probe is. This is useful to reduce memory overhead due * to tracking of probes. * * @return the ProbeLevel. */ ProbeLevel level() default INFO; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy