Skip to content

Downgrade System.Diagnostics.DiagnosticSource to v6 and add a check if OpenTelemetry instrumentation can be used#4487

Merged
pmaytak merged 6 commits intomainfrom
pmaytak/azfunc-ds-6
Jan 10, 2024
Merged

Downgrade System.Diagnostics.DiagnosticSource to v6 and add a check if OpenTelemetry instrumentation can be used#4487
pmaytak merged 6 commits intomainfrom
pmaytak/azfunc-ds-6

Conversation

@pmaytak
Copy link
Copy Markdown
Contributor

@pmaytak pmaytak commented Jan 4, 2024

Fixes #4456. An alternative to #4486 solution.

Changes proposed in this request

  • Downgrade System.Diagnostics.DiagnosticSource to v6, which is the same version as what Azure Functions runtime uses.
  • Catching error when instantiating Open Telemetry fails (means it's not available in that environment) and using null telemetry implementation instead.
  • See issue for more details.

Testing

  • Unit tests pass.
  • Tested with a dev app.
  • Also tested that Activity code from 5dc10b2 works.

@gladjohn
Copy link
Copy Markdown
Contributor

gladjohn commented Jan 6, 2024

thanks for referencing this issue, so even downgrading still causes some issues?

@pmaytak
Copy link
Copy Markdown
Contributor Author

pmaytak commented Jan 6, 2024

thanks for referencing this issue, so even downgrading still causes some issues?

Currently downgrading doesn't cause issues. However, it's not future-proof if we ever need newer APIs. Additionally, if the client app enables exporters, OpenTelemetry libraries 1.4.0 and above depend on DiagnosticSource 7.0.0+, so they'll have to use one of the workarounds anyway.

@bgavrilMS
Copy link
Copy Markdown
Member

Have you thought about merging both PRs? So that it fixes the assembly load and fallbacks when Az Functions moves from 6 to 8 (?). Alternatively, this PR is enough and when Az Functions updates, the upgrade will break some folks. This should be a strong signal that they need to figure out a better solution. Thoughts?

@neha-bhargava
Copy link
Copy Markdown
Contributor

Were you able to test this with the exporter manually?

@pmaytak
Copy link
Copy Markdown
Contributor Author

pmaytak commented Jan 9, 2024

Have you thought about merging both PRs? So that it fixes the assembly load and fallbacks when Az Functions moves from 6 to 8 (?). Alternatively, this PR is enough and when Az Functions updates, the upgrade will break some folks. This should be a strong signal that they need to figure out a better solution. Thoughts?

Yea, I'll merge the PRs.

You mean when Azure Functions update their runtime to v8? I tested with a v5 library and everything works. So if they upgrade to v9 and we use v6/7, it's okay.

Were you able to test this with the exporter manually?

Yes, with the dev app. Workarounds still needed for in-process Function, but works otherwise.

* Adds a check if OTel can be used.

* Comments. More specific error type.
@pmaytak pmaytak changed the title Downgrade System.Diagnostics.DiagnosticSource to v6. Downgrade System.Diagnostics.DiagnosticSource to v6 and add a check if OpenTelemetry instrumentation can be used Jan 9, 2024
@pmaytak pmaytak enabled auto-merge (squash) January 9, 2024 03:01
@pmaytak pmaytak marked this pull request as draft January 9, 2024 03:01
auto-merge was automatically disabled January 9, 2024 03:01

Pull request was converted to draft

@pmaytak pmaytak marked this pull request as ready for review January 9, 2024 03:01
Copy link
Copy Markdown
Contributor

@neha-bhargava neha-bhargava left a comment

Choose a reason for hiding this comment

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

I did a quick test with MISE exporter too and logs look fine. Thanks!

@pmaytak pmaytak enabled auto-merge (squash) January 10, 2024 19:06
@pmaytak pmaytak merged commit ea376b4 into main Jan 10, 2024
@pmaytak pmaytak deleted the pmaytak/azfunc-ds-6 branch January 10, 2024 19:36
fowl2 added a commit to fowl2/microsoft-authentication-library-for-dotnet that referenced this pull request Feb 4, 2026
Copilot AI pushed a commit that referenced this pull request Feb 5, 2026
Copilot AI pushed a commit that referenced this pull request Feb 5, 2026
neha-bhargava added a commit that referenced this pull request Feb 6, 2026
…mpatibility (#5720)

* Initial plan

* Fix fallback where OpenTelemetry instrumentation is not available

Follow up to #4487

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: James May <fowl2@users.noreply.github.com>
Co-authored-by: Neha Bhargava <61847233+neha-bhargava@users.noreply.github.com>
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.

[Bug] Dependency on System.Diagnostics.DiagnosticSource (>= 7.0.2) in version 4.58.0 missing in .NET 6 Azure Functions

4 participants