-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce metrics for failed evaluations (#584)
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> - introduced a new metric which buckets evaluations by reason - small refactoring - unit tests ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> Fixes #559 ### How to test Run flagd via ``` make run ``` Run ``` curl -X POST "localhost:8013/schema.v1.Service/ResolveString" -d '{"flagKey":"fibAlgo","context":{}}' -H "Content-Type: application/json" curl -X POST "localhost:8013/schema.v1.Service/ResolveString" -d '{"flagKey":"myStringFlag","context":{}}' -H "Content-Type: application/json" curl -X POST "localhost:8013/schema.v1.Service/ResolveString" -d '{"flagKey":"myStringFlagNonExisting","context":{}}' -H "Content-Type: application/json" curl -X POST "localhost:8013/schema.v1.Service/ResolveString" -d '{"flagKey":"myStringFlagNonExisting2","context":{}}' -H "Content-Type: application/json" curl -X POST "localhost:8013/schema.v1.Service/ResolveInt" -d '{"flagKey":"myStringFlag","context":{}}' -H "Content-Type: application/json" ``` Open http://localhost:8014/metrics and see something like the following ``` # HELP impressions_total The number of evaluation for a given flag # TYPE impressions_total counter impressions_total{feature_flag_key="fibAlgo",feature_flag_provider_name="flagd",feature_flag_reason="DEFAULT",feature_flag_variant="recursive",otel_scope_name="openfeature/flagd",otel_scope_version=""} 1 impressions_total{feature_flag_key="myStringFlag",feature_flag_provider_name="flagd",feature_flag_reason="STATIC",feature_flag_variant="key1",otel_scope_name="openfeature/flagd",otel_scope_version=""} 1 ``` and ``` # HELP reasons_total The number of evaluations for a given reason # TYPE reasons_total counter reasons_total{feature_flag_provider_name="flagd",feature_flag_reason="DEFAULT",otel_scope_name="openfeature/flagd",otel_scope_version=""} 1 reasons_total{feature_flag_provider_name="flagd",feature_flag_reason="STATIC",otel_scope_name="openfeature/flagd",otel_scope_version=""} 1 reasons_total{exception_type="FLAG_NOT_FOUND",feature_flag_provider_name="flagd",feature_flag_reason="ERROR",otel_scope_name="openfeature/flagd",otel_scope_version=""} 2 reasons_total{exception_type="TYPE_MISMATCH",feature_flag_provider_name="flagd",feature_flag_reason="ERROR",otel_scope_name="openfeature/flagd",otel_scope_version=""} 1 ``` Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com> Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com> Co-authored-by: James Milligan <75740990+james-milligan@users.noreply.github.com>
- Loading branch information
1 parent
c25d0ef
commit 77664cd
Showing
7 changed files
with
155 additions
and
50 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
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,20 @@ | ||
package eval | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAnyValue(t *testing.T) { | ||
obj := AnyValue{ | ||
Value: "val", | ||
Variant: "variant", | ||
Reason: "reason", | ||
FlagKey: "key", | ||
Error: fmt.Errorf("err"), | ||
} | ||
|
||
require.Equal(t, obj, NewAnyValue("val", "variant", "reason", "key", fmt.Errorf("err"))) | ||
} |
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
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
Oops, something went wrong.