Skip to content

Commit e210026

Browse files
authored
Merge branch 'main' into add_profiles_to_profiles_forward_connector
2 parents 437b096 + 6f29b34 commit e210026

File tree

8 files changed

+92
-3
lines changed

8 files changed

+92
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: cmd/builder
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Set CGO_ENABLED=0 by default, add the `cgo_enabled` configuration to enable it."
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10028]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: exporter/debug
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: add queue configuration
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14101]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

cmd/builder/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,14 @@ file for the following things after `go get`ing all components and calling
222222
The `--skip-strict-versioning` flag disables these versioning checks.
223223
This flag is available temporarily and
224224
**will be removed in a future minor version**.
225+
226+
### Cgo disabled by default
227+
228+
By default, the OpenTelemetry Collector binary is built with `CGO_ENABLED=0` in accordance with
229+
how the official OpenTelemetry Collector releases are built. This can be overridden by adding
230+
the following configuration option to the `dist` section of the builder configuration file:
231+
232+
```yaml
233+
dist:
234+
cgo_enabled: true
235+
```

cmd/builder/internal/builder/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type Distribution struct {
7373
Version string `mapstructure:"version"`
7474
BuildTags string `mapstructure:"build_tags"`
7575
DebugCompilation bool `mapstructure:"debug_compilation"`
76+
CGoEnabled bool `mapstructure:"cgo_enabled"`
7677
}
7778

7879
// Module represents a receiver, exporter, processor or extension for the distribution

cmd/builder/internal/builder/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ func runGoCommand(cfg *Config, args ...string) ([]byte, error) {
4040
cmd := exec.Command(cfg.Distribution.Go, args...)
4141
cmd.Dir = cfg.Distribution.OutputPath
4242

43+
cmd.Env = os.Environ()
44+
if cfg.Distribution.CGoEnabled {
45+
cmd.Env = append(cmd.Env, "CGO_ENABLED=1")
46+
} else {
47+
cmd.Env = append(cmd.Env, "CGO_ENABLED=0")
48+
}
49+
4350
var stdout, stderr bytes.Buffer
4451
cmd.Stdout = &stdout
4552
cmd.Stderr = &stderr
@@ -127,6 +134,9 @@ func Compile(cfg *Config) error {
127134
gcflags = cfg.GCFlags
128135
}
129136
}
137+
if cfg.Distribution.CGoEnabled {
138+
cfg.Logger.Info("Building with cgo enabled")
139+
}
130140

131141
args = append(args, "-ldflags="+ldflags, "-gcflags="+gcflags)
132142

cmd/builder/internal/builder/main_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,16 @@ func TestGenerateAndCompile(t *testing.T) {
327327
return cfg
328328
},
329329
},
330+
{
331+
name: "CGoEnabled set to true",
332+
cfgBuilder: func(t *testing.T) *Config {
333+
cfg := newTestConfig(t)
334+
cfg.Distribution.OutputPath = t.TempDir()
335+
cfg.Replaces = append(cfg.Replaces, replaces...)
336+
cfg.Distribution.CGoEnabled = true
337+
return cfg
338+
},
339+
},
330340
}
331341

332342
for _, tt := range testCases {

exporter/debugexporter/exporter_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestMetricsNoErrors(t *testing.T) {
5858
func TestLogsNoErrors(t *testing.T) {
5959
for _, tc := range createTestCases() {
6060
t.Run(tc.name, func(t *testing.T) {
61-
lle, err := createLogs(context.Background(), exportertest.NewNopSettings(metadata.Type), createDefaultConfig())
61+
lle, err := createLogs(context.Background(), exportertest.NewNopSettings(metadata.Type), tc.config)
6262
require.NotNil(t, lle)
6363
assert.NoError(t, err)
6464

@@ -73,7 +73,7 @@ func TestLogsNoErrors(t *testing.T) {
7373
func TestProfilesNoErrors(t *testing.T) {
7474
for _, tc := range createTestCases() {
7575
t.Run(tc.name, func(t *testing.T) {
76-
lle, err := createProfiles(context.Background(), exportertest.NewNopSettings(metadata.Type), createDefaultConfig())
76+
lle, err := createProfiles(context.Background(), exportertest.NewNopSettings(metadata.Type), tc.config)
7777
require.NotNil(t, lle)
7878
assert.NoError(t, err)
7979

@@ -110,13 +110,16 @@ func createTestCases() []testCase {
110110
{
111111
name: "default config",
112112
config: func() *Config {
113-
return createDefaultConfig().(*Config)
113+
c := createDefaultConfig().(*Config)
114+
c.QueueConfig.QueueSize = 10
115+
return c
114116
}(),
115117
},
116118
{
117119
name: "don't use internal logger",
118120
config: func() *Config {
119121
cfg := createDefaultConfig().(*Config)
122+
cfg.QueueConfig.QueueSize = 10
120123
cfg.UseInternalLogger = false
121124
return cfg
122125
}(),

exporter/debugexporter/factory.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func createTraces(ctx context.Context, set exporter.Settings, config component.C
6161
return exporterhelper.NewTraces(ctx, set, config,
6262
debug.pushTraces,
6363
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
64+
exporterhelper.WithQueue(cfg.QueueConfig),
6465
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
6566
exporterhelper.WithShutdown(otlptext.LoggerSync(exporterLogger)),
6667
)
@@ -73,6 +74,7 @@ func createMetrics(ctx context.Context, set exporter.Settings, config component.
7374
return exporterhelper.NewMetrics(ctx, set, config,
7475
debug.pushMetrics,
7576
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
77+
exporterhelper.WithQueue(cfg.QueueConfig),
7678
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
7779
exporterhelper.WithShutdown(otlptext.LoggerSync(exporterLogger)),
7880
)
@@ -85,6 +87,7 @@ func createLogs(ctx context.Context, set exporter.Settings, config component.Con
8587
return exporterhelper.NewLogs(ctx, set, config,
8688
debug.pushLogs,
8789
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
90+
exporterhelper.WithQueue(cfg.QueueConfig),
8891
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
8992
exporterhelper.WithShutdown(otlptext.LoggerSync(exporterLogger)),
9093
)
@@ -97,6 +100,7 @@ func createProfiles(ctx context.Context, set exporter.Settings, config component
97100
return xexporterhelper.NewProfiles(ctx, set, config,
98101
debug.pushProfiles,
99102
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
103+
exporterhelper.WithQueue(cfg.QueueConfig),
100104
exporterhelper.WithTimeout(exporterhelper.TimeoutConfig{Timeout: 0}),
101105
exporterhelper.WithShutdown(otlptext.LoggerSync(exporterLogger)),
102106
)

0 commit comments

Comments
 (0)