-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
service.go
137 lines (114 loc) · 5.41 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config // import "go.opentelemetry.io/collector/config"
import (
"go.uber.org/zap/zapcore"
"go.opentelemetry.io/collector/config/configtelemetry"
)
// Service defines the configurable components of the service.
type Service struct {
// Telemetry is the configuration for collector's own telemetry.
Telemetry ServiceTelemetry `mapstructure:"telemetry"`
// Extensions are the ordered list of extensions configured for the service.
Extensions []ComponentID `mapstructure:"extensions"`
// Pipelines are the set of data pipelines configured for the service.
Pipelines Pipelines `mapstructure:"pipelines"`
}
// ServiceTelemetry defines the configurable settings for service telemetry.
type ServiceTelemetry struct {
Logs ServiceTelemetryLogs `mapstructure:"logs"`
Metrics ServiceTelemetryMetrics `mapstructure:"metrics"`
}
// ServiceTelemetryLogs defines the configurable settings for service telemetry logs.
// This MUST be compatible with zap.Config. Cannot use directly zap.Config because
// the collector uses mapstructure and not yaml tags.
type ServiceTelemetryLogs struct {
// Level is the minimum enabled logging level.
// (default = "INFO")
Level zapcore.Level `mapstructure:"level"`
// Development puts the logger in development mode, which changes the
// behavior of DPanicLevel and takes stacktraces more liberally.
// (default = false)
Development bool `mapstructure:"development"`
// Encoding sets the logger's encoding.
// Example values are "json", "console".
Encoding string `mapstructure:"encoding"`
// DisableCaller stops annotating logs with the calling function's file
// name and line number. By default, all logs are annotated.
// (default = false)
DisableCaller bool `mapstructure:"disable_caller"`
// DisableStacktrace completely disables automatic stacktrace capturing. By
// default, stacktraces are captured for WarnLevel and above logs in
// development and ErrorLevel and above in production.
// (default = false)
DisableStacktrace bool `mapstructure:"disable_stacktrace"`
// OutputPaths is a list of URLs or file paths to write logging output to.
// The URLs could only be with "file" schema or without schema.
// The URLs with "file" schema must be an absolute path.
// The URLs without schema are treated as local file paths.
// "stdout" and "stderr" are interpreted as os.Stdout and os.Stderr.
// see details at Open in zap/writer.go.
// (default = ["stderr"])
OutputPaths []string `mapstructure:"output_paths"`
// ErrorOutputPaths is a list of URLs or file paths to write zap internal logger errors to.
// The URLs could only be with "file" schema or without schema.
// The URLs with "file" schema must use absolute paths.
// The URLs without schema are treated as local file paths.
// "stdout" and "stderr" are interpreted as os.Stdout and os.Stderr.
// see details at Open in zap/writer.go.
//
// Note that this setting only affects the zap internal logger errors.
// (default = ["stderr"])
ErrorOutputPaths []string `mapstructure:"error_output_paths"`
// InitialFields is a collection of fields to add to the root logger.
// Example:
//
// initial_fields:
// foo: "bar"
//
// By default, there is no initial field.
InitialFields map[string]interface{} `mapstructure:"initial_fields"`
}
// ServiceTelemetryMetrics exposes the common Telemetry configuration for one component.
// Experimental: *NOTE* this structure is subject to change or removal in the future.
type ServiceTelemetryMetrics struct {
// Level is the level of telemetry metrics, the possible values are:
// - "none" indicates that no telemetry data should be collected;
// - "basic" is the recommended and covers the basics of the service telemetry.
// - "normal" adds some other indicators on top of basic.
// - "detailed" adds dimensions and views to the previous levels.
Level configtelemetry.Level `mapstructure:"level"`
// Address is the [address]:port that metrics exposition should be bound to.
Address string `mapstructure:"address"`
}
// DataType is a special Type that represents the data types supported by the collector. We currently support
// collecting metrics, traces and logs, this can expand in the future.
type DataType = Type
// Currently supported data types. Add new data types here when new types are supported in the future.
const (
// TracesDataType is the data type tag for traces.
TracesDataType DataType = "traces"
// MetricsDataType is the data type tag for metrics.
MetricsDataType DataType = "metrics"
// LogsDataType is the data type tag for logs.
LogsDataType DataType = "logs"
)
// Pipeline defines a single pipeline.
type Pipeline struct {
Receivers []ComponentID `mapstructure:"receivers"`
Processors []ComponentID `mapstructure:"processors"`
Exporters []ComponentID `mapstructure:"exporters"`
}
// Pipelines is a map of names to Pipelines.
type Pipelines map[ComponentID]*Pipeline