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
Implement logging telemetry log 1926 #1264
Implement logging telemetry log 1926 #1264
Conversation
3d00eba
to
f46b76f
Compare
/test functional |
} | ||
|
||
var ( | ||
ClTelData = New() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global variable is not good practice, make this a member of the reconciler or some other suitable home.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanconway i see that EO also implemented by declaring global variables part of their metrics package. i wanted to do minimal changes to existing CLO stack and keep all new changes / implementation confining to this telemetry package. do you still think we should make this data a member of reconciler ? let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is a concurrent-unsafe pattern. Even if it is implemented safely today it is much too easy for someone who doesn't understand the concurrency rules to make an unsafe reference in new code.
Lets leave it global but use a concurrent-safe map for now. Patch below for a concurrent-safe string map.
I'd like to review the pattern in future, but for now that should do the trick.
diff --git a/internal/utils/stringmap.go b/internal/utils/stringmap.go
new file mode 100644
index 000000000..de1e10bc9
--- /dev/null
+++ b/internal/utils/stringmap.go
@@ -0,0 +1,28 @@
+package utils
+
+import "sync"
+
+// StringMap is a concurrent-safe map[string]string based on sync.Map
+type StringMap struct{ m sync.Map }
+
+// GetOK returns (value, true) if key is present and ("", false) if absent.
+func (m *StringMap) GetOK(key string) (s string, ok bool) {
+ x, ok := m.m.Load(key)
+ if ok {
+ s = x.(string)
+ }
+ return s, ok
+}
+
+// Get returns the value, or "" if the key is absent.
+func (m *StringMap) Get(key string) string {
+ if s, ok := m.GetOK(key); ok == true {
+ return s
+ }
+ return ""
+}
+
+// Set sets key to value.
+func (m *StringMap) Set(key, value string) {
+ m.m.Store(key, value)
+}
diff --git a/internal/utils/stringmap_test.go b/internal/utils/stringmap_test.go
new file mode 100644
index 000000000..ed008f6c7
--- /dev/null
+++ b/internal/utils/stringmap_test.go
@@ -0,0 +1,20 @@
+package utils
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestStringMap(t *testing.T) {
+ m := StringMap{}
+ assert.Equal(t, "", m.Get("x"))
+ s, ok := m.GetOK("x")
+ assert.Equal(t, "", s)
+ assert.False(t, ok)
+ m.Set("x", "y")
+ assert.Equal(t, "y", m.Get("x"))
+ s, ok = m.GetOK("x")
+ assert.Equal(t, "y", s)
+ assert.True(t, ok)
+}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanconway resolved
4718839
to
729a1c7
Compare
729a1c7
to
d9211c6
Compare
5bd9862
to
d77f402
Compare
3349b37
to
d5704a4
Compare
58412aa
to
79f91d6
Compare
/test e2e |
2a2486c
to
33cc2fa
Compare
/test e2e |
1 similar comment
/test e2e |
bc4fdfe
to
52402af
Compare
/test e2e |
975e42c
to
4d97ad8
Compare
54c85b9
to
0de832b
Compare
0de832b
to
07c9767
Compare
/test e2e |
@pmoogi-redhat: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alanconway, pmoogi-redhat The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…g-telemetry-LOG-1926 Implement logging telemetry log 1926
Description
Story
As a member of the OpenShift Logging Team, I want telemetry metrics of the CLO
so that we have a better understanding of how CLF is being utilized by customers (e.g. which outputs)
Acceptance Criteria
Verifying telemetry metrics are available from the CLO metrics endpoint in prometheus
/cc @jcantrill @alanconway
/assign
Links