Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cc461c4
feat(PL-PL-4367): add feature upload source map to Instana - do not e…
vatima2016 Oct 24, 2025
a520031
feat(PL-PL-4367): add feature upload source map to Instana - check di…
vatima2016 Oct 24, 2025
cc36228
feat(PL-PL-4367): add feature upload source map to Instana - check di…
vatima2016 Oct 24, 2025
6687f0b
feat(PL-PL-4367): add feature upload source map to Instana - check di…
vatima2016 Oct 24, 2025
e4b449d
feat(PL-PL-4367): add feature upload source map to Instana - check di…
vatima2016 Oct 24, 2025
d28a4dc
feat(PL-PL-4367): add feature upload source map to Instana - check di…
vatima2016 Oct 24, 2025
870cdd5
feat(PL-PL-4367): add job with source map upload to Instana
vatima2016 Oct 24, 2025
12c3b92
feat(PL-PL-4367): add job with source map upload to Instana - fix yaml
vatima2016 Oct 24, 2025
70e484d
feat(PL-PL-4367): add job with source map upload to Instana - add mis…
vatima2016 Oct 24, 2025
713c7ac
feat(PL-PL-4367): add job with source map upload to Instana - fix par…
vatima2016 Oct 24, 2025
2bbd930
feat(PL-PL-4367): add job with source map upload to Instana - fix lin…
vatima2016 Oct 24, 2025
b469aa0
feat(PL-PL-4367): add job with source map upload to Instana - fix lin…
vatima2016 Oct 24, 2025
3716c63
feat(PL-PL-4367): add job with source map upload to Instana - fix cmd…
vatima2016 Oct 24, 2025
a1f1535
feat(PL-PL-4367): add job with source map upload to Instana - check w…
vatima2016 Oct 24, 2025
36d7ef4
feat(PL-PL-4367): create upload file config if does not exist yet
vatima2016 Oct 26, 2025
146d8af
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
cb32821
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
e65b094
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
ae702c4
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
821c5a2
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
d436f77
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
3fd44d0
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
ee359b8
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
0651906
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
dfff78e
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
d77675b
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
fe471b0
feat(PL-PL-4367): create upload file config if does not exist yet and…
vatima2016 Oct 26, 2025
d318311
feat(PL-PL-4367): fix clear command
vatima2016 Oct 26, 2025
6b48fb5
feat(PL-PL-4367): fix clear command - 2
vatima2016 Oct 26, 2025
64f954a
feat(PL-PL-4367): take over tested command
vatima2016 Oct 27, 2025
b3a3bd9
feat(PL-PL-4367): take over tested command - fix lintinng issue
vatima2016 Oct 27, 2025
4df957c
feat(PL-PL-4367): take over tested command - fix linting issue
vatima2016 Oct 27, 2025
8138004
feat(PL-PL-4367): take over tested command - fix linting issue
vatima2016 Oct 27, 2025
4f1ec47
feat(PL-PL-4367): take over tested command - fix linting issue
vatima2016 Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ extends: relaxed

rules:
line-length:
max: 200
max: 260
allow-non-breakable-inline-mappings: true
82 changes: 82 additions & 0 deletions src/commands/upload_source_maps_to_instana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
description: >
Upload JS source maps to Instana APM

