Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ release.

### Metrics

- Development: Define `remove` operations for synchronous metric instruments. [#4702](https://github.com/open-telemetry/opentelemetry-specification/pulls/4702)

### Logs

### Baggage
Expand Down
119 changes: 119 additions & 0 deletions specification/metrics/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,28 @@ weight: 1
+ [Counter creation](#counter-creation)
+ [Counter operations](#counter-operations)
- [Add](#add)
- [Remove](#remove)
* [Asynchronous Counter](#asynchronous-counter)
+ [Asynchronous Counter creation](#asynchronous-counter-creation)
+ [Asynchronous Counter operations](#asynchronous-counter-operations)
* [Histogram](#histogram)
+ [Histogram creation](#histogram-creation)
+ [Histogram operations](#histogram-operations)
- [Record](#record)
- [Remove](#remove-1)
* [Gauge](#gauge)
+ [Gauge creation](#gauge-creation)
+ [Gauge operations](#gauge-operations)
- [Record](#record-1)
- [Remove](#remove-2)
* [Asynchronous Gauge](#asynchronous-gauge)
+ [Asynchronous Gauge creation](#asynchronous-gauge-creation)
+ [Asynchronous Gauge operations](#asynchronous-gauge-operations)
* [UpDownCounter](#updowncounter)
+ [UpDownCounter creation](#updowncounter-creation)
+ [UpDownCounter operations](#updowncounter-operations)
- [Add](#add-1)
- [Remove](#remove-3)
* [Asynchronous UpDownCounter](#asynchronous-updowncounter)
+ [Asynchronous UpDownCounter creation](#asynchronous-updowncounter-creation)
+ [Asynchronous UpDownCounter operations](#asynchronous-updowncounter-operations)
Expand Down Expand Up @@ -598,6 +602,38 @@ counterPowerUsed.Add(13.5, new PowerConsumption { customer = "Tom" });
counterPowerUsed.Add(200, new PowerConsumption { customer = "Jerry" }, ("is_green_energy", true));
```

##### Remove

Status: Development
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Status: Development
**Status**: [Development](../document-status.md)


Unregister the Counter. It will no longer be reported.
Copy link
Member

@pellared pellared Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Assuming that I do not miss something) This is not true. This does not registers the whole counter, but a data point (if I correctly remember/understand the terminology). Maybe it would be better to rename the operation to RemoveDataPoint so that we can add Remove in future that would unregister the whole instrument (and not only a given data point)?

The same comment applies to other instruments.

EDIT: I see similar comments like #4702 (comment) 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we aren't unregistering the entire counter. I don't like RemoveDataPoint, as DataPoint is not really an API concept. I would suggest phrasing this as "Unregister the attribute set".


This API SHOULD NOT return a value (it MAY return a dummy value if required by
certain programming languages or systems, for example `null`, `undefined`).

This API MUST accept the following parameter:

* [Attributes](../common/README.md#attribute) to identify the Counter.

Users can provide attributes to identify the Counter.
This API MUST be structured to accept a variable number of attributes, including none.

```python
# Python

exception_counter.remove({"exception_type": "IOError", "handled_by_user": True})
exception_counter.remove(exception_type="IOError", handled_by_user=True)
```

```csharp
// C#

counterExceptions.Remove(("exception_type", "FileLoadException"), ("handled_by_user", true));

counterPowerUsed.Remove(new PowerConsumption { customer = "Tom" });
counterPowerUsed.Remove(new PowerConsumption { customer = "Jerry" }, ("is_green_energy", true));
```

### Asynchronous Counter

Asynchronous Counter is an [asynchronous Instrument](#asynchronous-instrument-api)
Expand Down Expand Up @@ -827,6 +863,36 @@ httpServerDuration.Record(50, ("http.request.method", "POST"), ("url.scheme", "h
httpServerDuration.Record(100, new HttpRequestAttributes { method = "GET", scheme = "http" });
```

##### Remove

Status: Development
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Status: Development
**Status**: [Development](../document-status.md)


Unregister the Histogram. It will no longer be reported.

This API SHOULD NOT return a value (it MAY return a dummy value if required by
certain programming languages or systems, for example `null`, `undefined`).

This API MUST accept the following parameter:

* [Attributes](../common/README.md#attribute) to identify the Histogram.

Users can provide attributes to identify the Histogram.
This API MUST be structured to accept a variable number of attributes, including none.

```python
# Python

http_server_duration.Remove({"http.request.method": "POST", "url.scheme": "https"})
http_server_duration.Remove(http_method="GET", http_scheme="http")
```

```csharp
// C#

httpServerDuration.Remove(("http.request.method", "POST"), ("url.scheme", "https"));
httpServerDuration.Remove(new HttpRequestAttributes { method = "GET", scheme = "http" });
```

### Gauge

`Gauge` is a [synchronous Instrument](#synchronous-instrument-api) which can be
Expand Down Expand Up @@ -916,6 +982,31 @@ backgroundNoiseLevel.record(4.3, roomA);
backgroundNoiseLevel.record(2.5, roomB);
```

##### Remove

Status: Development
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Status: Development
**Status**: [Development](../document-status.md)


Unregister the Gauge. It will no longer be reported.

This API SHOULD NOT return a value (it MAY return a dummy value if required by
certain programming languages or systems, for example `null`, `undefined`).

This API MUST accept the following parameter:

* [Attributes](../common/README.md#attribute) to identify the Gauge.

Users can provide attributes to identify the Gauge.
This API MUST be structured to accept a variable number of attributes, including none.

```java
// Java
Attributes roomA = Attributes.builder().put("room.id", "Rack A");
Attributes roomB = Attributes.builder().put("room.id", "Rack B");

backgroundNoiseLevel.remove(roomA);
backgroundNoiseLevel.remove(roomB);
```

### Asynchronous Gauge

Asynchronous Gauge is an [asynchronous Instrument](#asynchronous-instrument-api)
Expand Down Expand Up @@ -1157,6 +1248,34 @@ customersInStore.Add(1, ("account.type", "commercial"));
customersInStore.Add(-1, new Account { Type = "residential" });
```

##### Remove

Status: Development
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Status: Development
**Status**: [Development](../document-status.md)


Unregister the UpDownCounter. It will no longer be reported.

This API SHOULD NOT return a value (it MAY return a dummy value if required by
certain programming languages or systems, for example `null`, `undefined`).

This API MUST accept the following parameter:

* [Attributes](../common/README.md#attribute) to identify the UpDownCounter.

Users can provide attributes to identify the UpDownCounter.
This API MUST be structured to accept a variable number of attributes, including none.

```python
# Python
customers_in_store.remove({"account.type": "commercial"})
customers_in_store.remove(account_type="residential")
```

```csharp
// C#
customersInStore.Remove(("account.type", "commercial"));
customersInStore.Remove(new Account { Type = "residential" });
```

### Asynchronous UpDownCounter

Asynchronous UpDownCounter is an [asynchronous
Expand Down
Loading