Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/transform] Add ContextStatements config #15382

Merged
merged 29 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
07457a8
Add ContextStatements config
TylerHelmuth Oct 21, 2022
5f8471c
Add high-level context
TylerHelmuth Oct 25, 2022
2da5d8a
Merge branch 'open-telemetry:main' into tp-enhanced-contexts-2
TylerHelmuth Oct 26, 2022
ffc1fee
respond to feedback
TylerHelmuth Oct 27, 2022
38b7d9c
Fix merge
TylerHelmuth Oct 27, 2022
9133edf
Merge branch 'open-telemetry:main' into tp-enhanced-contexts-2
TylerHelmuth Oct 27, 2022
cab0096
Merge branch 'open-telemetry:main' into tp-enhanced-contexts-2
TylerHelmuth Oct 28, 2022
edfe1a4
Adjust ParserCollection
TylerHelmuth Oct 31, 2022
cdf7c7e
Add example usage temporarily
TylerHelmuth Oct 31, 2022
a19bd17
apply feedback
TylerHelmuth Oct 31, 2022
14d60b1
Split into individual files
TylerHelmuth Nov 1, 2022
7e044a4
merge in upstream/main
TylerHelmuth Nov 2, 2022
8950da0
Add spanevent and metric contexts
TylerHelmuth Nov 2, 2022
438ce15
revert logs processor example
TylerHelmuth Nov 2, 2022
34ff332
Fix NewParserCollection
TylerHelmuth Nov 2, 2022
83acb90
Fix lint
TylerHelmuth Nov 2, 2022
2b0db77
Fix checks
TylerHelmuth Nov 2, 2022
0db5378
Refactor ParserCollection to have a base
TylerHelmuth Nov 5, 2022
1bb36bc
Merge remote-tracking branch 'upstream/main' into tp-enhanced-contexts-2
TylerHelmuth Nov 5, 2022
ca2b55d
Update interface to handle context.Context
TylerHelmuth Nov 5, 2022
fecfb09
cleanup var names
TylerHelmuth Nov 5, 2022
fd20cfb
Fix case statement
TylerHelmuth Nov 5, 2022
9c5d53e
Implement UnmarshalText for ContextID
TylerHelmuth Nov 7, 2022
bf06646
Switch to consumer.Signal
TylerHelmuth Nov 7, 2022
3291593
Fix lint
TylerHelmuth Nov 7, 2022
f95c418
Update processor/transformprocessor/internal/common/logs.go
TylerHelmuth Nov 7, 2022
7964803
Update processor/transformprocessor/internal/common/metrics.go
TylerHelmuth Nov 7, 2022
98feb98
apply feedback
TylerHelmuth Nov 7, 2022
8bb990d
Add back Options for each parser
TylerHelmuth Nov 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions processor/transformprocessor/internal/common/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package common // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/common"

const (
Resource string = "resource"
Scope string = "scope"
Trace string = "trace"
DataPoint string = "datapoint"
Log string = "log"
)

type ContextStatements struct {
Context string `mapstructure:"context"`
Statements []string `mapstructure:"statements"`
}
10 changes: 10 additions & 0 deletions processor/transformprocessor/internal/common/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package common // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/common"

import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlresource"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlscope"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs"
)

Expand All @@ -38,3 +40,11 @@ func Functions[K any]() map[string]interface{} {
"delete_matching_keys": ottlfuncs.DeleteMatchingKeys[K],
}
}

func ResourceFunctions() map[string]interface{} {
return Functions[ottlresource.TransformContext]()
}

func ScopeFunctions() map[string]interface{} {
return Functions[ottlscope.TransformContext]()
}
Comment on lines +44 to +50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need these specialized calls?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdandrutu I made specialized calls to represent the possibility of Resource-only functions or Scope-only functions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need a public API for that, just add a comment to the "Functions" that can be initialized with multiple contexts.

Copy link
Member Author

@TylerHelmuth TylerHelmuth Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdandrutu This isn't a public API, it would never be moved to the OTTL. This is a way for the transform processor to enforce its definition of what functions are allowed to be used for Scope and Resource. Similar to how each signal in the transform processor has their own functions.go.

Loading