Skip to content

OpenTelemetry support in worker #1049

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

Merged
merged 8 commits into from
Apr 12, 2024
Merged

Conversation

andystaples
Copy link
Contributor

Initial commit of changes needed to support OpenTelemetry in the worker

  • Includes the ability to check for the presence of the AzureFunctions.PowerShell.OpenTelemetry.SDK module and run commands from that module
    • Initializes an internal activity before each function invocation to link worker traces to host
    • Takes a reference to a method from the module and forwards all logs back through this method to be passed on to the OTel endpoint
  • Report the relevant OTel worker capabilities at init based on the presence of a newly specified environment variable
  • Update protobuf spec to latest in order to
    • Support updating worker capabilities at EnvironmentReloadRequest
    • Provide this capability for apps which were started in placeholder mode

resolves #1048

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

@andystaples
Copy link
Contributor Author

This is a draft PR for a number of reasons. We need to discuss:

  • Any concerns with the additional checks for the presence of the OTel module
  • Cold start impact
  • Additional testing that may be required (?)

Also, there is a comment in there (RequestProcessor#400) that suggests some uncertainty about whether all worker capabilities need to be reported in EnvironmentReloadRequest. Reading through the protobuf spec, the host defaults to "merge" mode where new capabilities are added but old ones are retained, so that is no longer a concern. I'll pull that comment out with the next commit to this branch

- Outline of unit testing, more is needed
@andystaples andystaples marked this pull request as ready for review April 11, 2024 17:37

internal class PowerShellModuleDetector
{
public static bool IsPowerShellModuleLoaded(System.Management.Automation.PowerShell _pwsh, ILogger _logger, string moduleName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming convention: we use names starting with underscore for class fields only. Parameter names should be in camelCase without underscore characters

Copy link
Contributor

Choose a reason for hiding this comment

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

I will not block the PR on this, but please clean it up, now or later

Copy link
Contributor

@AnatoliB AnatoliB left a comment

Choose a reason for hiding this comment

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

LGTM

@andystaples andystaples merged commit f0c7eec into dev Apr 12, 2024
andystaples added a commit that referenced this pull request Apr 12, 2024
* Detect if OpenTelemetry module is present and environment variable is set
* Pre-instrument invocations with a span using Invocation ID + parent span ID
* Forward all user logs to the module to be sent to OTel endpoint

(cherry picked from commit f0c7eec)
@andystaples andystaples deleted the andystaples/opentelemetry-changes branch April 12, 2024 19:03
andystaples added a commit that referenced this pull request Apr 12, 2024
* OpenTelemetry support in worker (#1049)

* Detect if OpenTelemetry module is present and environment variable is set
* Pre-instrument invocations with a span using Invocation ID + parent span ID
* Forward all user logs to the module to be sent to OTel endpoint

(cherry picked from commit f0c7eec)
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.

Support OpenTelemetry in the PowerShell worker
3 participants