cloudfoundry / java-buildpack

Cloud Foundry buildpack for running Java applications
Apache License 2.0
437 stars 2.58k forks source link

Add connection string for Azure Application Insights Agent 3.x #981

Closed mayrstefan closed 1 year ago

mayrstefan commented 1 year ago

Improvements to Azure Application Insights Agent to make version 3.x usable using a connection string (see also #980). Also added some initial documentation

pivotal-david-osullivan commented 1 year ago

Hi @mayrstefan, thanks for this PR, I did some testing of the changes and I cannot get the framework to detect when I create a service with only instrumentation_key in the credentials. It only works if I also have connection_string as a credentials key.

I think this is because when you are adding multiple credential keys as 'optional' and not 'required', they need to be in a 'group', i.e. [x,y], so

@application.services.find_service(FILTER, CONNECTION_STRING, INSTRUMENTATION_KEY)['credentials']

should become

@application.services.find_service?(FILTER, [CONNECTION_STRING, INSTRUMENTATION_KEY])

to make this an either/or detection. The same for the supports method call to @application.services.one_service.

Could you test this and let me know if I'm correct here?

mayrstefan commented 1 year ago

Hi,

you are absolutely right. I found the space where I tested my changes and it had a user provided service with both keys so that I could switch between versions 2.+ and 3.+.

Thanks for pointing this out