-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bring in copy of stanza operator helper and include severity in…
… expr env for stanza entries
- Loading branch information
1 parent
7960b17
commit 1a3a4ef
Showing
3 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
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