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

Update metrics sample with newer Prometheus suggestions #181

Closed
cretz opened this issue Mar 21, 2022 · 1 comment
Closed

Update metrics sample with newer Prometheus suggestions #181

cretz opened this issue Mar 21, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@cretz
Copy link
Member

cretz commented Mar 21, 2022

Describe the solution you'd like

When temporalio/sdk-go#756 is released, apply this:

diff --git a/metrics/worker/main.go b/metrics/worker/main.go
index c1dc254..e3dde80 100644
--- a/metrics/worker/main.go
+++ b/metrics/worker/main.go
@@ -53,35 +53,12 @@ func newPrometheusScope(c prometheus.Configuration) tally.Scope {
        scopeOpts := tally.ScopeOptions{
                CachedReporter:  reporter,
                Separator:       prometheus.DefaultSeparator,
-               SanitizeOptions: &sanitizeOptions,
+               SanitizeOptions: &sdktally.PrometheusSanitizeOptions,
                Prefix:          "temporal_samples",
        }
        scope, _ := tally.NewRootScope(scopeOpts, time.Second)
+       scope = sdktally.NewPrometheusNamingScope(scope)

        log.Println("prometheus metrics scope created")
        return scope
 }
-
-// tally sanitizer options that satisfy Prometheus restrictions.
-// This will rename metrics at the tally emission level, so metrics name we
-// use maybe different from what gets emitted. In the current implementation
-// it will replace - and . with _
-var (
-       safeCharacters = []rune{'_'}
-
-       sanitizeOptions = tally.SanitizeOptions{
-               NameCharacters: tally.ValidCharacters{
-                       Ranges:     tally.AlphanumericRange,
-                       Characters: safeCharacters,
-               },
-               KeyCharacters: tally.ValidCharacters{
-                       Ranges:     tally.AlphanumericRange,
-                       Characters: safeCharacters,
-               },
-               ValueCharacters: tally.ValidCharacters{
-                       Ranges:     tally.AlphanumericRange,
-                       Characters: safeCharacters,
-               },
-               ReplacementCharacter: tally.DefaultReplacementCharacter,
-       }
-)
@cretz cretz added the enhancement New feature or request label Mar 21, 2022
@Quinn-With-Two-Ns
Copy link
Contributor

Closing as this change was done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants