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

Provide better usage of AzureMonitorClient #844

Merged
merged 9 commits into from
Feb 20, 2020
Merged

Conversation

tomkerkhove
Copy link
Owner

@tomkerkhove tomkerkhove commented Jan 18, 2020

Provide better usage of AzureMonitorClient by only creating it once.

Relates to #798

Before

image
image

After

72669608-4ba47180-3a34-11ea-9f3e-0f5c5a5f863b
72669622-7ee70080-3a34-11ea-8f96-9074fbdaf179

@promitor-bot
Copy link

Docker image for this PR was built and is available on Docker Hub.

You can pull it locally via the CLI:

docker pull tomkerkhove/promitor-agent-scraper-ci:pr844

Want to verify the new version? Run it locally:

docker run -d -p 8999:80 --name promitor-agent-scraper-pr844 \
                         --env PROMITOR_AUTH_APPID='<azure-ad-app-id>' \
                         --env-file C:/Promitor/az-mon-auth.creds \
                         --volume C:/Promitor/metrics-declaration.yaml:/config/metrics-declaration.yaml  \
                         --volume C:/Promitor/runtime-config.yaml:/config/runtime.yaml \
                         tomkerkhove/promitor-agent-scraper-ci:pr844

You can find a CI version of our Helm chart on hub.helm.sh

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@promitor-bot
Copy link

Docker image for this PR was built and is available on Docker Hub.

You can pull it locally via the CLI:

docker pull tomkerkhove/promitor-agent-scraper-ci:pr844

Want to verify the new version? Run it locally:

docker run -d -p 8999:80 --name promitor-agent-scraper-pr844 \
                         --env PROMITOR_AUTH_APPID='<azure-ad-app-id>' \
                         --env-file C:/Promitor/az-mon-auth.creds \
                         --volume C:/Promitor/metrics-declaration.yaml:/config/metrics-declaration.yaml  \
                         --volume C:/Promitor/runtime-config.yaml:/config/runtime.yaml \
                         tomkerkhove/promitor-agent-scraper-ci:pr844

You can find a CI version of our Helm chart on hub.helm.sh

@tomkerkhove
Copy link
Owner Author

@maartenba Did a bit of refactoring but didn't seem to really help.

However, it looks like there's a shitload of HttpClients being created, I presume dotMemory is showing unique instance rather than (re)used ones or not?

@maartenba
Copy link

It shows unique ones, yes. Can you send me a longer run snapshot? Will have a look at it.

@tomkerkhove
Copy link
Owner Author

Performance analysis before & after can be downloaded from DropBox

@maartenba
Copy link

Checking "after". Looks like lots of leftover HttpClient instances are held in memory by AzureMonitorClient:

image

That in turn seems to not be disposed by ServiceProvider (check the right-hand side)

The AzMon libraries seem to hold a lot of these references as well, but can't really pinpoint where those come from.

Would you mind running performance profiling in Timeline mode as well? That should give some more info on # calls etc.

@tomkerkhove
Copy link
Owner Author

You can download it here @maartenba

@promitor-bot
Copy link

Docker image for this PR was built and is available on Docker Hub.

You can pull it locally via the CLI:

docker pull tomkerkhove/promitor-agent-scraper-ci:pr844

Want to verify the new version? Run it locally:

docker run -d -p 8999:80 --name promitor-agent-scraper-pr844 \
                         --env PROMITOR_AUTH_APPID='<azure-ad-app-id>' \
                         --env-file C:/Promitor/az-mon-auth.creds \
                         --volume C:/Promitor/metrics-declaration.yaml:/config/metrics-declaration.yaml  \
                         --volume C:/Promitor/runtime-config.yaml:/config/runtime.yaml \
                         tomkerkhove/promitor-agent-scraper-ci:pr844

You can find a CI version of our Helm chart on hub.helm.sh

@maartenba
Copy link

OK, ran through all traces, and found HttpClients are created here.

Example instance:

image

All instances:

image

Looks like there is a way to pass in an existing HttpClient, not sure whether that is exposed in the Azure Management API's? If yes, try passing a pre-created instance into the tree.

@tomkerkhove
Copy link
Owner Author

@maartenba Think it's safe to merge this or think it is not?

The issue lies in the SDK so can't do much about it, but this PR still improves it a bit.

Thougths?

@maartenba
Copy link

Think it's safe to do so, however if you figure out a way to pass in an existing HttpClient (which seems supported at the lower levels) you would be golden.

@tomkerkhove tomkerkhove marked this pull request as ready for review February 19, 2020 13:27
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.

3 participants