Skip to content

Commit 68d5bad

Browse files
Merge branch 'main' into jmeagher-return-json-for-some-traces
2 parents 703400d + 1e1a945 commit 68d5bad

30 files changed

+599
-56
lines changed

.chloggen/aggregate_labels_empty.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: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: metricstransform
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: The previously removed functionality of aggregating against an empty label set is restored.
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: [34430]
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: []
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: bug_fix
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: ensure validate is called
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: [35745]
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: []

.chloggen/main.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: 'enhancement'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: 'mongodbreceiver'
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 MongoDB direct connection
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: [35427]
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: []
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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: routingconnector
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Allow routing based on OTTL Conditions
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: [35731]
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+
Each route must contain either a statement or a condition.
20+
21+
# If your change doesn't affect end users or the exported elements of any package,
22+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
23+
# Optional: The change log or logs in which this entry should be included.
24+
# e.g. '[user]' or '[user, api]'
25+
# Include 'user' if the change is relevant to end users.
26+
# Include 'api' if there is a change to a library API.
27+
# Default: '[user]'
28+
change_logs: []

cmd/telemetrygen/internal/common/validate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99
)
1010

1111
var (
12-
errInvalidTraceIDLenght = fmt.Errorf("TraceID must be a 32 character hex string, like: 'ae87dadd90e9935a4bc9660628efd569'")
13-
errInvalidSpanIDLenght = fmt.Errorf("SpanID must be a 16 character hex string, like: '5828fa4960140870'")
12+
errInvalidTraceIDLength = fmt.Errorf("TraceID must be a 32 character hex string, like: 'ae87dadd90e9935a4bc9660628efd569'")
13+
errInvalidSpanIDLength = fmt.Errorf("SpanID must be a 16 character hex string, like: '5828fa4960140870'")
1414
errInvalidTraceID = fmt.Errorf("failed to create traceID byte array from the given traceID, make sure the traceID is a hex representation of a [16]byte, like: 'ae87dadd90e9935a4bc9660628efd569'")
1515
errInvalidSpanID = fmt.Errorf("failed to create SpanID byte array from the given SpanID, make sure the SpanID is a hex representation of a [8]byte, like: '5828fa4960140870'")
1616
)
1717

