Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jkraml-staffbase
Copy link

@jkraml-staffbase jkraml-staffbase commented Nov 12, 2024

Implementation of #317

@@ -27,10 +27,10 @@ test-cov:

.PHONY: lint
lint:
@PATH=$(shell go env GOPATH)/bin:$(PATH)
@PATH=$(shell go env GOBIN):$(PATH)
Copy link
Author

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

Comment on lines +502 to +509
// 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)
}
Copy link
Author

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.

Comment on lines +239 to +247
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)
Copy link
Author

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
Copy link
Author

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?

Comment on lines +83 to +85
for _, k := range streamMetaKeys {
streamLabels = append(streamLabels, "stream_meta_"+k)
}
Copy link
Author

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?

# Conflicts:
#	collector/jsz.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant