-
Notifications
You must be signed in to change notification settings - Fork 139
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
Allow exporting JS metadata #318
base: main
Are you sure you want to change the base?
Allow exporting JS metadata #318
Conversation
@@ -27,10 +27,10 @@ test-cov: | |||
|
|||
.PHONY: lint | |||
lint: | |||
@PATH=$(shell go env GOPATH)/bin:$(PATH) | |||
@PATH=$(shell go env GOBIN):$(PATH) |
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.
this seemed to make some assumptions on workspace layout which were not true on my machine, feel free to ignore
// NewJszCollector creates a new NATS JetStream Collector. | ||
func NewJszCollector( | ||
endpoint, prefix string, | ||
servers []*CollectedServer, | ||
streamMetaKeys, consumerMetaKeys []string, | ||
) prometheus.Collector { | ||
return newJszCollector(getSystem(JetStreamSystem, prefix), endpoint, servers, streamMetaKeys, consumerMetaKeys) | ||
} |
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.
There is a separate code path now for JetStream collectors to be able to supply the meta keys. This seemed better than to pass the arguments around for the other collectors where they wouldn't be used.
This makes JS collectors somewhat of a special case in the code, not sure if you like it that way.
splitOrEmpty := func(s string) []string { | ||
if s == "" { | ||
return []string{} | ||
} | ||
return strings.Split(s, ",") | ||
} | ||
streamMetaKeys := splitOrEmpty(opts.JszSteamMetaKeys) | ||
consumerMetaKeys := splitOrEmpty(opts.JszConsumerMetaKeys) | ||
ne.createJszCollector(opts.GetJszFilter, streamMetaKeys, consumerMetaKeys) |
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.
It may be smart to validate that the resulting label names are actually valid in Prometheus. WDYT?
@@ -201,7 +201,7 @@ func RunJetStreamServerWithPorts(port, monitorPort int, domain string) *server.S | |||
opts.JetStream = true | |||
opts.JetStreamDomain = domain | |||
tdir, _ := os.MkdirTemp(tempRoot, "js-storedir-") | |||
opts.StoreDir = filepath.Dir(tdir) | |||
opts.StoreDir = tdir |
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.
IMHO, this was a bug. It always selected the parent directory of the tdir
, effectively re-using the same director always.
Also: I had to create that parent directory by hand. Are you sure that is intended?
for _, k := range streamMetaKeys { | ||
streamLabels = append(streamLabels, "stream_meta_"+k) | ||
} |
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.
Stream metadata is exported as labels named stream_meta_…
, making sure they don't conflict with consumer metadata defined below.
Maybe it would actually be nice to combine these, WDYT?
Implementation of #317