Skip to content
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

[Resources.Azure] Add support for Container App Jobs #2064

Merged

Conversation

hansmbakker
Copy link
Contributor

@hansmbakker hansmbakker commented Sep 11, 2024

Fixes #2036
Design discussion issue #

Changes

This adds support for the detection of Container App Jobs and fixes the issue that normal Container App are recognized but that containers running as a ACA Job are shown as unknown_service:dotnet.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@hansmbakker hansmbakker requested a review from a team September 11, 2024 11:25
Copy link

linux-foundation-easycla bot commented Sep 11, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@Kielek
Copy link
Contributor

Kielek commented Sep 11, 2024

Please update CHANGELOG.md and README.md.

I will leave logic review for @rajkumar-rangaraj and @TimothyMothra.

@Kielek Kielek changed the title Add support for Container App Jobs [Resources.Azure] Add support for Container App Jobs Sep 11, 2024
@hansmbakker
Copy link
Contributor Author

hansmbakker commented Sep 11, 2024

Please update CHANGELOG.md and README.md.

@Kielek done

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

thanks.

@TimothyMothra
Copy link
Contributor

Hi @hansmbakker, thanks for the contribution. Were you able to test this in a sample app to confirm that this Environment Variable exists?

@rajkumar-rangaraj, do we need to get this reviewed from anyone on the service team to confirm we can take a dependency on this environment variable? Do we need to share this with the other languages to make the same change?

@hansmbakker
Copy link
Contributor Author

hansmbakker commented Sep 12, 2024

@TimothyMothra I created a sample app and added it in the last commit. I connected it to application insights.

⚠️ Note that in order to access the internal AzureContainerAppsResourceDetector class, I had to add [InternalsVisibleTo(...)] to its project when building that app. I did not commit that change but documented it in the sample apps README.md.

Application map (note that it now correctly shows the job name instead of unknown_service:dotnet):

image

Example activity making a call to microsoft.com and throwing an example exception:

image

Environment variables:

image

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Sep 12, 2024
@hansmbakker
Copy link
Contributor Author

do we need to get this reviewed from anyone on the service team to confirm we can take a dependency on this environment variable

@TimothyMothra if you're reaching out to the service team anyway, it would be good to request more useful environment variables - it would be nice to also log the image name and image tag for example.

@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Sep 13, 2024
Copy link
Contributor

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

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

I’ve engaged the Azure Container Apps team to confirm whether we can reliably use the environment variables CONTAINER_APP_JOB_NAME and CONTAINER_APP_JOB_EXECUTION_NAME. Until we receive confirmation, I recommend putting this PR on hold.

@cijothomas
Copy link
Member

I’ve engaged the Azure Container Apps team to confirm whether we can reliably use the environment variables CONTAINER_APP_JOB_NAME and CONTAINER_APP_JOB_EXECUTION_NAME. Until we receive confirmation, I recommend putting this PR on hold.

I am okay to merge the PR, given this package is experimental anyway. If we chose to merge now, lets add an explicit warning to the ACAJobs methods/doc that this is highly experimental and subject to even more change (or similar wording to indicate the unstability part).

@hansmbakker do you prefer to merge now (with a additional doc warning suggested above) OR wait for an official confirmation from ACA team on this?

@TimothyMothra
Copy link
Contributor

I am okay to merge the PR, given this package is experimental anyway.

I'm in favor of waiting before we merge. Users aren't blocked and can write their own resource detector for the short term.

@rajkumar-rangaraj do you have any estimate on how long till we get a response from the server team? As this week is Hackathon, I wouldn't expect a response this week.

@cijothomas would you be comfortable waiting 2-3 weeks for a response? I'd like to avoid extra churn if possible :)

@hansmbakker
Copy link
Contributor Author

hansmbakker commented Sep 17, 2024

@hansmbakker do you prefer to merge now (with a additional doc warning suggested above) OR wait for an official confirmation from ACA team on this?

@cijothomas I'm ok with waiting for a confirmation if it's a reasonable timeframe 👍🏼 I understand it's better to avoid unnecessary changes if we can prevent them.

Copy link
Contributor

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

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

LGTM

I received confirmation that we can rely on these environment variables for ACA jobs.

@Kielek Kielek requested a review from a team as a code owner September 20, 2024 16:45
@Kielek
Copy link
Contributor

Kielek commented Sep 20, 2024

@hansmbakker, tests are failing. Could you please fix it?

@hansmbakker
Copy link
Contributor Author

hansmbakker commented Sep 20, 2024

@Kielek the app name / job name env vars were not cleared in between tests which caused the test failure. This should be fixed now

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.89%. Comparing base (71655ce) to head (2897aa2).
Report is 446 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2064      +/-   ##
==========================================
+ Coverage   73.91%   83.89%   +9.97%     
==========================================
  Files         267        6     -261     
  Lines        9615      149    -9466     
==========================================
- Hits         7107      125    -6982     
+ Misses       2508       24    -2484     
Flag Coverage Δ
unittests-Resources.Azure 83.89% <100.00%> (?)

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

Files with missing lines Coverage Δ
...ources.Azure/AzureContainerAppsResourceDetector.cs 90.90% <100.00%> (ø)

... and 272 files with indirect coverage changes

@Kielek Kielek merged commit b05067f into open-telemetry:main Sep 24, 2024
59 checks passed
@hansmbakker hansmbakker deleted the feature/container_app_job-detector branch September 24, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:resources.azure Things related to OpenTelemetry.Resources.Azure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Azure Container Apps Jobs
5 participants