Skip to content

Commit

Permalink
[receiver/podman] use unqualified names for metric attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
tosuke committed Jul 6, 2024
1 parent 759af84 commit 8804082
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 71 deletions.
4 changes: 2 additions & 2 deletions receiver/podmanreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Total CPU time consumed by the container since its creation.
| Name | Description | Values |
| ---- | ----------- | ------ |
| container.cpu.state | The CPU state for the data point. | Str: ``user``, ``system`` |
| state | The CPU state for the data point. | Str: ``user``, ``system`` |
### container.cpu.usage.percpu
Expand Down Expand Up @@ -128,7 +128,7 @@ Network bytes for the container.
| Name | Description | Values |
| ---- | ----------- | ------ |
| network.io.direction | The network IO operation direction. | Str: ``transmit``, ``receive`` |
| direction | The direction data is moving. | Str: ``transmit``, ``receive`` |
### container.network.io.usage.rx_bytes
Expand Down
76 changes: 38 additions & 38 deletions receiver/podmanreceiver/internal/metadata/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions receiver/podmanreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ attributes:
core:
description: "The CPU core number when utilising per-CPU metrics."
type: string
container.cpu.state:
state:
description: "The CPU state for the data point."
type: string
enum: [user, system]
network.io.direction:
description: "The network IO operation direction."
direction:
description: "The direction data is moving."
type: string
enum: [transmit, receive]

Expand All @@ -52,7 +52,7 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
attributes:
- container.cpu.state
- state
container.cpu.usage.system:
enabled: true
description: "System CPU usage."
Expand Down Expand Up @@ -126,7 +126,7 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
attributes:
- network.io.direction
- direction
container.network.io.usage.rx_bytes:
enabled: true
description: "Bytes received by the container."
Expand Down
8 changes: 4 additions & 4 deletions receiver/podmanreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,18 @@ func (r *metricsReceiver) recordCPUMetrics(now pcommon.Timestamp, stats *contain

r.mb.RecordContainerCPUTimeDataPoint(now,
toSecondsWithNanosecondPrecisionF(stats.CPUNano-stats.CPUSystemNano),
metadata.AttributeContainerCPUStateUser)
metadata.AttributeStateUser)
r.mb.RecordContainerCPUTimeDataPoint(now,
toSecondsWithNanosecondPrecisionF(stats.CPUSystemNano),
metadata.AttributeContainerCPUStateSystem)
metadata.AttributeStateSystem)
}

func (r *metricsReceiver) recordNetworkMetrics(now pcommon.Timestamp, stats *containerStats) {
r.mb.RecordContainerNetworkIoUsageRxBytesDataPoint(now, int64(stats.NetInput))
r.mb.RecordContainerNetworkIoUsageTxBytesDataPoint(now, int64(stats.NetOutput))

r.mb.RecordContainerNetworkIoDataPoint(now, int64(stats.NetOutput), metadata.AttributeNetworkIoDirectionTransmit)
r.mb.RecordContainerNetworkIoDataPoint(now, int64(stats.NetInput), metadata.AttributeNetworkIoDirectionReceive)
r.mb.RecordContainerNetworkIoDataPoint(now, int64(stats.NetOutput), metadata.AttributeDirectionTransmit)
r.mb.RecordContainerNetworkIoDataPoint(now, int64(stats.NetInput), metadata.AttributeDirectionReceive)
}

func (r *metricsReceiver) recordMemoryMetrics(now pcommon.Timestamp, stats *containerStats) {
Expand Down
28 changes: 10 additions & 18 deletions receiver/podmanreceiver/record_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,12 @@ func assertStatsEqualToMetrics(t *testing.T, podmanStats *containerStats, md pme
case "container.network.io":
assertMetricEqual(t, m, pmetric.MetricTypeSum, []point{
{
intVal: podmanStats.NetOutput,
attributes: map[string]string{
"network.io.direction": metadata.AttributeNetworkIoDirectionTransmit.String(),
},
intVal: podmanStats.NetOutput,
attributes: map[string]string{"direction": metadata.AttributeDirectionTransmit.String()},
},
{
intVal: podmanStats.NetInput,
attributes: map[string]string{
"network.io.direction": metadata.AttributeNetworkIoDirectionReceive.String(),
},
intVal: podmanStats.NetInput,
attributes: map[string]string{"direction": metadata.AttributeDirectionReceive.String()},
},
})

Expand All @@ -94,18 +90,14 @@ func assertStatsEqualToMetrics(t *testing.T, podmanStats *containerStats, md pme
case "container.cpu.time":
assertMetricEqual(t, m, pmetric.MetricTypeSum, []point{
{
doubleVal: float64(podmanStats.CPUNano-podmanStats.CPUSystemNano) / 1e9,
epsilon: 1e-9,
attributes: map[string]string{
"container.cpu.state": metadata.AttributeContainerCPUStateUser.String(),
},
doubleVal: float64(podmanStats.CPUNano-podmanStats.CPUSystemNano) / 1e9,
epsilon: 1e-9,
attributes: map[string]string{"state": metadata.AttributeStateUser.String()},
},
{
doubleVal: float64(podmanStats.CPUSystemNano) / 1e9,
epsilon: 1e-9,
attributes: map[string]string{
"container.cpu.state": metadata.AttributeContainerCPUStateSystem.String(),
},
doubleVal: float64(podmanStats.CPUSystemNano) / 1e9,
epsilon: 1e-9,
attributes: map[string]string{"state": metadata.AttributeStateSystem.String()},
},
})

Expand Down

0 comments on commit 8804082

Please sign in to comment.