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/filter] Add functionality to allow filtering on SeverityNumber #13002

Merged
Prev Previous commit
Next Next commit
add license, fix test
  • Loading branch information
BinaryFissionGames authored and djaglowski committed Aug 11, 2022
commit d3e8dbd12b4bafa1f6d60e3a8b38ac5e04bdf1bd
16 changes: 15 additions & 1 deletion internal/coreinternal/processor/filterlog/severity_matcher.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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:https://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 filterlog

import (
Expand All @@ -20,7 +34,7 @@ func newSeverityNumberMatcher(minSeverity plog.SeverityNumber, matchUndefined bo
}

func (snm severityNumberMatcher) MatchLogRecord(lr plog.LogRecord, _ pcommon.Resource, _ pcommon.InstrumentationScope) bool {
// We explicitly do not match UNDEFINED severity.
// behavior on SeverityNumberUNDEFINED is explicitly defined by matchUndefined
if lr.SeverityNumber() == plog.SeverityNumberUNDEFINED {
return snm.matchUndefined
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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:https://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 filterlog

import (
Expand Down Expand Up @@ -63,7 +77,7 @@ func TestSeverityMatcher_MatchLogRecord(t *testing.T) {
minSeverity: plog.SeverityNumberUNDEFINED,
matchUndefined: true,
inputSeverity: plog.SeverityNumberUNDEFINED,
matches: false,
matches: true,
},
}

Expand Down