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

Fix Jira Metrics Behavior #5360

Conversation

Galactus22625
Copy link
Member

Description

Jira Metrics were showing up under aws.jira and aws.jiraRestClient and crawer.sourceCrawler instead of
jira.pipelineName.

Fixed this issue

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…man (fix jira metrics behavior)

Signed-off-by: Maxwell Brown <[email protected]>

public JiraService(JiraSourceConfig jiraSourceConfig, JiraRestClient jiraRestClient) {
this.jiraSourceConfig = jiraSourceConfig;
this.jiraRestClient = jiraRestClient;
}

public void setPluginMetrics(PluginMetrics pluginMetrics){
Copy link
Member

Choose a reason for hiding this comment

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

Can pluginMetrics be added as part of JiraService constructor line 66 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried that and it doesnt work because JiraService is a bean I think

Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the the bean annotation for JiraService ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that would cause a lot of problems? not sure tho have to ask @san81

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dinujoh we are using Spring dependency injection here. We are not instantiating JiraService ourself. Spring DI is instantiating it and for Spring DI, any constructor parameter should also be a spring bean otherwise, it won't inject as the constructor argument. If PluginMetrics is a spring bean then constructor argument will work but it is not.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/opensearch-project/data-prepper/blob/main/data-prepper-plugins/saas-source-plugins/jira-source/src/main/java/org/opensearch/dataprepper/plugins/source/jira/JiraService.java

Does this needs to use Spring dependency injection ? I was recommending to create the instance when needed in the client for example in JiraSource without using Spring DI

Copy link
Member

Choose a reason for hiding this comment

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

Why can't we include PluginMetrics in the context so that we can provide it via the application context? That would be a good long-term solution.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The idea is that, as we add additional SAAS sources, the common code in source-crawler will dynamically bind with one of the implementation in a specific SAAS source like Jira or Confluence etc. That is why we started using Spring DI in these source plugins.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dlvenable Yah, I like the approach to include PluginMetrics in the application context. We will try that approach and update here.

@@ -54,9 +55,15 @@ public JiraSource(final PluginMetrics pluginMetrics,
final PluginFactory pluginFactory,
final AcknowledgementSetManager acknowledgementSetManager,
Crawler crawler,
PluginExecutorServiceProvider executorServiceProvider) {
PluginExecutorServiceProvider executorServiceProvider,
final JiraService jiraService,
Copy link
Member

Choose a reason for hiding this comment

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

How is this injected here ? Can JiraService be initialized in the JiraSource constructor ? and pass pluginMetrics to the JiraService constructor ?

Copy link
Member Author

Choose a reason for hiding this comment

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

tried passing in pluginMetrics to jiraService constructor but doesn't work because jira service is a bean i think. Jira Service can be initialized in jiraSource constructor for the same reason

super(PLUGIN_NAME, pluginMetrics, jiraSourceConfig, pluginFactory, acknowledgementSetManager, crawler, executorServiceProvider);
log.info("Creating Jira Source Plugin");
jiraService.setPluginMetrics(pluginMetrics);
crawler.setPluginMetrics(pluginMetrics);
Copy link
Member

Choose a reason for hiding this comment

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

Same comment for crawler initialization.

Copy link
Member Author

Choose a reason for hiding this comment

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

same as jira service. Also crawler will be shared by multiple source plugins in the future


public void setPluginMetrics(PluginMetrics pluginMetrics){
Copy link
Member

Choose a reason for hiding this comment

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

Can pluginMetrics be passed in JiraRestClient constructor ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No for the same reason as Jira Service


public JiraService(JiraSourceConfig jiraSourceConfig, JiraRestClient jiraRestClient) {
this.jiraSourceConfig = jiraSourceConfig;
this.jiraRestClient = jiraRestClient;
}

public void setPluginMetrics(PluginMetrics pluginMetrics){
Copy link
Member

Choose a reason for hiding this comment

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

Why can't we include PluginMetrics in the context so that we can provide it via the application context? That would be a good long-term solution.

@Galactus22625 Galactus22625 deleted the fix-metrics-then-cherry-pick branch January 31, 2025 20:28
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.

4 participants