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

Legacy metrics capture -> ActiveMetrics adapter #15710

Merged
merged 4 commits into from
Aug 7, 2017

Conversation

chrisarcand
Copy link
Member

@chrisarcand chrisarcand commented Aug 2, 2017

This moves the current write interface in metrics processing to an ActiveMetrics adapter pattern.

Presumably one can now write an adapter for a different backend such as Elasticsearch that conforms to this interface with minimal hair pulling.

@chrisarcand chrisarcand force-pushed the active-metrics-spike branch 2 times, most recently from 47e730b to fa75c6b Compare August 2, 2017 15:30
@miq-bot miq-bot added the wip label Aug 2, 2017
@chessbyte chessbyte requested a review from blomquisg August 2, 2017 16:34
I don't see a reason we need to do this, and it actually breaks the
tests in some way as that's not the format of the original implementation.
Because Rubocop hates nice things.
@chrisarcand chrisarcand force-pushed the active-metrics-spike branch from 69f99b2 to b93e411 Compare August 2, 2017 19:12
@chrisarcand chrisarcand changed the title [WIP] Legacy metrics capture -> ActiveMetrics adapter Legacy metrics capture -> ActiveMetrics adapter Aug 2, 2017
@chrisarcand
Copy link
Member Author

Ready to roll, @blomquisg @Fryguy

@@ -0,0 +1 @@
ActiveMetrics::Base.establish_connection(:adapter => "miq_postgres", :database => "metrics_spike")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this gets merged the database will need to change...I'm guessing this would end up being Rails.database_configuration.database (or however you get it)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I guess it doesn't really matter, but if we switch adapters, I'm thinking the database name should be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O_o Good catch, it absolutely matters does it not? This should absolutely fall on its face without a change.

Copy link
Member Author

@chrisarcand chrisarcand Aug 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, forgot the adapter here just steals AR::Base's, nevermind.

{}.tap do |index|
metrics.each do |m|
interval_name = m.fetch_path(:tags, :capture_interval_name)
resource = m[:resource] || m.fetch_path(:tags, :resource_type).safe_constantize.find(m.fetch_path(:tags, :resource_id))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting...I didn't expect the resource_type to be in a tag. I thought for the other adapters, resource_type and resource_id were top-level keys.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're top level in the metric (a realtime row) but are written as 'tags' in each respective adapter. You had said you took that from Influx, where tags are indexed (values are not). Unsure if it really makes sense to differentiate, but we can change that later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably doesn't make much of a difference for now because the caller is sending :resource anyway

@Fryguy
Copy link
Member

Fryguy commented Aug 4, 2017

@chrisarcand Where do the bottlenecks happen? I remember in my initial spike on this, I had brought that over (even though it shouldn't be brought over), but I don't see it here at all, which was surprising.

@chrisarcand
Copy link
Member Author

Where do the bottlenecks happen? I remember in my initial spike on this, I had brought that over (even though it shouldn't be brought over), but I don't see it here at all, which was surprising.

@Fryguy Bottlenecks? I'm not sure what you're referring to.

@miq-bot
Copy link
Member

miq-bot commented Aug 4, 2017

Checked commits chrisarcand/manageiq@8698abe~...3c5ae5b with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 1 offense detected

lib/active_metrics/connection_adapters/miq_postgres_adapter.rb

  • ❗ - Line 8, Col 9 - Style/CommentAnnotation - Annotation keywords like TODO should be all upper case, followed by a colon, and a space, then a note describing the problem.

@Fryguy
Copy link
Member

Fryguy commented Aug 7, 2017

@chrisarcand I'm referring to the Bottleneck calculations. However, the reason I don't see it is because it lives in rollups :

Benchmark.realtime_block(:process_bottleneck) { BottleneckEvent.generate_future_events(self) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants