Skip to content

Commit 8fbb7f6

Browse files
authored
Merge branch 'main' into main
2 parents 793983b + e296b0f commit 8fbb7f6

File tree

69 files changed

+2219
-464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2219
-464
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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. filelogreceiver)
7+
component: processor/transformprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add support for global conditions and error mode overrides.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [29017]
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+
Global conditions are now available for context-inferred structured configurations, allowing the use of fully
20+
qualified paths. Additionally, a new configuration key called `error_mode` has been added to the context statements group.
21+
This key determines how the processor reacts to errors that occur while processing that specific group of statements.
22+
When provided, it overrides the top-level error mode, offering more granular control over error handling.
23+
24+
# If your change doesn't affect end users or the exported elements of any package,
25+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
26+
# Optional: The change log or logs in which this entry should be included.
27+
# e.g. '[user]' or '[user, api]'
28+
# Include 'user' if the change is relevant to end users.
29+
# Include 'api' if there is a change to a library API.
30+
# Default: '[user]'
31+
change_logs: [user]

.chloggen/rm-dep-func.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/stanza
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove deprecated func BuildWithSplitFunc from stanza/fileconsumer
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [37723]
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+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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. filelogreceiver)
7+
component: telemetrygen
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Exported the API for telemetrygen for test uses. Additionally added new E2E tests and fixed race condition
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [36984]
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+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ jobs:
221221
run: |
222222
make crosslink
223223
git diff --exit-code || (echo 'Replace statements are out of date, please run "make crosslink" and commit the changes in this PR.' && exit 1)
224+
- name: tidylist
225+
run: |
226+
make tidylist
227+
git diff --exit-code || (echo 'Tidylist is out of date, please run "make tidylist" and commit the changes in this PR.' && exit 1)
224228
- name: Check for go mod dependency changes
225229
run: |
226230
make gotidy

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,23 @@ stability-tests: otelcontribcol
114114
gogci:
115115
$(MAKE) $(FOR_GROUP_TARGET) TARGET="gci"
116116

117+
.PHONY: tidylist
118+
tidylist: $(CROSSLINK)
119+
cd internal/tidylist && \
120+
$(CROSSLINK) tidylist \
121+
--validate \
122+
--allow-circular allow-circular.txt \
123+
--skip cmd/otelcontribcol/go.mod \
124+
--skip cmd/oteltestbedcol/go.mod \
125+
tidylist.txt
126+
127+
# internal/tidylist/tidylist.txt lists modules in topological order, to ensure `go mod tidy` converges.
117128
.PHONY: gotidy
118129
gotidy:
119-
$(MAKE) $(FOR_GROUP_TARGET) TARGET="tidy"
130+
@for mod in $$(cat internal/tidylist/tidylist.txt); do \
131+
echo "Tidying $$mod"; \
132+
(cd $$mod && rm -rf go.sum && $(GOCMD) mod tidy -compat=1.22.0) || exit $?; \
133+
done
120134

121135
.PHONY: remove-toolchain
122136
remove-toolchain:

cmd/telemetrygen/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212

1313
"github.com/spf13/cobra"
1414

15-
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/logs"
1615
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/metadata"
17-
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/metrics"
18-
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/traces"
16+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/pkg/logs"
17+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/pkg/metrics"
18+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/pkg/traces"
1919
)
2020

