Skip to content

Commit

Permalink
chore: fix azp telemetry injection (#594)
Browse files Browse the repository at this point in the history
# Description

AZP didn't pass build pipeline vars to makefile recipes

## Related Issue

If this pull request is related to any issue, please mention it here.
Additionally, make sure that the issue is assigned to you before
submitting this pull request.

## Checklist

- [ ] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [ ] I signed and signed-off the commits (`git commit -S -s ...`). See
[this
documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
on signing commits.
- [ ] I have correctly attributed the author(s) of the code.
- [ ] I have tested the changes locally.
- [ ] I have followed the project's style guidelines.
- [ ] I have updated the documentation, if necessary.
- [ ] I have added tests, if applicable.

## Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes
made.

## Additional Notes

Add any additional notes or context about the pull request here.

---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.
  • Loading branch information
matmerr authored Aug 12, 2024
1 parent 7309cf6 commit 5425b41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
24 changes: 6 additions & 18 deletions .pipelines/cg-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ stages:
else
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(make version)"
fi
if [[ -z $(git status -s) ]]; then
if [[ -n $(git describe --exact-match --tags HEAD 2>/dev/null) ]]; then
echo "the current folder is clean and has a tag."
echo "##vso[task.setvariable variable=ApplicationInsightsID;isOutput=true]$(PROD_AI)"
else
echo "the current folder is clean but does not have a tag."
echo "##vso[task.setvariable variable=ApplicationInsightsID;isOutput=true]$(TEST_AI)"
fi
else
echo "the current folder is not clean."
echo "##vso[task.setvariable variable=ApplicationInsightsID;isOutput=true]$(TEST_AI)"
fi
name: "EnvironmentalVariables"
displayName: "Set environmental variables"
condition: always()
Expand Down Expand Up @@ -76,10 +63,12 @@ stages:
set -euo pipefail
echo "VERSION=$(make version)"
export VERSION=$(make version)
export APP_INSIGHTS_ID=$(APP_INSIGHTS_ID)
mkdir -p ./output/images/$(platform)/$(arch)/$(year)
make retina-image \
AGENT_TARGETS=$(target) \
TAG=$(make version) \
APP_INSIGHTS_ID=$(APP_INSIGHTS_ID) \
IMAGE_NAMESPACE=retina \
PLATFORM=$(platform)/$(arch) \
IMAGE_REGISTRY=ghcr.io/microsoft \
Expand Down Expand Up @@ -118,6 +107,7 @@ stages:
mkdir -p ./output/images/$(platform)/$(arch)/$(year)
make retina-operator-image \
TAG=$(make version) \
APP_INSIGHTS_ID=$(APP_INSIGHTS_ID) \
IMAGE_NAMESPACE=retina \
PLATFORM=$(platform)/$(arch) \
IMAGE_REGISTRY=ghcr.io/microsoft \
Expand All @@ -143,16 +133,14 @@ stages:
- checkout: self
fetchTags: true



- task: DownloadPipelineArtifact@2
inputs:
buildType: 'specific'
buildType: "specific"
project: $(BUILDER_ADO_PROECT)
definition: $(BUILDER_ADO_DEFINITION_ID) # Replace with your build definition ID
buildId: $(BUILDER_ADO_BUILD_ID)
artifactName: $(BUILDER_ADO_ARTIFACTE_NAME) # Replace with your artifact name
itemPattern: '**/*builder*.tar'
itemPattern: "**/*builder*.tar"
downloadPath: '$(Pipeline.Workspace)\artifacts'

- task: PowerShell@2
Expand All @@ -173,7 +161,7 @@ stages:
targetType: "inline"
script: |
Import-Module -Name "$(Build.SourcesDirectory)\windows\docker\DockerBuildModule.psm1" -Force
Build-RetinaAgentImage -fullBuilderImageName $(WINDOWS_BUILDER_IMAGE) -registry $(BUILD_REGISTRY) -appInsightsID $(PROD_AI)
Build-RetinaAgentImage -fullBuilderImageName $(WINDOWS_BUILDER_IMAGE) -registry $(BUILD_REGISTRY) -appInsightsID $(APP_INSIGHTS_ID)
Save-Image -imageName retina-agent -registry $(BUILD_REGISTRY)
- task: PublishBuildArtifacts@1
Expand Down
5 changes: 4 additions & 1 deletion cmd/legacy/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ func (d *Daemon) Start() error {
mainLogger.Info(zap.String("data aggregation level", daemonConfig.DataAggregationLevel.String()))

var tel telemetry.Telemetry
if daemonConfig.EnableTelemetry && buildinfo.ApplicationInsightsID != "" {
if daemonConfig.EnableTelemetry {
if buildinfo.ApplicationInsightsID == "" {
panic("telemetry enabled, but ApplicationInsightsID is empty")
}
mainLogger.Info("telemetry enabled", zap.String("applicationInsightsID", buildinfo.ApplicationInsightsID))
tel = telemetry.NewAppInsightsTelemetryClient("retina-agent", map[string]string{
"version": buildinfo.Version,
Expand Down

0 comments on commit 5425b41

Please sign in to comment.