Skip to content

Commit 32583e9

Browse files
committed
Add remove method to synchronous gauges, counters, updowncounters and histograms
1 parent b544e93 commit 32583e9

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

specification/metrics/api.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,28 @@ weight: 1
3535
+ [Counter creation](#counter-creation)
3636
+ [Counter operations](#counter-operations)
3737
- [Add](#add)
38+
- [Remove](#remove)
3839
* [Asynchronous Counter](#asynchronous-counter)
3940
+ [Asynchronous Counter creation](#asynchronous-counter-creation)
4041
+ [Asynchronous Counter operations](#asynchronous-counter-operations)
4142
* [Histogram](#histogram)
4243
+ [Histogram creation](#histogram-creation)
4344
+ [Histogram operations](#histogram-operations)
4445
- [Record](#record)
46+
- [Remove](#remove-1)
4547
* [Gauge](#gauge)
4648
+ [Gauge creation](#gauge-creation)
4749
+ [Gauge operations](#gauge-operations)
4850
- [Record](#record-1)
51+
- [Remove](#remove-2)
4952
* [Asynchronous Gauge](#asynchronous-gauge)
5053
+ [Asynchronous Gauge creation](#asynchronous-gauge-creation)
5154
+ [Asynchronous Gauge operations](#asynchronous-gauge-operations)
5255
* [UpDownCounter](#updowncounter)
5356
+ [UpDownCounter creation](#updowncounter-creation)
5457
+ [UpDownCounter operations](#updowncounter-operations)
5558
- [Add](#add-1)
59+
- [Remove](#remove-3)
5660
* [Asynchronous UpDownCounter](#asynchronous-updowncounter)
5761
+ [Asynchronous UpDownCounter creation](#asynchronous-updowncounter-creation)
5862
+ [Asynchronous UpDownCounter operations](#asynchronous-updowncounter-operations)
@@ -598,6 +602,37 @@ counterPowerUsed.Add(13.5, new PowerConsumption { customer = "Tom" });
598602
counterPowerUsed.Add(200, new PowerConsumption { customer = "Jerry" }, ("is_green_energy", true));
599603
```
600604

605+
##### Remove
606+
607+
Unregister the Counter. It will no longer be reported.
608+
609+
This API SHOULD NOT return a value (it MAY return a dummy value if required by
610+
certain programming languages or systems, for example `null`, `undefined`).
611+
612+
This API MUST accept the following parameter:
613+
614+
* [Attributes](../common/README.md#attribute) to identify the Counter.
615+
616+
Users can provide attributes to identify the Counter.
617+
This API MUST be structured to accept a variable number of attributes, including none.
618+
619+
620+
```python
621+
# Python
622+
623+
exception_counter.remove({"exception_type": "IOError", "handled_by_user": True})
624+
exception_counter.remove(exception_type="IOError", handled_by_user=True)
625+
```
626+
627+
```csharp
628+
// C#
629+
630+
counterExceptions.Remove(("exception_type", "FileLoadException"), ("handled_by_user", true));
631+
632+
counterPowerUsed.Remove(new PowerConsumption { customer = "Tom" });
633+
counterPowerUsed.Remove(new PowerConsumption { customer = "Jerry" }, ("is_green_energy", true));
634+
```
635+
601636
### Asynchronous Counter
602637

603638
Asynchronous Counter is an [asynchronous Instrument](#asynchronous-instrument-api)
@@ -827,6 +862,35 @@ httpServerDuration.Record(50, ("http.request.method", "POST"), ("url.scheme", "h
827862
httpServerDuration.Record(100, new HttpRequestAttributes { method = "GET", scheme = "http" });
828863
```
829864

865+
##### Remove
866+
867+
Unregister the Histogram. It will no longer be reported.
868+
869+
This API SHOULD NOT return a value (it MAY return a dummy value if required by
870+
certain programming languages or systems, for example `null`, `undefined`).
871+
872+
This API MUST accept the following parameter:
873+
874+
* [Attributes](../common/README.md#attribute) to identify the Histogram.
875+
876+
Users can provide attributes to identify the Histogram.
877+
This API MUST be structured to accept a variable number of attributes, including none.
878+
879+
880+
```python
881+
# Python
882+
883+
http_server_duration.Remove({"http.request.method": "POST", "url.scheme": "https"})
884+
http_server_duration.Remove(http_method="GET", http_scheme="http")
885+
```
886+
887+
```csharp
888+
// C#
889+
890+
httpServerDuration.Remove(("http.request.method", "POST"), ("url.scheme", "https"));
891+
httpServerDuration.Remove(new HttpRequestAttributes { method = "GET", scheme = "http" });
892+
```
893+
830894
### Gauge
831895

832896
`Gauge` is a [synchronous Instrument](#synchronous-instrument-api) which can be
@@ -916,6 +980,29 @@ backgroundNoiseLevel.record(4.3, roomA);
916980
backgroundNoiseLevel.record(2.5, roomB);
917981
```
918982

983+
##### <a name="remove_gauge"></a>Remove
984+
985+
Unregister the Gauge. It will no longer be reported.
986+
987+
This API SHOULD NOT return a value (it MAY return a dummy value if required by
988+
certain programming languages or systems, for example `null`, `undefined`).
989+
990+
This API MUST accept the following parameter:
991+
992+
* [Attributes](../common/README.md#attribute) to identify the Gauge.
993+
994+
Users can provide attributes to identify the Gauge.
995+
This API MUST be structured to accept a variable number of attributes, including none.
996+
997+
```java
998+
// Java
999+
Attributes roomA = Attributes.builder().put("room.id", "Rack A");
1000+
Attributes roomB = Attributes.builder().put("room.id", "Rack B");
1001+
1002+
backgroundNoiseLevel.remove(roomA);
1003+
backgroundNoiseLevel.remove(roomB);
1004+
```
1005+
9191006
### Asynchronous Gauge
9201007

9211008
Asynchronous Gauge is an [asynchronous Instrument](#asynchronous-instrument-api)
@@ -1157,6 +1244,32 @@ customersInStore.Add(1, ("account.type", "commercial"));
11571244
customersInStore.Add(-1, new Account { Type = "residential" });
11581245
```
11591246

1247+
##### Remove
1248+
1249+
Unregister the UpDownCounter. It will no longer be reported.
1250+
1251+
This API SHOULD NOT return a value (it MAY return a dummy value if required by
1252+
certain programming languages or systems, for example `null`, `undefined`).
1253+
1254+
This API MUST accept the following parameter:
1255+
1256+
* [Attributes](../common/README.md#attribute) to identify the UpDownCounter.
1257+
1258+
Users can provide attributes to identify the UpDownCounter.
1259+
This API MUST be structured to accept a variable number of attributes, including none.
1260+
1261+
```python
1262+
# Python
1263+
customers_in_store.remove({"account.type": "commercial"})
1264+
customers_in_store.remove(account_type="residential")
1265+
```
1266+
1267+
```csharp
1268+
// C#
1269+
customersInStore.Remove(("account.type", "commercial"));
1270+
customersInStore.Remove(new Account { Type = "residential" });
1271+
```
1272+
11601273
### Asynchronous UpDownCounter
11611274

11621275
Asynchronous UpDownCounter is an [asynchronous

0 commit comments

Comments
 (0)