123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // Code generated by mdatagen. DO NOT EDIT.
- package metadata
- import (
- "path/filepath"
- "testing"
- "github.com/google/go-cmp/cmp"
- "github.com/google/go-cmp/cmp/cmpopts"
- "github.com/stretchr/testify/require"
- "go.opentelemetry.io/collector/component"
- "go.opentelemetry.io/collector/confmap/confmaptest"
- )
- func TestMetricsBuilderConfig(t *testing.T) {
- tests := []struct {
- name string
- want MetricsBuilderConfig
- }{
- {
- name: "default",
- want: DefaultMetricsBuilderConfig(),
- },
- {
- name: "all_set",
- want: MetricsBuilderConfig{
- Metrics: MetricsConfig{
- OracledbConsistentGets: MetricConfig{Enabled: true},
- OracledbCPUTime: MetricConfig{Enabled: true},
- OracledbDbBlockGets: MetricConfig{Enabled: true},
- OracledbDmlLocksLimit: MetricConfig{Enabled: true},
- OracledbDmlLocksUsage: MetricConfig{Enabled: true},
- OracledbEnqueueDeadlocks: MetricConfig{Enabled: true},
- OracledbEnqueueLocksLimit: MetricConfig{Enabled: true},
- OracledbEnqueueLocksUsage: MetricConfig{Enabled: true},
- OracledbEnqueueResourcesLimit: MetricConfig{Enabled: true},
- OracledbEnqueueResourcesUsage: MetricConfig{Enabled: true},
- OracledbExchangeDeadlocks: MetricConfig{Enabled: true},
- OracledbExecutions: MetricConfig{Enabled: true},
- OracledbHardParses: MetricConfig{Enabled: true},
- OracledbLogicalReads: MetricConfig{Enabled: true},
- OracledbParseCalls: MetricConfig{Enabled: true},
- OracledbPgaMemory: MetricConfig{Enabled: true},
- OracledbPhysicalReads: MetricConfig{Enabled: true},
- OracledbProcessesLimit: MetricConfig{Enabled: true},
- OracledbProcessesUsage: MetricConfig{Enabled: true},
- OracledbSessionsLimit: MetricConfig{Enabled: true},
- OracledbSessionsUsage: MetricConfig{Enabled: true},
- OracledbTablespaceSizeLimit: MetricConfig{Enabled: true},
- OracledbTablespaceSizeUsage: MetricConfig{Enabled: true},
- OracledbTransactionsLimit: MetricConfig{Enabled: true},
- OracledbTransactionsUsage: MetricConfig{Enabled: true},
- OracledbUserCommits: MetricConfig{Enabled: true},
- OracledbUserRollbacks: MetricConfig{Enabled: true},
- },
- ResourceAttributes: ResourceAttributesConfig{
- OracledbInstanceName: ResourceAttributeConfig{Enabled: true},
- },
- },
- },
- {
- name: "none_set",
- want: MetricsBuilderConfig{
- Metrics: MetricsConfig{
- OracledbConsistentGets: MetricConfig{Enabled: false},
- OracledbCPUTime: MetricConfig{Enabled: false},
- OracledbDbBlockGets: MetricConfig{Enabled: false},
- OracledbDmlLocksLimit: MetricConfig{Enabled: false},
- OracledbDmlLocksUsage: MetricConfig{Enabled: false},
- OracledbEnqueueDeadlocks: MetricConfig{Enabled: false},
- OracledbEnqueueLocksLimit: MetricConfig{Enabled: false},
- OracledbEnqueueLocksUsage: MetricConfig{Enabled: false},
- OracledbEnqueueResourcesLimit: MetricConfig{Enabled: false},
- OracledbEnqueueResourcesUsage: MetricConfig{Enabled: false},
- OracledbExchangeDeadlocks: MetricConfig{Enabled: false},
- OracledbExecutions: MetricConfig{Enabled: false},
- OracledbHardParses: MetricConfig{Enabled: false},
- OracledbLogicalReads: MetricConfig{Enabled: false},
- OracledbParseCalls: MetricConfig{Enabled: false},
- OracledbPgaMemory: MetricConfig{Enabled: false},
- OracledbPhysicalReads: MetricConfig{Enabled: false},
- OracledbProcessesLimit: MetricConfig{Enabled: false},
- OracledbProcessesUsage: MetricConfig{Enabled: false},
- OracledbSessionsLimit: MetricConfig{Enabled: false},
- OracledbSessionsUsage: MetricConfig{Enabled: false},
- OracledbTablespaceSizeLimit: MetricConfig{Enabled: false},
- OracledbTablespaceSizeUsage: MetricConfig{Enabled: false},
- OracledbTransactionsLimit: MetricConfig{Enabled: false},
- OracledbTransactionsUsage: MetricConfig{Enabled: false},
- OracledbUserCommits: MetricConfig{Enabled: false},
- OracledbUserRollbacks: MetricConfig{Enabled: false},
- },
- ResourceAttributes: ResourceAttributesConfig{
- OracledbInstanceName: ResourceAttributeConfig{Enabled: false},
- },
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- cfg := loadMetricsBuilderConfig(t, tt.name)
- if diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(MetricConfig{}, ResourceAttributeConfig{})); diff != "" {
- t.Errorf("Config mismatch (-expected +actual):\n%s", diff)
- }
- })
- }
- }
- func loadMetricsBuilderConfig(t *testing.T, name string) MetricsBuilderConfig {
- cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
- require.NoError(t, err)
- sub, err := cm.Sub(name)
- require.NoError(t, err)
- cfg := DefaultMetricsBuilderConfig()
- require.NoError(t, component.UnmarshalConfig(sub, &cfg))
- return cfg
- }
- func TestResourceAttributesConfig(t *testing.T) {
- tests := []struct {
- name string
- want ResourceAttributesConfig
- }{
- {
- name: "default",
- want: DefaultResourceAttributesConfig(),
- },
- {
- name: "all_set",
- want: ResourceAttributesConfig{
- OracledbInstanceName: ResourceAttributeConfig{Enabled: true},
- },
- },
- {
- name: "none_set",
- want: ResourceAttributesConfig{
- OracledbInstanceName: ResourceAttributeConfig{Enabled: false},
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- cfg := loadResourceAttributesConfig(t, tt.name)
- if diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(ResourceAttributeConfig{})); diff != "" {
- t.Errorf("Config mismatch (-expected +actual):\n%s", diff)
- }
- })
- }
- }
- func loadResourceAttributesConfig(t *testing.T, name string) ResourceAttributesConfig {
- cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
- require.NoError(t, err)
- sub, err := cm.Sub(name)
- require.NoError(t, err)
- sub, err = sub.Sub("resource_attributes")
- require.NoError(t, err)
- cfg := DefaultResourceAttributesConfig()
- require.NoError(t, component.UnmarshalConfig(sub, &cfg))
- return cfg
- }
|