2121
var (
@@ -64,13 +64,13 @@ var logsCmd = &cobra.Command{
6464
func init() {
6565
rootCmd.AddCommand(tracesCmd, metricsCmd, logsCmd)
6666

67-
tracesCfg = new(traces.Config)
67+
tracesCfg = traces.NewConfig()
6868
tracesCfg.Flags(tracesCmd.Flags())
6969

70-
metricsCfg = new(metrics.Config)
70+
metricsCfg = metrics.NewConfig()
7171
metricsCfg.Flags(metricsCmd.Flags())
7272

73-
logsCfg = new(logs.Config)
73+
logsCfg = logs.NewConfig()
7474
logsCfg.Flags(logsCmd.Flags())
7575

7676
// Disabling completion command for end user
@@ -81,7 +81,7 @@ func init() {
8181
// Execute tries to run the input command
8282
func Execute() {
8383
if err := rootCmd.Execute(); err != nil {
84-
// TODO: Uncomment the line below when using Run instead of RunE in the xxxCmd functions
84+
// TODO: Uncomment the line below when using run instead of RunE in the xxxCmd functions
8585
// fmt.Fprintln(os.Stderr, err)
8686
os.Exit(1)
8787
}

cmd/telemetrygen/internal/common/config.go

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,40 +148,59 @@ func (c *Config) GetHeaders() map[string]string {
148148

149149
// CommonFlags registers common config flags.
150150
func (c *Config) CommonFlags(fs *pflag.FlagSet) {
151-
fs.IntVar(&c.WorkerCount, "workers", 1, "Number of workers (goroutines) to run")
152-
fs.Float64Var(&c.Rate, "rate", 0, "Approximately how many metrics/spans/logs per second each worker should generate. Zero means no throttling.")
153-
fs.DurationVar(&c.TotalDuration, "duration", 0, "For how long to run the test")
154-
fs.DurationVar(&c.ReportingInterval, "interval", 1*time.Second, "Reporting interval")
151+
fs.IntVar(&c.WorkerCount, "workers", c.WorkerCount, "Number of workers (goroutines) to run")
152+
fs.Float64Var(&c.Rate, "rate", c.Rate, "Approximately how many metrics/spans/logs per second each worker should generate. Zero means no throttling.")
153+
fs.DurationVar(&c.TotalDuration, "duration", c.TotalDuration, "For how long to run the test")
154+
fs.DurationVar(&c.ReportingInterval, "interval", c.ReportingInterval, "Reporting interval")
155155

156-
fs.StringVar(&c.CustomEndpoint, "otlp-endpoint", "", "Destination endpoint for exporting logs, metrics and traces")
157-
fs.BoolVar(&c.Insecure, "otlp-insecure", false, "Whether to enable client transport security for the exporter's grpc or http connection")
158-
fs.BoolVar(&c.InsecureSkipVerify, "otlp-insecure-skip-verify", false, "Whether a client verifies the server's certificate chain and host name")
159-
fs.BoolVar(&c.UseHTTP, "otlp-http", false, "Whether to use HTTP exporter rather than a gRPC one")
156+
fs.StringVar(&c.CustomEndpoint, "otlp-endpoint", c.CustomEndpoint, "Destination endpoint for exporting logs, metrics and traces")
157+
fs.BoolVar(&c.Insecure, "otlp-insecure", c.Insecure, "Whether to enable client transport security for the exporter's grpc or http connection")
158+
fs.BoolVar(&c.InsecureSkipVerify, "otlp-insecure-skip-verify", c.InsecureSkipVerify, "Whether a client verifies the server's certificate chain and host name")
159+
fs.BoolVar(&c.UseHTTP, "otlp-http", c.UseHTTP, "Whether to use HTTP exporter rather than a gRPC one")
160160

161161
// custom headers
162-
c.Headers = make(KeyValue)
163162
fs.Var(&c.Headers, "otlp-header", "Custom header to be passed along with each OTLP request. The value is expected in the format key=\"value\". "+
164163
"Note you may need to escape the quotes when using the tool from a cli. "+
165164
`Flag may be repeated to set multiple headers (e.g --otlp-header key1=\"value1\" --otlp-header key2=\"value2\")`)
166165

167166
// custom resource attributes
168-
c.ResourceAttributes = make(KeyValue)
169167
fs.Var(&c.ResourceAttributes, "otlp-attributes", "Custom resource attributes to use. The value is expected in the format key=\"value\". "+
170168
"You can use key=true or key=false. to set boolean attribute."+
171169
"Note you may need to escape the quotes when using the tool from a cli. "+
172170
`Flag may be repeated to set multiple attributes (e.g --otlp-attributes key1=\"value1\" --otlp-attributes key2=\"value2\" --telemetry-attributes key3=true)`)
173171

174-
c.TelemetryAttributes = make(KeyValue)
175172
fs.Var(&c.TelemetryAttributes, "telemetry-attributes", "Custom telemetry attributes to use. The value is expected in the format key=\"value\". "+
176173
"You can use key=true or key=false. to set boolean attribute."+
177174
"Note you may need to escape the quotes when using the tool from a cli. "+
178175
`Flag may be repeated to set multiple attributes (e.g --telemetry-attributes key1=\"value1\" --telemetry-attributes key2=\"value2\" --telemetry-attributes key3=true)`)
179176

180177
// TLS CA configuration
181-
fs.StringVar(&c.CaFile, "ca-cert", "", "Trusted Certificate Authority to verify server certificate")
178+
fs.StringVar(&c.CaFile, "ca-cert", c.CaFile, "Trusted Certificate Authority to verify server certificate")
182179

183180
// mTLS configuration
184-
fs.BoolVar(&c.ClientAuth.Enabled, "mtls", false, "Whether to require client authentication for mTLS")
185-
fs.StringVar(&c.ClientAuth.ClientCertFile, "client-cert", "", "Client certificate file")
186-
fs.StringVar(&c.ClientAuth.ClientKeyFile, "client-key", "", "Client private key file")
181+
fs.BoolVar(&c.ClientAuth.Enabled, "mtls", c.ClientAuth.Enabled, "Whether to require client authentication for mTLS")
182+
fs.StringVar(&c.ClientAuth.ClientCertFile, "client-cert", c.ClientAuth.ClientCertFile, "Client certificate file")
183+
fs.StringVar(&c.ClientAuth.ClientKeyFile, "client-key", c.ClientAuth.ClientKeyFile, "Client private key file")
184+
}
185+
186+
// SetDefaults is here to mirror the defaults for flags above,
187+
// This allows for us to have a single place to change the defaults
188+
// while exposing the API for use.
189+
func (c *Config) SetDefaults() {
190+
c.WorkerCount = 1
191+
c.Rate = 0
192+
c.TotalDuration = 0
193+
c.ReportingInterval = 1 * time.Second
194+
c.CustomEndpoint = ""
195+
c.Insecure = false
196+
c.InsecureSkipVerify = false
197+
c.UseHTTP = false
198+
c.HTTPPath = ""
199+
c.Headers = make(KeyValue)
200+
c.ResourceAttributes = make(KeyValue)
201+
c.TelemetryAttributes = make(KeyValue)
202+
c.CaFile = ""
203+
c.ClientAuth.Enabled = false
204+
c.ClientAuth.ClientCertFile = ""
205+
c.ClientAuth.ClientKeyFile = ""
187206
}

cmd/telemetrygen/internal/e2etest/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,21 @@ require (
6565
go.opentelemetry.io/collector/pipeline v0.119.0 // indirect
6666
go.opentelemetry.io/collector/receiver v0.119.0 // indirect
6767
go.opentelemetry.io/collector/receiver/xreceiver v0.119.0 // indirect
68+
go.opentelemetry.io/collector/semconv v0.119.0 // indirect
6869
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
6970
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
7071
go.opentelemetry.io/otel v1.34.0 // indirect
72+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.10.0 // indirect
73+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.10.0 // indirect
74+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.34.0 // indirect
75+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.34.0 // indirect
7176
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
7277
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 // indirect
7378
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 // indirect
79+
go.opentelemetry.io/otel/log v0.10.0 // indirect
7480
go.opentelemetry.io/otel/metric v1.34.0 // indirect
7581
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
82+
go.opentelemetry.io/otel/sdk/log v0.10.0 // indirect
7683
go.opentelemetry.io/otel/sdk/metric v1.34.0 // indirect
7784
go.opentelemetry.io/otel/trace v1.34.0 // indirect
7885
go.opentelemetry.io/proto/otlp v1.5.0 // indirect

cmd/telemetrygen/internal/e2etest/go.sum

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package e2etest
5+
6+
import (
7+
"context"
8+
"testing"
9+
"time"
10+
11+
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
13+
"go.opentelemetry.io/collector/component/componenttest"
14+
"go.opentelemetry.io/collector/consumer/consumertest"
15+
"go.opentelemetry.io/collector/receiver/otlpreceiver"
16+
"go.opentelemetry.io/collector/receiver/receivertest"
17+
18+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/pkg/logs"
19+
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil"
20+
)
21+
22+
func TestGenerateLogs(t *testing.T) {
23+
f := otlpreceiver.NewFactory()
24+
sink := &consumertest.LogsSink{}
25+
rCfg := f.CreateDefaultConfig()
26+
endpoint := testutil.GetAvailableLocalAddress(t)
27+
rCfg.(*otlpreceiver.Config).GRPC.NetAddr.Endpoint = endpoint
28+
r, err := f.CreateLogs(context.Background(), receivertest.NewNopSettings(), rCfg, sink)
29+
require.NoError(t, err)
30+
err = r.Start(context.Background(), componenttest.NewNopHost())
31+
require.NoError(t, err)
32+
defer func() {
33+
require.NoError(t, r.Shutdown(context.Background()))
34+
}()
35+
cfg := logs.NewConfig()
36+
cfg.WorkerCount = 10
37+
cfg.Rate = 10
38+
cfg.TotalDuration = 10 * time.Second
39+
cfg.ReportingInterval = 10
40+
cfg.CustomEndpoint = endpoint
41+
cfg.Insecure = true
42+
cfg.SkipSettingGRPCLogger = true
43+
cfg.NumLogs = 6000
44+
go func() {
45+
err = logs.Start(cfg)
46+
assert.NoError(t, err)
47+
}()
48+
require.Eventually(t, func() bool {
49+
return len(sink.AllLogs()) > 0
50+
}, 10*time.Second, 100*time.Millisecond)
51+
}

0 commit comments

Comments
 (0)