|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package samplereceiver // import "go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver" |
| 5 | + |
| 6 | +import ( |
| 7 | + "time" |
| 8 | + |
| 9 | + "go.opentelemetry.io/collector/component" |
| 10 | + "go.opentelemetry.io/collector/config/configopaque" |
| 11 | + "go.opentelemetry.io/collector/config/configoptional" |
| 12 | +) |
| 13 | + |
| 14 | +var _ component.Factory = (*AnotherStruct)(nil) |
| 15 | + |
| 16 | +type AnotherStruct struct{} |
| 17 | + |
| 18 | +func (a AnotherStruct) Type() component.Type { |
| 19 | + // TODO implement me |
| 20 | + panic("implement me") |
| 21 | +} |
| 22 | + |
| 23 | +func (a AnotherStruct) CreateDefaultConfig() component.Config { |
| 24 | + // TODO implement me |
| 25 | + panic("implement me") |
| 26 | +} |
| 27 | + |
| 28 | +var _ component.Config = (*MyConfig)(nil) |
| 29 | + |
| 30 | +type CustomString string |
| 31 | + |
| 32 | +// NetworkConfig holds network configuration that should be squashed into parent. |
| 33 | +type NetworkConfig struct { |
| 34 | + // Host is the network host. |
| 35 | + Host string `mapstructure:"host"` |
| 36 | + |
| 37 | + // Port is the network port. |
| 38 | + Port int `mapstructure:"port"` |
| 39 | +} |
| 40 | + |
| 41 | +// MyConfig defines configuration for the sample exporter used to test schema generation. |
| 42 | +type MyConfig struct { |
| 43 | + // Network is squashed into the parent config. |
| 44 | + Network NetworkConfig `mapstructure:",squash"` |
| 45 | + |
| 46 | + // ID is the component identifier. |
| 47 | + ID component.ID `mapstructure:"id"` |
| 48 | + |
| 49 | + // Endpoint is the target URL to send data to. |
| 50 | + Endpoint string `mapstructure:"endpoint"` |
| 51 | + |
| 52 | + // CustomString is a custom string. |
| 53 | + CustomString CustomString `mapstructure:"custom_string"` |
| 54 | + |
| 55 | + // Timeout is the maximum time to wait for a response. |
| 56 | + Timeout time.Duration `mapstructure:"timeout"` |
| 57 | + |
| 58 | + // StartTime is the time when the receiver should start collecting data. |
| 59 | + StartTime time.Time `mapstructure:"start_time"` |
| 60 | + |
| 61 | + // Enabled controls whether the exporter is active. |
| 62 | + Enabled bool `mapstructure:"enabled"` |
| 63 | + |
| 64 | + // BatchSize is the number of items to send in each batch. |
| 65 | + BatchSize int `mapstructure:"batch_size"` |
| 66 | + |
| 67 | + // Headers are additional headers to include in requests. |
| 68 | + Headers map[string]string `mapstructure:"headers"` |
| 69 | + |
| 70 | + // Retry contains retry configuration. |
| 71 | + Retry RetryConfig `mapstructure:"retry"` |
| 72 | + |
| 73 | + // Tags are optional tags to attach. |
| 74 | + Tags []string `mapstructure:"tags"` |
| 75 | + |
| 76 | + // APIKey is a secret API key (opaque string). |
| 77 | + APIKey configopaque.String `mapstructure:"api_key"` |
| 78 | + |
| 79 | + // OptionalRetry is an optional retry configuration. |
| 80 | + OptionalRetry configoptional.Optional[RetryConfig] `mapstructure:"optional_retry"` |
| 81 | + |
| 82 | + // Secrets is a list of secret key-value pairs. |
| 83 | + Secrets configopaque.MapList `mapstructure:"secrets"` |
| 84 | + |
| 85 | + // Endpoints is a list of endpoint configurations. |
| 86 | + Endpoints []EndpointConfig `mapstructure:"endpoints"` |
| 87 | + |
| 88 | + // InternalState is an internal field that should be excluded from the schema. |
| 89 | + InternalState string `mapstructure:"-"` |
| 90 | +} |
| 91 | + |
| 92 | +// EndpointConfig holds configuration for a single endpoint. |
| 93 | +type EndpointConfig struct { |
| 94 | + // URL is the endpoint URL. |
| 95 | + URL string `mapstructure:"url"` |
| 96 | + |
| 97 | + // Priority is the endpoint priority. |
| 98 | + Priority int `mapstructure:"priority"` |
| 99 | +} |
| 100 | + |
| 101 | +// RetryConfig holds retry settings. |
| 102 | +type RetryConfig struct { |
| 103 | + // MaxRetries is the maximum number of retries. |
| 104 | + MaxRetries int `mapstructure:"max_retries"` |
| 105 | + |
| 106 | + // InitialInterval is the initial retry interval. |
| 107 | + InitialInterval time.Duration `mapstructure:"initial_interval"` |
| 108 | +} |
0 commit comments