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

feat(outputs.azure_data_explorer): Added MS_Fabric with refactoring #16372

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

asaharn
Copy link
Contributor

@asaharn asaharn commented Jan 6, 2025

Summary

  • Added MS Fabric as output plugin
  • Refactored ADX and EH plugin to reuse common code.
  • Added corresponding test cases

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #16371

* Refactored ADX and EH plugin to reuse common code.
* Added corresponding test cases
@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Jan 6, 2025
@asaharn
Copy link
Contributor Author

asaharn commented Jan 13, 2025

Hi @srebhan, requesting for the review here. extending the changes we discussed on PR #16102

@asaharn asaharn closed this Jan 16, 2025
@asaharn asaharn force-pushed the feature/microsoft_fabric_connector branch from 597ed1f to 4e7821a Compare January 16, 2025 08:47
@asaharn asaharn reopened this Jan 16, 2025
@telegraf-tiger
Copy link
Contributor

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

@asaharn thanks for your contribution. I do have some comments in the code. Additionally, as a general comment, I suggest to split this PR into the following individual PRs:

  1. Move the azure_data_explorer common part to plugins/common/adx and convert the azure_data_explorer plugin to use it.
  2. Move the event_hubs common part to plugins/common/event_hubs and convert the event_hubs plugin to use it.
  3. Implement the new microsoft_fabric plugin based on the common parts.

I can assist with step 1 to give you a climpse on how I think things should look like... Let me know if you want me to help!

@@ -0,0 +1,286 @@
package adx_commons
Copy link
Member

Choose a reason for hiding this comment

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

Please name the package adx as the directory.

Comment on lines +11 to +15
"github.com/Azure/azure-kusto-go/kusto"
kustoerrors "github.com/Azure/azure-kusto-go/kusto/data/errors"

"github.com/Azure/azure-kusto-go/kusto/ingest"
"github.com/Azure/azure-kusto-go/kusto/kql"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"github.com/Azure/azure-kusto-go/kusto"
kustoerrors "github.com/Azure/azure-kusto-go/kusto/data/errors"
"github.com/Azure/azure-kusto-go/kusto/ingest"
"github.com/Azure/azure-kusto-go/kusto/kql"
"github.com/Azure/azure-kusto-go/kusto"
kustoerrors "github.com/Azure/azure-kusto-go/kusto/data/errors"
"github.com/Azure/azure-kusto-go/kusto/ingest"
"github.com/Azure/azure-kusto-go/kusto/kql"

"github.com/influxdata/telegraf/plugins/serializers/json"
)

var sampleConfig string
Copy link
Member

Choose a reason for hiding this comment

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

This is not something that should belong in common, this is plugin specific!

type AzureDataExplorer struct {
Endpoint string `toml:"endpoint_url"`
Database string `toml:"database"`
Log telegraf.Logger `toml:"-"`
Copy link
Member

Choose a reason for hiding this comment

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

Please move the logger to the plugin(s)!

Comment on lines +107 to +120
tableMetricGroups := make(map[string][]byte)
// Group metrics by name and serialize them
for _, m := range metrics {
tableName := m.Name()
metricInBytes, err := adx.serializer.Serialize(m)
if err != nil {
return err
}
if existingBytes, ok := tableMetricGroups[tableName]; ok {
tableMetricGroups[tableName] = append(existingBytes, metricInBytes...)
} else {
tableMetricGroups[tableName] = metricInBytes
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Serialization and grouping should happen in the plugin(s) if different data-formats should be supported!

Comment on lines +71 to +74
func (adx *AzureDataExplorer) SetSerializer(serializer telegraf.Serializer) {
adx.serializer = serializer
}

Copy link
Member

Choose a reason for hiding this comment

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

Remove here.


var sampleConfig string

type AzureDataExplorer struct {
Copy link
Member

Choose a reason for hiding this comment

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

Usually we do have a config here and a "factory" function to create a client instance from it. So I would call this Config and have a function to create aClient from it with no exported fields...

Copy link
Member

Choose a reason for hiding this comment

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

Please split the PR into one for azure_data_explorer and one for event_hubs!

kustoerrors "github.com/Azure/azure-kusto-go/kusto/data/errors"
"github.com/Azure/azure-kusto-go/kusto/ingest"
"github.com/Azure/azure-kusto-go/kusto/kql"
adx_commons "github.com/influxdata/telegraf/plugins/common/adx"
Copy link
Member

Choose a reason for hiding this comment

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

Please use the common_adx as alias as we are following this pattern for other "common" packages too.

Copy link
Member

Choose a reason for hiding this comment

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

Please keep the unit-tests as they were before to ensure the overall plugin mechanism works! Testing internal functions in common/adx is fine but the ones using the plugin interfaces (like Write) should stay as they are!

@srebhan srebhan self-assigned this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A new output plugin support for Microsoft fabric EventHouse and Eventstream
2 participants