-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 business logic for handling traces queries. #7300
Changes from 6 commits
33715c7
d234f06
a778335
e4273ee
cc83968
e408791
18ee45b
0f3e6f9
98582e2
f88a0be
3673a56
c55590a
d870f2a
ab6e397
43357f7
75ae504
bc8f619
70a87b4
5a8b421
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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 traces // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/traces" | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go.opentelemetry.io/collector/model/pdata" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/common" | ||
) | ||
|
||
type condFunc = func(span pdata.Span, il pdata.InstrumentationLibrary, resource pdata.Resource) bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make this a "3" stage check?
I think this way we don't have to repeat the checks on the "resource" for every span. I may have already mentioned this idea, but I think it may be an important optimization. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checks generally evaluate in well less than a microsecond right now so was hoping to do this as a future optimization. I don't think this effects the query DSL, just the implementation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are correct, but may affect the "supported" function signatures, so we better do not open yet the API to allow external funcs until we finalize that. |
||
|
||
var alwaysTrue = func(span pdata.Span, il pdata.InstrumentationLibrary, resource pdata.Resource) bool { | ||
return true | ||
} | ||
|
||
func newConditionEvaluator(cond *common.Condition) (condFunc, error) { | ||
if cond == nil { | ||
return alwaysTrue, nil | ||
} | ||
left, err := newGetter(cond.Left) | ||
if err != nil { | ||
return nil, err | ||
} | ||
right, err := newGetter(cond.Right) | ||
// TODO(anuraaga): Check if both left and right are literals and const-evaluate | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
switch cond.Op { | ||
case "==": | ||
return func(span pdata.Span, il pdata.InstrumentationLibrary, resource pdata.Resource) bool { | ||
a := left.get(span, il, resource) | ||
b := right.get(span, il, resource) | ||
return a == b | ||
}, nil | ||
anuraaga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case "!=": | ||
return func(span pdata.Span, il pdata.InstrumentationLibrary, resource pdata.Resource) bool { | ||
a := left.get(span, il, resource) | ||
b := right.get(span, il, resource) | ||
return a != b | ||
}, nil | ||
} | ||
|
||
return nil, fmt.Errorf("unrecognized boolean operation %v", cond.Op) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix after confirming the approach for config validation