Debian Codegraph @

service/internal/proctelemetry/process_telemetry_linux_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 //go:build linux
5
6 package proctelemetry
7
8 import (
9 "testing"
10
11 "github.com/stretchr/testify/require"
12 "go.opentelemetry.io/otel/sdk/metric/metricdata"
13 "go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
14
15 "go.opentelemetry.io/collector/component/componenttest"
16 "go.opentelemetry.io/collector/service/internal/metadatatest"
17 )
18
19 func TestProcessTelemetryWithHostProc(t *testing.T) {
20 // Make the sure the environment variable value is not used.
21 t.Setenv("HOST_PROC", "foo/bar")
22 tel := componenttest.NewTelemetry()
23 require.NoError(t, RegisterProcessMetrics(tel.NewTelemetrySettings(), WithHostProc("/proc")))
24
25 metadatatest.AssertEqualProcessUptime(t, tel,
26 []metricdata.DataPoint[float64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
27
28 metadatatest.AssertEqualProcessRuntimeHeapAllocBytes(t, tel,
29 []metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
30
31 metadatatest.AssertEqualProcessRuntimeTotalAllocBytes(t, tel,
32 []metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
33
34 metadatatest.AssertEqualProcessRuntimeTotalSysMemoryBytes(t, tel,
35 []metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
36
37 metadatatest.AssertEqualProcessCPUSeconds(t, tel,
38 []metricdata.DataPoint[float64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
39
40 metadatatest.AssertEqualProcessMemoryRss(t, tel,
41 []metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
42 }