-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signozlogspipelineprocessor: add support for using severity in route …
…operator (pipeline filter) expressions (#405) Contributes to SigNoz/engineering-pod#1446
- Loading branch information
1 parent
8969d16
commit 629ff58
Showing
4 changed files
with
92 additions
and
4 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
38 changes: 38 additions & 0 deletions
38
processor/signozlogspipelineprocessor/stanza/operator/helper/expr.go
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 @@ | ||
// Mostly brought in as-is from otel-collector-contrib with minor changes | ||
// For example: includes severity_text and severity_number in GetExprEnv | ||
|
||
package signozstanzahelper | ||
|
||
import ( | ||
"os" | ||
"sync" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry" | ||
) | ||
|
||
var envPool = sync.Pool{ | ||
New: func() any { | ||
return map[string]any{ | ||
"os_env_func": os.Getenv, | ||
} | ||
}, | ||
} | ||
|
||
// GetExprEnv returns a map of key/value pairs that can be be used to evaluate an expression | ||
func GetExprEnv(e *entry.Entry) map[string]any { | ||
env := envPool.Get().(map[string]any) | ||
env["$"] = e.Body | ||
env["body"] = e.Body | ||
env["attributes"] = e.Attributes | ||
env["resource"] = e.Resource | ||
env["timestamp"] = e.Timestamp | ||
env["severity_text"] = e.SeverityText | ||
env["severity_number"] = int(e.Severity) | ||
|
||
return env | ||
} | ||
|
||
// PutExprEnv adds a key/value pair that will can be used to evaluate an expression | ||
func PutExprEnv(e map[string]any) { | ||
envPool.Put(e) | ||
} |
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