Skip to content

Commit

Permalink
Merge branch 'main' into dd-con-fix-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
songy23 committed Oct 19, 2023
2 parents 7fa4fda + 1842e13 commit 5ae7cd0
Show file tree
Hide file tree
Showing 36 changed files with 860 additions and 114 deletions.
27 changes: 27 additions & 0 deletions .chloggen/awscwl_noisypusher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: awscloudwatchlogsexporter/awsemfexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Reduce noisy logs emitted by CloudWatch Logs Pusher.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27774]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: The Collector logger will now write successful CloudWatch API writes at the Debug level instead of Info level.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
27 changes: 27 additions & 0 deletions .chloggen/double-converter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'enhancement'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: doubleconverter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Adding a double converter into pkg/ottl"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [22056]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
22 changes: 22 additions & 0 deletions .chloggen/feat_top_n_file_sorting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: "enhancement"

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: filelogreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add a new "top_n" option to specify the number of files to track when using ordering criteria

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [23788]

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: ["user"]
27 changes: 27 additions & 0 deletions .chloggen/ptracetest-ignore-spanid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/pdatatest

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "support ignore span ID in span comparisons for ptracetest"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27685]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
27 changes: 27 additions & 0 deletions .chloggen/ptracetest-ignore-traceid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/pdatatest

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "support ignore trace ID in span comparisons for ptracetest"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27687]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/stanza

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: When async is enabled for udp receiver, separate logic into readers (only read logs from udp port and push to channel), and processors (read logs from channel and process; decode, split, add attributes, and push downstream), allowing to change concurrency level for both readers and processors separately.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [27613]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
18 changes: 15 additions & 3 deletions cmd/otelcontribcol/exporters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,23 @@ func verifyExporterLifecycle(t *testing.T, factory exporter.Factory, getConfigFn
assert.NotPanics(t, func() {
switch e := exp.(type) {
case exporter.Logs:
err = e.ConsumeLogs(ctx, testdata.GenerateLogsManyLogRecordsSameResource(2))
logs := testdata.GenerateLogsManyLogRecordsSameResource(2)
if !e.Capabilities().MutatesData {
logs.MarkReadOnly()
}
err = e.ConsumeLogs(ctx, logs)
case exporter.Metrics:
err = e.ConsumeMetrics(ctx, testdata.GenerateMetricsTwoMetrics())
metrics := testdata.GenerateMetricsTwoMetrics()
if !e.Capabilities().MutatesData {
metrics.MarkReadOnly()
}
err = e.ConsumeMetrics(ctx, metrics)
case exporter.Traces:
err = e.ConsumeTraces(ctx, testdata.GenerateTracesTwoSpansSameResource())
traces := testdata.GenerateTracesTwoSpansSameResource()
if !e.Capabilities().MutatesData {
traces.MarkReadOnly()
}
err = e.ConsumeTraces(ctx, traces)
}
})
if !expectErr {
Expand Down
5 changes: 2 additions & 3 deletions exporter/fileexporter/buffered_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ package fileexporter // import "github.com/open-telemetry/opentelemetry-collecto

import (
"bufio"
"errors"
"io"

"go.uber.org/multierr"
)

// bufferedWriteCloser is intended to use more memory
Expand All @@ -33,7 +32,7 @@ func (bwc *bufferedWriteCloser) Write(p []byte) (n int, err error) {
}

func (bwc *bufferedWriteCloser) Close() error {
return multierr.Combine(
return errors.Join(
bwc.buffered.Flush(),
bwc.wrapped.Close(),
)
Expand Down
4 changes: 2 additions & 2 deletions exporter/fileexporter/buffered_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package fileexporter

import (
"bytes"
"errors"
"fmt"
"io"
"os"
Expand All @@ -13,7 +14,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/multierr"
)

const (
Expand Down Expand Up @@ -83,7 +83,7 @@ func BenchmarkWriter(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err = w.Write(payload)
}
errBenchmark = multierr.Combine(err, w.Close())
errBenchmark = errors.Join(err, w.Close())
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/fileexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
go.opentelemetry.io/collector/consumer v0.87.1-0.20231017160804-ec0725874313
go.opentelemetry.io/collector/exporter v0.87.1-0.20231017160804-ec0725874313
go.opentelemetry.io/collector/pdata v1.0.0-rcv0016.0.20231017160804-ec0725874313
go.uber.org/multierr v1.11.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

Expand All @@ -39,6 +38,7 @@ require (
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/cwlogs/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (p *logPusher) pushEventBatch(req interface{}) error {
return err
}

p.logger.Info("logpusher: publish log events successfully.",
p.logger.Debug("logpusher: publish log events successfully.",
zap.Int("NumOfLogEvents", len(putLogEventsInput.LogEvents)),
zap.Float64("LogEventsSize", float64(logEventBatch.byteTotal)/float64(1024)),
zap.Int64("Time", time.Since(startTime).Nanoseconds()/int64(time.Millisecond)))
Expand Down
24 changes: 24 additions & 0 deletions pkg/ottl/ottlfuncs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ Available Converters:
- [ExtractPatterns](#extractpatterns)
- [FNV](#fnv)
- [Hours](#hours)
- [Double](#double)
- [Duration](#duration)
- [Int](#int)
- [IsMap](#ismap)
Expand Down Expand Up @@ -365,6 +366,29 @@ Examples:

- `ConvertCase(metric.name, "snake")`

### Double

The `Double` Converter converts an inputted `value` into a double.

The returned type is float64.

The input `value` types:
* float64. returns the `value` without changes.
* string. Tries to parse a double from string. If it fails then nil will be returned.
* bool. If `value` is true, then the function will return 1 otherwise 0.
* int64. The function converts the integer to a double.

If `value` is another type or parsing failed nil is always returned.

The `value` is either a path expression to a telemetry field to retrieve or a literal.

Examples:

- `Double(attributes["http.status_code"])`


- `Double("2.0")`

### Duration

`Duration(duration)`
Expand Down
42 changes: 42 additions & 0 deletions pkg/ottl/ottlfuncs/func_double.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package ottlfuncs // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs"

import (
"context"
"fmt"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
)

type DoubleArguments[K any] struct {
Target ottl.FloatLikeGetter[K]
}

func NewDoubleFactory[K any]() ottl.Factory[K] {
return ottl.NewFactory("Double", &DoubleArguments[K]{}, createDoubleFunction[K])
}

func createDoubleFunction[K any](_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[K], error) {
args, ok := oArgs.(*DoubleArguments[K])

if !ok {
return nil, fmt.Errorf("DoubleFactory args must be of type *DoubleArguments[K]")
}

return doubleFunc(args.Target), nil
}

func doubleFunc[K any](target ottl.FloatLikeGetter[K]) ottl.ExprFunc[K] {
return func(ctx context.Context, tCtx K) (interface{}, error) {
value, err := target.Get(ctx, tCtx)
if err != nil {
return nil, err
}
if value == nil {
return nil, nil
}
return *value, nil
}
}
Loading

0 comments on commit 5ae7cd0

Please sign in to comment.