1818
func ValidateTraceID(traceID string) error {
1919
if len(traceID) != 32 {
20-
return errInvalidTraceIDLenght
20+
return errInvalidTraceIDLength
2121
}
2222

2323
_, err := hex.DecodeString(traceID)
@@ -30,7 +30,7 @@ func ValidateTraceID(traceID string) error {
3030

3131
func ValidateSpanID(spanID string) error {
3232
if len(spanID) != 16 {
33-
return errInvalidSpanIDLenght
33+
return errInvalidSpanIDLength
3434
}
3535
_, err := hex.DecodeString(spanID)
3636
if err != nil {

cmd/telemetrygen/internal/common/validate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestValidateTraceID(t *testing.T) {
2323
{
2424
name: "InvalidLength",
2525
traceID: "invalid-length",
26-
expected: errInvalidTraceIDLenght,
26+
expected: errInvalidTraceIDLength,
2727
},
2828
{
2929
name: "InvalidTraceID",
@@ -53,7 +53,7 @@ func TestValidateSpanID(t *testing.T) {
5353
{
5454
name: "InvalidLength",
5555
spanID: "invalid-length",
56-
expected: errInvalidSpanIDLenght,
56+
expected: errInvalidSpanIDLength,
5757
},
5858
{
5959
name: "InvalidTraceID",

cmd/telemetrygen/internal/logs/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package logs
55

66
import (
7+
"fmt"
8+
79
"github.com/spf13/pflag"
810

911
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/common"
@@ -36,6 +38,10 @@ func (c *Config) Flags(fs *pflag.FlagSet) {
3638

3739
// Validate validates the test scenario parameters.
3840
func (c *Config) Validate() error {
41+
if c.TotalDuration <= 0 && c.NumLogs <= 0 {
42+
return fmt.Errorf("either `logs` or `duration` must be greater than 0")
43+
}
44+
3945
if c.TraceID != "" {
4046
if err := common.ValidateTraceID(c.TraceID); err != nil {
4147
return err

cmd/telemetrygen/internal/logs/logs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func Start(cfg *Config) error {
6060
}
6161

6262
if err = Run(cfg, expFunc, logger); err != nil {
63-
logger.Error("failed to stop the exporter", zap.Error(err))
6463
return err
6564
}
6665

@@ -69,10 +68,12 @@ func Start(cfg *Config) error {
6968

7069
// Run executes the test scenario.
7170
func Run(c *Config, exp func() (sdklog.Exporter, error), logger *zap.Logger) error {
71+
if err := c.Validate(); err != nil {
72+
return err
73+
}
74+
7275
if c.TotalDuration > 0 {
7376
c.NumLogs = 0
74-
} else if c.NumLogs <= 0 {
75-
return fmt.Errorf("either `logs` or `duration` must be greater than 0")
7677
}
7778

7879
limit := rate.Limit(c.Rate)

cmd/telemetrygen/internal/logs/worker_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,58 @@ func TestLogsWithTraceIDAndSpanID(t *testing.T) {
229229
}
230230
}
231231

232+
func TestValidate(t *testing.T) {
233+
tests := []struct {
234+
name string
235+
cfg *Config
236+
wantErrMessage string
237+
}{
238+
{
239+
name: "No duration or NumLogs",
240+
cfg: &Config{
241+
Config: common.Config{
242+
WorkerCount: 1,
243+
},
244+
TraceID: "123",
245+
},
246+
wantErrMessage: "either `logs` or `duration` must be greater than 0",
247+
},
248+
{
249+
name: "TraceID invalid",
250+
cfg: &Config{
251+
Config: common.Config{
252+
WorkerCount: 1,
253+
},
254+
NumLogs: 5,
255+
TraceID: "123",
256+
},
257+
wantErrMessage: "TraceID must be a 32 character hex string, like: 'ae87dadd90e9935a4bc9660628efd569'",
258+
},
259+
{
260+
name: "SpanID invalid",
261+
cfg: &Config{
262+
Config: common.Config{
263+
WorkerCount: 1,
264+
},
265+
NumLogs: 5,
266+
TraceID: "ae87dadd90e9935a4bc9660628efd569",
267+
SpanID: "123",
268+
},
269+
wantErrMessage: "SpanID must be a 16 character hex string, like: '5828fa4960140870'",
270+
},
271+
}
272+
for _, tt := range tests {
273+
t.Run(tt.name, func(t *testing.T) {
274+
m := &mockExporter{}
275+
expFunc := func() (sdklog.Exporter, error) {
276+
return m, nil
277+
}
278+
logger, _ := zap.NewDevelopment()
279+
require.EqualError(t, Run(tt.cfg, expFunc, logger), tt.wantErrMessage)
280+
})
281+
}
282+
}
283+
232284
func configWithNoAttributes(qty int, body string) *Config {
233285
return &Config{
234286
Body: body,

cmd/telemetrygen/internal/metrics/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package metrics
55

66
import (
7+
"fmt"
8+
79
"github.com/spf13/pflag"
810

911
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/common"
@@ -39,6 +41,10 @@ func (c *Config) Flags(fs *pflag.FlagSet) {
3941

4042
// Validate validates the test scenario parameters.
4143
func (c *Config) Validate() error {
44+
if c.TotalDuration <= 0 && c.NumMetrics <= 0 {
45+
return fmt.Errorf("either `metrics` or `duration` must be greater than 0")
46+
}
47+
4248
if c.TraceID != "" {
4349
if err := common.ValidateTraceID(c.TraceID); err != nil {
4450
return err

0 commit comments

Comments
 (0)