-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jaegerremotesampling_replace_thrift-gen_with…
…_proto-gen Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
- Loading branch information
Showing
18 changed files
with
734 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
# If your change doesn't affect end users, such as a test fix or a tooling change, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
|
||
# 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/ottl' | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Add converters to convert time to unix nanoseconds, unix microseconds, unix milliseconds or unix seconds" | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [24686] | ||
|
||
# (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: |
20 changes: 20 additions & 0 deletions
20
.chloggen/fix-tailsampling-lost-instrumentation-scope-info.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
# If your change doesn't affect end users, such as a test fix or a tooling change, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: bug_fix | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: processor/tailsampling | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Added saving instrumentation library information for tail-sampling | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [13642] | ||
|
||
# (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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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 UnixMicroArguments[K any] struct { | ||
Time ottl.TimeGetter[K] `ottlarg:"0"` | ||
} | ||
|
||
func NewUnixMicroFactory[K any]() ottl.Factory[K] { | ||
return ottl.NewFactory("UnixMicro", &UnixMicroArguments[K]{}, createUnixMicroFunction[K]) | ||
} | ||
func createUnixMicroFunction[K any](_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[K], error) { | ||
args, ok := oArgs.(*UnixMicroArguments[K]) | ||
|
||
if !ok { | ||
return nil, fmt.Errorf("UnixMicroFactory args must be of type *UnixMicroArguments[K]") | ||
} | ||
|
||
return UnixMicro(args.Time) | ||
} | ||
|
||
func UnixMicro[K any](inputTime ottl.TimeGetter[K]) (ottl.ExprFunc[K], error) { | ||
return func(ctx context.Context, tCtx K) (interface{}, error) { | ||
t, err := inputTime.Get(ctx, tCtx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return t.UnixMicro(), nil | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package ottlfuncs | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" | ||
) | ||
|
||
func Test_TimeUnixMicro(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
time ottl.TimeGetter[interface{}] | ||
expected time.Time | ||
}{ | ||
{ | ||
name: "January 1, 2023", | ||
time: &ottl.StandardTimeGetter[interface{}]{ | ||
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) { | ||
return time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local), nil | ||
}, | ||
}, | ||
expected: time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local), | ||
}, | ||
{ | ||
name: "April 30, 2001, 3pm", | ||
time: &ottl.StandardTimeGetter[interface{}]{ | ||
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) { | ||
return time.Date(2001, 4, 30, 15, 0, 0, 0, time.Local), nil | ||
}, | ||
}, | ||
expected: time.Date(2001, 4, 30, 15, 0, 0, 0, time.Local), | ||
}, | ||
{ | ||
name: "November 12, 1980, 4:35:01am", | ||
time: &ottl.StandardTimeGetter[interface{}]{ | ||
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) { | ||
return time.Date(1980, 11, 12, 4, 35, 1, 0, time.Local), nil | ||
}, | ||
}, | ||
expected: time.Date(1980, 11, 12, 4, 35, 1, 0, time.Local), | ||
}, | ||
{ | ||
name: "October 4, 2020, 5:05 5 microseconds 5 nanosecs", | ||
time: &ottl.StandardTimeGetter[interface{}]{ | ||
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) { | ||
return time.Date(2020, 10, 4, 5, 5, 5, 5, time.Local), nil | ||
}, | ||
}, | ||
expected: time.Date(2020, 10, 4, 5, 5, 5, 5, time.Local), | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
exprFunc, err := UnixMicro(tt.time) | ||
assert.NoError(t, err) | ||
result, err := exprFunc(nil, nil) | ||
assert.NoError(t, err) | ||
want := tt.expected.UnixMicro() | ||
assert.Equal(t, want, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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 UnixMilliArguments[K any] struct { | ||
Time ottl.TimeGetter[K] `ottlarg:"0"` | ||
} | ||
|
||
func NewUnixMilliFactory[K any]() ottl.Factory[K] { | ||
return ottl.NewFactory("UnixMilli", &UnixMilliArguments[K]{}, createUnixMilliFunction[K]) | ||
} | ||
func createUnixMilliFunction[K any](_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[K], error) { | ||
args, ok := oArgs.(*UnixMilliArguments[K]) | ||
|
||
if !ok { | ||
return nil, fmt.Errorf("UnixMilliFactory args must be of type *UnixMilliArguments[K]") | ||
} | ||
|
||
return UnixMilli(args.Time) | ||
} | ||
|
||
func UnixMilli[K any](inputTime ottl.TimeGetter[K]) (ottl.ExprFunc[K], error) { | ||
return func(ctx context.Context, tCtx K) (interface{}, error) { | ||
t, err := inputTime.Get(ctx, tCtx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return t.UnixMilli(), nil | ||
}, nil | ||
} |
Oops, something went wrong.