|
| 1 | +// Copyright The OpenTelemetry Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +// Package configmodels defines the data models for entities. This file defines the |
| 16 | +// models for configuration format. The defined entities are: |
| 17 | +// Config (the top-level structure), Receivers, Exporters, Processors, Pipelines. |
| 18 | +// |
| 19 | +// Receivers, Exporters and Processors typically have common configuration settings, however |
| 20 | +// sometimes specific implementations will have extra configuration settings. |
| 21 | +// This requires the configuration data for these entities to be polymorphic. |
| 22 | +// |
| 23 | +// To satisfy these requirements we declare interfaces Receiver, Exporter, Processor, |
| 24 | +// which define the behavior. We also provide helper structs ReceiverSettings, ExporterSettings, |
| 25 | +// ProcessorSettings, which define the common settings and un-marshaling from config files. |
| 26 | +// |
| 27 | +// Specific Receivers/Exporters/Processors are expected to at the minimum implement the |
| 28 | +// corresponding interface and if they have additional settings they must also extend |
| 29 | +// the corresponding common settings struct (the easiest approach is to embed the common struct). |
| 30 | +package configmodels |
| 31 | + |
| 32 | +// Config defines the configuration for the various elements of collector or agent. |
| 33 | +type Config struct { |
| 34 | + Receivers |
| 35 | + Exporters |
| 36 | + Processors |
| 37 | + Extensions |
| 38 | + Service |
| 39 | +} |
| 40 | + |
| 41 | +// Service defines the configurable components of the service. |
| 42 | +type Service struct { |
| 43 | + // Extensions is the ordered list of extensions configured for the service. |
| 44 | + Extensions []string |
| 45 | + |
| 46 | + // Pipelines is the set of data pipelines configured for the service. |
| 47 | + Pipelines Pipelines |
| 48 | +} |
| 49 | + |
| 50 | +// Type is the component type as it is used in the config. |
| 51 | +type Type string |
| 52 | + |
| 53 | +// NamedEntity is a configuration entity that has a type and a name. |
| 54 | +type NamedEntity interface { |
| 55 | + Type() Type |
| 56 | + Name() string |
| 57 | + SetName(name string) |
| 58 | +} |
| 59 | + |
| 60 | +// DataType is the data type that is supported for collection. We currently support |
| 61 | +// collecting metrics, traces and logs, this can expand in the future. |
| 62 | +type DataType string |
| 63 | + |
| 64 | +// Currently supported data types. Add new data types here when new types are supported in the future. |
| 65 | +const ( |
| 66 | + // TracesDataType is the data type tag for traces. |
| 67 | + TracesDataType DataType = "traces" |
| 68 | + |
| 69 | + // MetricsDataType is the data type tag for metrics. |
| 70 | + MetricsDataType DataType = "metrics" |
| 71 | + |
| 72 | + // LogsDataType is the data type tag for logs. |
| 73 | + LogsDataType DataType = "logs" |
| 74 | +) |
| 75 | + |
| 76 | +// Pipeline defines a single pipeline. |
| 77 | +type Pipeline struct { |
| 78 | + Name string |
| 79 | + InputType DataType |
| 80 | + Receivers []string |
| 81 | + Processors []string |
| 82 | + Exporters []string |
| 83 | +} |
| 84 | + |
| 85 | +// Pipelines is a map of names to Pipelines. |
| 86 | +type Pipelines map[string]*Pipeline |
0 commit comments