parameters:
instana_endpoint:
default: "$INSTANA_ENDPOINT"
type: string
description: Instana API endpoint host
instana_api_token:
default: "$INSTANA_API_TOKEN"
type: string
description: Instana API token
website_id:
description: "Website ID in Instana"
type: string
upload_config_name:
description: "Upload configuration name to be created and cleaned up before every upload"
type: string
assets_path:
default: "dist/assets"
description: "Local path to the folder containing JS files"
type: string
maps_path:
default: "source-maps"
description: "Local path to the folder containing JS source maps"
type: string
js_url:
description: "Remote path to the folder containing JS files"
type: string
steps:
- run:
name: Upload JS source maps to Instana
command: |
# get all file upload configurations for the website
GET_RESPONSE=$(curl -s -X GET "https://<< parameters.instana_endpoint >>/api/website-monitoring/config/<< parameters.website_id >>/sourcemap-upload" -H "Accept: application/json" -H "Authorization: apiToken << parameters.instana_api_token >>")
echo "File Upload configurations for website ID << parameters.website_id >> : $GET_RESPONSE"
UPLOAD_CONFIG_ID=$(echo "$GET_RESPONSE" | jq -r '.configs[] | select(.description == "<< parameters.upload_config_name >>") | .id')
# create config if not found
if [ -z "$UPLOAD_CONFIG_ID" ]; then
echo "No file upload configuration << parameters.upload_config_name >> was found, so creating a new one..."
CREATION_ENDPOINT="https://<< parameters.instana_endpoint >>/api/website-monitoring/config/<< parameters.website_id >>/sourcemap-upload"
# echo "CREATION_ENDPOINT=$CREATION_ENDPOINT"
CREATION_RESPONSE=$(curl -s -X POST $CREATION_ENDPOINT -H "Content-Type: application/json" -H "Accept: application/json" -d '{"description": "<< parameters.upload_config_name >>"}' -H "authorization: apiToken << parameters.instana_api_token >>")
echo "CREATION_RESPONSE=$CREATION_RESPONSE"
UPLOAD_CONFIG_ID=$(echo "$CREATION_RESPONSE" | jq -r '.id')
fi
if [ -z "$UPLOAD_CONFIG_ID" ]; then
echo "Error: UPLOAD_CONFIG_ID is still empty!"
exit 1
else
echo "UPLOAD_CONFIG_ID=$UPLOAD_CONFIG_ID"
fi
# clear uploads
CLEAR_ENDPOINT="https://<< parameters.instana_endpoint >>/api/website-monitoring/config/<< parameters.website_id >>/sourcemap-upload/$UPLOAD_CONFIG_ID/clear"
# echo "CLEAR_ENDPOINT=$CLEAR_ENDPOINT"
CLEAR_RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}\n" -X PUT $CLEAR_ENDPOINT -H "authorization: apiToken << parameters.instana_api_token >>")
echo "CLEAR_RESPONSE_CODE=$CLEAR_RESPONSE_CODE"
if [ "$CLEAR_RESPONSE_CODE" -eq 204 ]; then
echo "Request to clear source map files for << parameters.upload_config_name >> was successful."
else
echo "Request to clear source map files for << parameters.upload_config_name >> failed with status code: $CLEAR_RESPONSE_CODE"
exit 1
fi
# upload files
echo "########### JS files ##########"
ls -al << parameters.assets_path >>/*.js
if ls << parameters.assets_path >>/*.js.map >/dev/null 2>&1; then
echo "Error: << parameters.assets_path >>/*.js.map files still exist! Move them to the << parameters.maps_path >>/ directory on the same level like your local path to sync."
exit 1
fi
echo "########### JS source map files ##########"
ls -al << parameters.maps_path >>/*.js.map
UPLOAD_ENDPOINT="https://<< parameters.instana_endpoint >>/api/website-monitoring/config/<< parameters.website_id >>/sourcemap-upload/$UPLOAD_CONFIG_ID/form"
# echo "UPLOAD_ENDPOINT=$UPLOAD_ENDPOINT"
for file in << parameters.assets_path >>/*.js; do
filename=$(basename "$file")
MAP_LOCATION="<< parameters.maps_path >>/${filename}.map"
JS_URL="<< parameters.js_url >>/$filename"
echo "JS_URL=$JS_URL \nMAP_LOCATION=$MAP_LOCATION"
UPLOAD_RESULT=$(curl -s -X PUT "$UPLOAD_ENDPOINT" -H "authorization: apiToken << parameters.instana_api_token >>" -F "url=$JS_URL" -F "sourceMap=@$MAP_LOCATION" -H "ContentType: multipart/form-data")
echo "UPLOAD_RESULT=$UPLOAD_RESULT"
done
129 changes: 129 additions & 0 deletions src/jobs/sync_and_invalidate_with_source_maps_upload_to_instana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
description: >
Upload JS source maps to Instana APM

executor: default

parameters:
distribution_id:
description: ID of cloudfront distribution
type: string
pattern:
description: Pattern to purge
type: string
default: "/*"
bucket_name:
description: Name of the bucket to sync files to
type: string
local:
description: Local path to sync
type: string
default: "dist/"
remote:
description: Remote path in s3 to sync
type: string
default: ""
additional_args:
default: ""
description: Additional arguments to pass to AWS cli
type: string
attach_workspace:
default: true
description: >
Boolean for whether or not to attach to an existing workspace.
type: boolean
checkout:
default: true
description: >
Boolean for whether or not to checkout sources
type: boolean
workspace_root:
default: .
description: >
Workspace root path that is either an absolute path or a path relative to the working directory.
type: string
aws_access_key_id:
type: env_var_name
description: aws access key id override
default: AWS_ACCESS_KEY_ID
aws_secret_access_key:
type: env_var_name
description: aws secret access key override
default: AWS_SECRET_ACCESS_KEY
aws_iam_web_identity_role_arn:
type: string
description: IAM role of web identity enabled role to access aws resources
default: "none"
aws_region:
type: env_var_name
description: aws region override
default: AWS_REGION
# Instana source maps upload
bucket_key:
description: Name of the bucket key to distinguish between assets to be uploaded to the same bucket
type: string
default: ""
instana_endpoint:
default: "$INSTANA_ENDPOINT"
type: string
description: Instana API endpoint host
instana_api_token:
default: "$INSTANA_API_TOKEN"
type: string
description: Instana API token
# tenant:
# default: "trustedshops"
# description: "Tenant part in the Instana host name"
# type: string
# unit:
# description: "Unit part in the Instana host name, must match stage (dev, test or prod)"
# type: string
website_id:
description: "Website ID in Instana"
type: string
assets_path:
default: "dist/assets"
description: "Local path to the older containing JS files and its source maps"
type: string
javascript_url:
description: "Remote path to the folder containing JS files and its source maps"
type: string
steps:
- when:
condition: <<parameters.checkout>>
steps:
- checkout
- unless:
condition:
and:
- equal: [ <<parameters.aws_iam_web_identity_role_arn>>, "none" ]
steps:
- aws-cli/install
- aws-cli/assume_role_with_web_identity:
role_arn: <<parameters.aws_iam_web_identity_role_arn>>
- when:
condition:
and:
- equal: [ <<parameters.aws_iam_web_identity_role_arn>>, "none" ]
steps:
- aws-cli/setup:
aws_access_key_id: <<parameters.aws_access_key_id>>
aws_secret_access_key: <<parameters.aws_secret_access_key>>
region: <<parameters.aws_region>>
- s3_sync:
bucket_name: <<parameters.bucket_name>>
local: <<parameters.local>>
remote: <<parameters.remote>>
attach_workspace: <<parameters.attach_workspace>>
workspace_root: <<parameters.workspace_root>>
additional_args: <<parameters.additional_args>>
- upload_source_maps_to_instana:
instana_endpoint: << parameters.instana_endpoint >>
instana_api_token: << parameters.instana_api_token >>
website_id: << parameters.website_id >>
# use bucket_name as upload_config_name
upload_config_name: "<< parameters.bucket_name >><< parameters.bucket_key>>"
assets_path: << parameters.assets_path >>
js_url: << parameters.javascript_url >>
- cloudfront_invalidate:
distribution_id: <<parameters.distribution_id>>
pattern: <<parameters.pattern>>