@@ -20,7 +20,6 @@ import (
2020 "fmt"
2121 "net/http"
2222 "os"
23- "strings"
2423 "sync"
2524 "sync/atomic"
2625 "time"
@@ -407,20 +406,23 @@ func (i *integrationStats) statsDecorator(delegate AddFn) AddFn {
407406 return func () (Index , error ) {
408407 idx , err := f ()
409408 attr := []attribute.KeyValue {}
410- pushbackType := "" // This will be used for the pushback attribute below, empty string means no pushback
411409
412410 if err != nil {
413- if errors .Is (err , ErrPushback ) {
414- // record the the fact there was pushback, and use the error string as the type.
415- pushbackType = err .Error ()
416- } else {
417- // Just flag that it's an errored request to avoid high cardinality of attribute values.
411+ switch {
412+ // Record the fact there was pushback, if any.
413+ case errors .Is (err , ErrPushbackAntispam ):
414+ attr = append (attr , attribute .String ("tessera.pushback" , "antispam" ))
415+ case errors .Is (err , ErrPushbackIntegration ):
416+ attr = append (attr , attribute .String ("tessera.pushback" , "integration" ))
417+ case errors .Is (err , ErrPushback ):
418+ attr = append (attr , attribute .String ("tessera.pushback" , "other" ))
419+ default :
420+ // If it's not a pushback, just flag that it's an errored request to avoid high cardinality of attribute values.
418421 // TODO(al): We might want to bucket errors into OTel status codes in the future, though.
419422 attr = append (attr , attribute .String ("tessera.error.type" , "_OTHER" ))
420423 }
421424 }
422425
423- attr = append (attr , attribute .String ("tessera.pushback" , strings .ReplaceAll (pushbackType , " " , "_" )))
424426 attr = append (attr , attribute .Bool ("tessera.duplicate" , idx .IsDup ))
425427
426428 appenderAddsTotal .Add (ctx , 1 , metric .WithAttributes (attr ... ))
0 commit comments