Files
Bogdan DrutuandGitHub a5066c419e [metadatatest] Generate NewSettings that accepts componenttest.Telemetry (#12216)
This is the last functionality needed to replace
`metadatatest.Telemetry` with `componenttest.Telemetry`.

The `metadatatest.Telemetry` will be deprecated next release to give
time to change contrib since it is a large change.

Signed-off-by: Bogdan Drutu <[email protected]>
2025-01-30 21:42:20 +00:00

39 lines
1.5 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package proctelemetry
import (
"testing"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/service/internal/metadatatest"
)
func TestProcessTelemetry(t *testing.T) {
tel := componenttest.NewTelemetry()
require.NoError(t, RegisterProcessMetrics(tel.NewTelemetrySettings()))
metadatatest.AssertEqualProcessUptime(t, tel,
[]metricdata.DataPoint[float64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
metadatatest.AssertEqualProcessRuntimeHeapAllocBytes(t, tel,
[]metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
metadatatest.AssertEqualProcessRuntimeTotalAllocBytes(t, tel,
[]metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
metadatatest.AssertEqualProcessRuntimeTotalSysMemoryBytes(t, tel,
[]metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
metadatatest.AssertEqualProcessCPUSeconds(t, tel,
[]metricdata.DataPoint[float64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
metadatatest.AssertEqualProcessMemoryRss(t, tel,
[]metricdata.DataPoint[int64]{{}}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
}