Skip to content

feat: OpenTelemetry support #1469

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 14 commits into from
Apr 12, 2024
Merged

feat: OpenTelemetry support #1469

merged 14 commits into from
Apr 12, 2024

Conversation

gavin-aguiar
Copy link
Contributor

@gavin-aguiar gavin-aguiar commented Apr 8, 2024

Description

Added support for opentelemetry.

The worker does not take a dependency on opentelemetry but checks if the function app has opentelemetry. If it finds the libraries, it will setup the Otel configs needed.

Otel is configured separately for sync and async. For async functions, we can directly call configure_opentelemetry but for sync functions this method has to be called inside the ThreadPool executor which is used to run sync functions.
This is because OpenTelemetry is thread specific and will only update the Span on the thread it is configured

Sample function app.

import azure.functions as func 
import requests
import logging
from azure.monitor.opentelemetry import configure_azure_monitor

configure_azure_monitor()

app = func.FunctionApp()

@app.route('call_bing', auth_level=func.AuthLevel.ANONYMOUS)
def call_bing(req: func.HttpRequest) -> func.HttpResponse:
    logging.info(f'Logging to app insights...')
    res = requests.get('https://www.bing.com')
    return func.HttpResponse(f"Bing.com: status_code = {res.status_code}", status_code=res.status_code)

Fixes #


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and CI is passing.

Quality of Code and Contribution Guidelines

@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 45.16129% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 46.16%. Comparing base (330783f) to head (ba14b63).
Report is 4 commits behind head on dev.

❗ Current head ba14b63 differs from pull request most recent head c170240. Consider uploading reports for the commit c170240 to get more accurate results

Files Patch % Lines
azure_functions_worker/dispatcher.py 43.33% 16 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              dev    #1469       +/-   ##
===========================================
- Coverage   84.64%   46.16%   -38.49%     
===========================================
  Files          35       36        +1     
  Lines        2052     2307      +255     
  Branches      387      433       +46     
===========================================
- Hits         1737     1065      -672     
- Misses        232     1157      +925     
- Partials       83       85        +2     
Flag Coverage Δ
unittests 46.16% <45.16%> (-38.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gavin-aguiar gavin-aguiar marked this pull request as ready for review April 12, 2024 19:03
@gavin-aguiar gavin-aguiar merged commit 51758a2 into dev Apr 12, 2024
50 of 51 checks passed
@gavin-aguiar gavin-aguiar deleted the gaaguiar/otel branch April 12, 2024 22:26
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.

4 participants