forked from dapr/dapr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/dapr/dapr into grpc-update
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
- Loading branch information
Showing
41 changed files
with
3,228 additions
and
573 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package diagnostics | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.opencensus.io/stats/view" | ||
) | ||
|
||
func servicesMetrics() *serviceMetrics { | ||
s := newServiceMetrics() | ||
s.Init("testAppId") | ||
|
||
return s | ||
} | ||
|
||
func TestServiceInvocation(t *testing.T) { | ||
t.Run("record service invocation request sent", func(t *testing.T) { | ||
s := servicesMetrics() | ||
|
||
s.ServiceInvocationRequestSent("testAppId2", "testMethod") | ||
|
||
viewData, _ := view.RetrieveData("runtime/service_invocation/req_sent_total") | ||
v := view.Find("runtime/service_invocation/req_sent_total") | ||
|
||
allTagsPresent(t, v, viewData[0].Tags) | ||
}) | ||
|
||
t.Run("record service invoation request received", func(t *testing.T) { | ||
s := servicesMetrics() | ||
|
||
s.ServiceInvocationRequestReceived("testAppId", "testMethod") | ||
|
||
viewData, _ := view.RetrieveData("runtime/service_invocation/req_recv_total") | ||
v := view.Find("runtime/service_invocation/req_recv_total") | ||
|
||
allTagsPresent(t, v, viewData[0].Tags) | ||
}) | ||
|
||
t.Run("record service invocation response sent", func(t *testing.T) { | ||
s := servicesMetrics() | ||
|
||
s.ServiceInvocationResponseSent("testAppId2", "testMethod", 200) | ||
|
||
viewData, _ := view.RetrieveData("runtime/service_invocation/res_sent_total") | ||
v := view.Find("runtime/service_invocation/res_sent_total") | ||
|
||
allTagsPresent(t, v, viewData[0].Tags) | ||
}) | ||
|
||
t.Run("record service invocation response received", func(t *testing.T) { | ||
s := servicesMetrics() | ||
|
||
s.ServiceInvocationResponseReceived("testAppId", "testMethod", 200, time.Now()) | ||
|
||
viewData, _ := view.RetrieveData("runtime/service_invocation/res_recv_total") | ||
v := view.Find("runtime/service_invocation/res_recv_total") | ||
|
||
allTagsPresent(t, v, viewData[0].Tags) | ||
|
||
viewData2, _ := view.RetrieveData("runtime/service_invocation/res_recv_latency_ms") | ||
v2 := view.Find("runtime/service_invocation/res_recv_latency_ms") | ||
|
||
allTagsPresent(t, v2, viewData2[0].Tags) | ||
}) | ||
} | ||
|
||
func TestSerivceMonitoringInit(t *testing.T) { | ||
c := servicesMetrics() | ||
assert.True(t, c.enabled) | ||
assert.Equal(t, c.appID, "testAppId") | ||
} |
Oops, something went wrong.