Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

[WIP - GH-42] Add Service Bus Subscription Count Client #49

Closed
wants to merge 8 commits into from
Closed

[WIP - GH-42] Add Service Bus Subscription Count Client #49

wants to merge 8 commits into from

Conversation

marc-sensenich
Copy link
Contributor

@marc-sensenich marc-sensenich commented Nov 18, 2018

Allow for users of the metrics adapter to gather message counts from Azure Service Bus Topic Subscriptions to decide their scaling targets

Closes #42

import (
"context"

"github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I currently use the Azure SDK for Go as it allowed for the retrieval of each type of count within CountDetails. In the current case of azure-service-bus-go this number can be skewed if there are letters in the DLQ not being pulled

Copy link
Collaborator

Choose a reason for hiding this comment

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

what is DLQ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marc-sensenich
Copy link
Contributor Author

Based on #39, this is the structure I'd see for configuring the CRD

apiVersion: azure.com/v1alpha2
kind: ExternalMetric
metadata:
  name: example-external-metric-service-bus-subscription
spec:
  type: servicebussubscription
  azure:
    resourceGroup: storage-rg
    namespace: sample-ns
    topic: sample-topic
    subscription: sample-subscription
  metric:
    # This would default to activeMessageCount, but could be updated to one of the counts from https://github.com/Azure/azure-sdk-for-go/blob/master/services/servicebus/mgmt/2017-04-01/servicebus/models.go#L1116
    field: activeMessageCount

Copy link
Collaborator

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

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

Thanks so much for working on this! Gave initial thoughts. I didn't see were it was wired up in the provider... I assume your still working on it but like the general direction 👍

main.go Outdated
monitorClient := monitor.NewClient(defaultSubscriptionID)
appinsightsClient := appinsights.NewClient()

azureProvider := azureprovider.NewAzureProvider(defaultSubscriptionID, mapper, dynamicClient, appinsightsClient, monitorClient, metricsCache)
azureProvider := azureprovider.NewAzureProvider(defaultSubscriptionID, mapper, dynamicClient, appinsightsClient, monitorClient, serviceBusSubscriptionClient, metricsCache)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this will get unwieldy as we add more clients such as the Storage bus client. I suggest we create a factory that creates the correct client based on the type specified in the new spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I'll move it towards the factory pattern


type AzureExternalMetricClient interface {
GetAzureMetric(azMetricRequest AzureExternalMetricRequest) (AzureExternalMetricResponse, error)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks good and right along the lines of what I was thinking.

merticReq.Filter = fmt.Sprintf("%s %s '%s'", filterStrings[0], filterStrings[1], filterStrings[2])
glog.V(2).Infof("filter formatted: %s", merticReq.Filter)
// Service Bus
case "namespace":
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to continue to update this function. It was a left over the first attempt that proved not to work very well. My plan is to depreciate the support of label selectors as we approach 1.0 and only support CRD's. I left this in for now for anyone that might have had something running so as to not break existing solutions but don't want to encourage using it any further.

import (
"context"

"github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus"
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is DLQ?

@marc-sensenich
Copy link
Contributor Author

@jsturtevant currently didn't link up the providers just yet as I didn't want to get too far into the weeds without agreement from your end. I'll keep it moving forward based on the initial feedback

@jsturtevant
Copy link
Collaborator

Looks good to move forward on. Let me know if there are any challenges or blockers. Thanks again!

@jsturtevant
Copy link
Collaborator

Just checking in to see of there are any blockers I can help with.

@marc-sensenich
Copy link
Contributor Author

No blockers currently. I got backlogged on professional and personal commitments and will be getting back to this PR.

@jsturtevant
Copy link
Collaborator

@marc-sensenich Thanks so much for this PR. On Friday afternoon I was going to take the great start you have here and start to finish it up for the next release. Let me know if you have any thoughts or objections.

@marc-sensenich
Copy link
Contributor Author

marc-sensenich commented Jan 23, 2019

@jsturtevant my apologies for leaving this one hanging. I have no objections from you getting this put together for the next release. I have some lingering changes I'll push up here and then you can keep them or drop them

@jsturtevant
Copy link
Collaborator

Thanks and no worries! I appreciate the initial start to this. I have a few spare cycles coming up and this is a frequently asked for feature. So thank you for getting it started!

@jsturtevant
Copy link
Collaborator

I am closing this as I did not have permissions to push changes to @marc-sensenich branch. Thanks for your initial implementation!

@jsturtevant jsturtevant closed this Feb 2, 2019
@marc-sensenich
Copy link
Contributor Author

Thanks for taking this over @jsturtevant!

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

Successfully merging this pull request may close these issues.

2 participants