forked from open-telemetry/opentelemetry-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable configurable RUM destination in frontend
- Loading branch information
1 parent
40ea0cf
commit cccb670
Showing
3 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
chunksDir=/app/.next/static/chunks | ||
envFile=/app/splunk_rum_env | ||
|
||
noRumStart() { | ||
echo "Frontend starting with no RUM support." | ||
echo "You will probably see browser console errors." | ||
cd /app | ||
npm start | ||
exit | ||
} | ||
|
||
|
||
if ! [ -f $envFile ]; then | ||
echo "Config file \"$envFile\" for Splunk Rum not found." | ||
noRumStart | ||
fi | ||
|
||
# Splunk Rum config file found. Try to substitute SPLUNK_RUM_PLACEHOLDER values | ||
cd $chunksDir | ||
mainfile=$(ls main-*.js) | ||
|
||
if [ "$mainfile" == '' ] ; then | ||
# Next.js main chunk file not found | ||
echo "Did not find main file in $chunksDir" | ||
noRumStart | ||
fi | ||
|
||
if echo "$mainfile" | grep -q ' ' ; then | ||
# Uh-oh, got multiple mainfiles. | ||
echo "Found multiple main files in $chunksDir" | ||
noRumStart | ||
fi | ||
|
||
echo splunk_rum_env file contains the following values: | ||
cat $envFile | ||
. $envFile | ||
sed -e "s/SPLUNK_RUM_REALM_PLACEHOLDER/$SPLUNK_RUM_REALM/" \ | ||
-e "s/SPLUNK_RUM_TOKEN_PLACEHOLDER/$SPLUNK_RUM_TOKEN/" \ | ||
-e "s/SPLUNK_RUM_APP_PLACEHOLDER/$SPLUNK_RUM_APP_NAME/" \ | ||
-e "s/SPLUNK_RUM_ENV_PLACEHOLDER/$SPLUNK_RUM_ENV/" < $mainfile > /tmp/${mainfile}.new | ||
|
||
if [ "$?" -ne 0 ]; then | ||
# Some error while running the sed command. Do a fallback start | ||
echo "Encountered an error while trying to substitute RUM config placeholders" | ||
noRumStart | ||
fi | ||
|
||
# All looks good! We should be able to do a regular start | ||
cp ${mainfile} /tmp/$mainfile.orig | ||
cp /tmp/${mainfile}.new $mainfile | ||
cd /app | ||
npm start | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import SplunkRum from '@splunk/otel-web'; | ||
|
||
SplunkRum.init({ | ||
realm: "us1", | ||
rumAccessToken: "5UxP7X9NINTxugmccK8kaA", | ||
applicationName: "astroshop_lab", | ||
deploymentEnvironment: "astroshop_lab" | ||
realm: "SPLUNK_RUM_REALM_PLACEHOLDER", | ||
rumAccessToken: "SPLUNK_RUM_TOKEN_PLACEHOLDER", | ||
applicationName: "SPLUNK_RUM_APP_PLACEHOLDER", | ||
deploymentEnvironment: "SPLUNK_RUM_ENV_PLACEHOLDER" | ||
}); | ||
|
||
//SplunkRum.init({ | ||
// realm: "us1", | ||
// rumAccessToken: "Qad35m7E6ld6p_-O_RxwEg", | ||
// applicationName: "astroshop", | ||
// deploymentEnvironment: "astroshop" | ||
// applicationName: "astroshop_lab_2", | ||
// deploymentEnvironment: "astroshop_lab_2" | ||
//}); |