Skip to content

feat: Add diagnostics parameter #4929

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SanderNugteren
Copy link

Description

I added the diagnostics parameter for Log Analytics. However, I was unable to fully test the changes due to issues with the local setup. I would appreciate it if someone with a working environment could verify and complete the testing.

Fixes #3519
-->

Pipeline Reference

Pipeline

Type of Change

  • Update to CI Environment or utilities (Non-module affecting changes)
  • Azure Verified Module updates:
    • Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in version.json:
      • Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description.
      • The bug was found by the module author, and no one has opened an issue to report it yet.
    • Feature update backwards compatible feature updates, and I have bumped the MINOR version in version.json.
    • Breaking changes and I have bumped the MAJOR version in version.json.
    • Update to documentation

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • I have run Set-AVMModule locally to generate the supporting module files.
  • My corresponding pipelines / checks run clean and green without any errors or warnings

@SanderNugteren SanderNugteren requested review from a team as code owners March 28, 2025 07:46
@avm-team-linter avm-team-linter bot added the Needs: Module Owner 📣 This module needs an owner to develop or maintain it label Mar 28, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Triage 🔍 Maintainers need to triage still Type: AVM 🅰️ ✌️ Ⓜ️ This is an AVM related issue labels Mar 28, 2025
@SanderNugteren SanderNugteren changed the title Add diagnostics parameter feat: Add diagnostics parameter Mar 28, 2025
@SanderNugteren
Copy link
Author

@SanderNugteren please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Waternet"

@AlexanderSehr
Copy link
Contributor

Hey @SanderNugteren,
happy to do so by rebasing your PR (which keeps you as the author) and testing it in my environment. However, before doing so, I'd need to ask you to merge the latest upstream AVM version into your fork and resolve the conflicts. It appears your version of the module is missing some updates that were already implemented in the upstream repository.
Just make sure your actions are disabled before pulling the changes into your fork as this may result in all of them being triggered (if not disabled).

@SanderNugteren
Copy link
Author

Hi @AlexanderSehr! I resolved the conflicts. Thanks for the help in getting this merged!

Comment on lines +155 to +159
diagnostics: !empty(diagnostics)
? {
logAnalytics: diagnostics.?logAnalytics
}
: null
Copy link
Contributor

@AlexanderSehr AlexanderSehr Apr 10, 2025

Choose a reason for hiding this comment

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

Does it make sense that logAnalytics is optional?
E.g., because just setting an empty diagnostics object already configures something.

If not, it may make sense to either make it mandatory, or even remove one level of nesting by changin it to

diagnostics: !empty(diagnostics) ? {
  logAnalytics: {
    logType: diagnostics!.logType
    workspaceId: diagnostics!.workspaceId
    workspaceKey: diagnostics!.workspaceKey
    workspaceResourceId: diagnostics!.?workspaceResourceId
    metadata: diagnostics!.?metadata
  }
} : null

Copy link
Author

Choose a reason for hiding this comment

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

I was also thinking that, but I thought that in the future the diagnostics might contain more fields than just the logAnalytics field (e.g. having different diagnostics implementations). In that case it might change which diagnostics field you choose to use and they should allbe optional.

But perhaps this is over-engineering for a possible future situation 😉. If you think it's not necessary to account for this, then I think implementing your suggestion of removing the nesting would be best. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Either is fine for me, and ultimately it might be best if the module owner @JPEasier makes this decision.

You input is much appreciated and I share your concern. 💪
That being said, there's also a best practice in engineering to not plan for possible future scenarios that may never happen 😄 I guess if it does happen it could still be changed alongside a major version change to tell users as much - and transitioning from one model to the other would be as easy as to adding this intermediate level. Either way - it's not outrageous.

One element would help the decision though - and that is to find out if even a deployment like diagnostics: {} (which you can currenlty do as logAnalytics is optional does any thing. A good example for this are networkAcls which usually, even if empty, enable a service's firewall.
If this is the case here to, I'd strongly recommend to keep your current implementation. If not - then it remains up for debate an personally I'd lean towards my suggestion. But I'm biased, so ... 😄

Copy link
Author

Choose a reason for hiding this comment

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

Hi @AlexanderSehr ! I don't see an answer from @JPEasier yet. How should we proceed with this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @SanderNugteren, I just reached out to the owner internally. The notification via GitHub may have gotten lost.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @SanderNugteren,
I understand it like this, diagnostics: {} has only one parameter: logAnalytic . in this case i would suggest to set logAnalytic as mendetory, then the conversion is quite simple if more parameters are added.

So exactly what @AlexanderSehr wrote in his code suggestion :)

SanderNugteren and others added 2 commits April 10, 2025 11:57
Co-authored-by: Alexander Sehr <ASehr@hotmail.de>
Co-authored-by: Alexander Sehr <ASehr@hotmail.de>
Copy link
Contributor

@JPEasier JPEasier left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution!
I see some conflicts, please review and update your branch.


@description('Optional. Metadata for log analytics.')
metadata: object?
}?
Copy link
Contributor

@JPEasier JPEasier May 12, 2025

Choose a reason for hiding this comment

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

as disscussed, lets make the logAnalytics mandatory. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Module Owner 📣 This module needs an owner to develop or maintain it Needs: Triage 🔍 Maintainers need to triage still Type: AVM 🅰️ ✌️ Ⓜ️ This is an AVM related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AVM Module Issue]: Missing Diagnostic Settings for Container-Instance
3 participants