### Start Example App with Custom Agent Port Source: https://github.com/instana/nodejs/blob/main/example-apps/collector/README.md Start the example Node.js application, connecting to an agent stub on a specific port. Ensure you are in the correct directory. ```bash cd nodejs/example-apps/collector INSTANA_AGENT_PORT=3210 npm start ``` -------------------------------- ### Start Async Recursive Example Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/misc/sdk/examples/README.md This command starts an example application that uses the async API with a recursive call pattern. Ensure you have an Instana agent running or use the agent stub. ```bash node packages/collector/test/integration/misc/sdk/examples/async_recursive.js ``` -------------------------------- ### Install and Run Next.js App Source: https://github.com/instana/nodejs/blob/main/example-apps/nextjs-app/README.md Standard commands to install dependencies, build the Next.js application, and start the server. ```bash npm i npm run build npm run start ``` -------------------------------- ### Install Dependencies and Run App Source: https://github.com/instana/nodejs/blob/main/example-apps/eum-serverless-collector/README.md Installs project dependencies, creates a website configuration file, generates necessary files, and starts the application server. Navigate to http://localhost:4200/ after running. ```sh npm i touch website.txt # Copy the script snippet form the website creation into website.txt node ./generate.js npm run start ``` -------------------------------- ### Install and Run Serverless Collector Source: https://github.com/instana/nodejs/blob/main/example-apps/serverless-collector/README.md Installs dependencies and starts the application. Environment variables INSTANA_ENDPOINT_URL and INSTANA_AGENT_KEY are required. ```sh npm i INSTANA_ENDPOINT_URL=... INSTANA_AGENT_KEY=... npm start ``` ```sh MODE=local INSTANA_ENDPOINT_URL=... INSTANA_AGENT_KEY=... npm start ``` ```sh APP_PORT=9192 INSTANA_ENDPOINT_URL=... INSTANA_AGENT_KEY=... npm start ``` -------------------------------- ### Install Dependencies Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/serverless-framework/README.md Run this command in the service directory to install Node.js dependencies. ```bash npm i ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md After cloning the repository, run this command in the root to install all project dependencies. ```bash npm install ``` -------------------------------- ### Start Application and Send Requests Source: https://github.com/instana/nodejs/blob/main/example-apps/otel/agent-based-http/README.md Start the Node.js application with specified environment variables and send HTTP requests to test its functionality. This includes sending a GET request to '/http' and a POST request to '/kafka-msg'. ```sh OTEL_LOG_LEVEL=debug OTEL_SERVICE_NAME=node-agent-based-otel-sdk npm start node kafka-consumer.js curl http://localhost:6215/http curl -X POST http://localhost:6215/kafka-msg ``` -------------------------------- ### Install Nest.js CLI and Project Dependencies Source: https://github.com/instana/nodejs/blob/main/example-apps/nestjs-app/README.md Install the Nest.js CLI globally and then install project dependencies using npm. This is a standard setup step for Nest.js projects. ```bash $ npm i -g @nestjs/cli $ npm install ``` -------------------------------- ### Start Instana Agent Stub Source: https://github.com/instana/nodejs/blob/main/example-apps/collector/README.md Use this command to start the agent stub for testing. Ensure you are in the correct directory. ```bash cd nodejs/packages/collector DROP_DATA=true npm run agent-stub ``` -------------------------------- ### Install Node.js Prerelease Version (Nightly) Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Set the NVM_NODEJS_ORG_MIRROR environment variable to the nightly mirror to install a specific nightly version of Node.js. ```bash NVM_NODEJS_ORG_MIRROR="https://nodejs.org/download/nightly" nvm install 23.0.0 ``` -------------------------------- ### Install node-fetch Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Install the current stable release (2.x) of node-fetch using npm. ```sh npm install node-fetch --save ``` -------------------------------- ### Start Serverless Application Source: https://github.com/instana/nodejs/blob/main/example-apps/otel/serverless-instana-format-grpc/README.md Starts the Node.js application with Instana tracing enabled. Requires setting environment variables for the Instana agent key, endpoint URL, and service name. Also sets the OpenTelemetry log level. ```sh INSTANA_AGENT_KEY="xx" INSTANA_ENDPOINT_URL="https://serverless-x-saas.instana.io" OTEL_LOG_LEVEL=debug OTEL_SERVICE_NAME=node-otel-instana-1 npm start ``` -------------------------------- ### Install npm Dependencies Source: https://github.com/instana/nodejs/blob/main/example-apps/otel/serverless-otlp-format-grpc/README.md Installs the necessary Node.js dependencies for the project. ```sh npm i ``` -------------------------------- ### Run the Nest.js Project Source: https://github.com/instana/nodejs/blob/main/example-apps/nestjs-app/README.md Run the Nest.js project using the npm start script. This command will start the application with the configured Instana integration. ```bash $ npm run start ``` -------------------------------- ### Install Instana Node.js Collector Source: https://github.com/instana/nodejs/blob/main/native-dep-packs/README.md Use this command to install the Instana Node.js collector. Ensure you are using a compatible Node.js version. ```bash npm install @instana/collector ``` -------------------------------- ### Install Node.js Prerelease Version (RC) Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Set the NVM_NODEJS_ORG_MIRROR environment variable to the RC mirror to install a specific prerelease version of Node.js. ```bash NVM_NODEJS_ORG_MIRROR="https://nodejs.org/download/rc" nvm install 23.0.0 ``` -------------------------------- ### Start Test Containers Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Use Docker and Docker Compose to run required infrastructure components for tests, such as MongoDB and Redis. ```bash node bin/start-test-containers.js --mongo --redis ``` -------------------------------- ### Build and Package Instana Node.js Project Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/misc/esbuild-external/README.md Standard commands to install dependencies, set up environment variables, build the project, and package it for distribution. Ensure all production dependencies are correctly managed, especially when using esbuild. ```sh npm i cp .env.template .env npm run build npm run package ``` -------------------------------- ### Start Serverless OTLP Service Source: https://github.com/instana/nodejs/blob/main/example-apps/otel/serverless-otlp-format-grpc/README.md Starts the Node.js application with Instana and OpenTelemetry configurations for OTLP gRPC. Ensure to replace 'xxx' and 'yyy' with your actual Instana agent key and endpoint URL. ```sh INSTANA_AGENT_KEY=xxx INSTANA_ENDPOINT_URL=yyy OTEL_LOG_LEVEL=debug OTEL_SERVICE_NAME=node-otlp-grpc npm start ``` -------------------------------- ### Install AWS Lambda Runtime Interface Emulator Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/runtime_emulator/README.md Download and make the RIE executable locally. This is required for running Lambda functions in a containerized environment. ```sh mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie \ https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie \ && chmod +x ~/.aws-lambda-rie/aws-lambda-rie ``` -------------------------------- ### Control Example Delay Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/misc/sdk/examples/README.md Set a custom delay in milliseconds between individual calls for the async recursive example. The default delay is 10 milliseconds. ```bash DELAY=1000 node packages/collector/test/integration/misc/sdk/examples/async_recursive.js ``` -------------------------------- ### Build and Run Test Application Image Locally Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md Builds the test application image and runs it locally. Useful for quick local testing and debugging of the monitoring setup. ```bash ./test-images/build-and-run.sh ``` -------------------------------- ### GET Request - JSON Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Shows how to make a GET request and parse the response body as JSON. ```APIDOC ## GET /users/:username ### Description Fetches user information from the GitHub API and returns it as a JSON object. ### Method GET ### Endpoint /users/:username ### Parameters #### Path Parameters - **username** (string) - Required - The username of the GitHub user. ### Request Example ```js fetch('https://api.github.com/users/github') .then(res => res.json()) .then(json => console.log(json)); ``` ### Response #### Success Response (200) - **json** (object) - The user information as a JSON object. #### Response Example ```json { "example": { "login": "github", "id": 9919, "name": "GitHub" } } ``` ``` -------------------------------- ### Configure Instana ESM Loader in package.json Source: https://github.com/instana/nodejs/blob/main/example-apps/nextjs-app/README.md Configure the start script in package.json to use the Instana ESM loader and enable debug logging. ```json { "start": "NODE_OPTIONS='--import ./node_modules/@instana/collector/esm-register.mjs' INSTANA_DEBUG=true next start" } ``` -------------------------------- ### Start Development Server Source: https://github.com/instana/nodejs/blob/main/example-apps/eum-lambda/README.md Runs the Angular development server. Access the application at http://localhost:4200/. The server reloads automatically on file changes. ```bash ng serve ``` -------------------------------- ### Trigger Requests with Siege Source: https://github.com/instana/nodejs/blob/main/example-apps/serverless-collector/README.md Instructions for installing and using the 'siege' tool to trigger requests to the application for testing purposes. ```sh ./trigger-requests.sh ``` -------------------------------- ### GET Request - Plain Text or HTML Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Demonstrates how to perform a GET request and retrieve the response body as plain text or HTML. ```APIDOC ## GET / ### Description Fetches the content of a given URL and returns it as plain text or HTML. ### Method GET ### Endpoint / ### Parameters #### Query Parameters - **url** (string) - Required - The URL to fetch. ### Request Example ```js fetch('https://github.com/') .then(res => res.text()) .then(body => console.log(body)); ``` ### Response #### Success Response (200) - **body** (string) - The content of the response as text. #### Response Example ```json { "example": "..." } ``` ``` -------------------------------- ### Install Angular CLI Source: https://github.com/instana/nodejs/blob/main/example-apps/eum-lambda/README.md Installs the Angular CLI globally. Requires Node.js version 18.19 or higher. ```bash npm install -g @angular/cli ``` -------------------------------- ### Build and Push Test Application Image Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md Builds the test application image and pushes it to a container registry. Used for testing the Instana monitoring setup in a Fargate task. ```bash ./test-images/build-and-push.sh ``` -------------------------------- ### Install jq for Auditing Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md jq is required on OSX (and other systems) to run `npm run audit` or `lerna audit run`. ```bash brew install jq ``` -------------------------------- ### Install Lerna Globally Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Lerna needs to be installed globally to run certain package.json scripts, such as `npm run reinstall-deps`. ```bash npm i lerna@8.1.8 -g ``` -------------------------------- ### Run Lambda Function with RIE Emulator Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/runtime_emulator/README.md Start your Lambda function in a Docker container, mounting the RIE and setting necessary environment variables. Port 9000 is exposed for invocation. ```sh docker run -d -v ~/.aws-lambda-rie:/aws-lambda -e INSTANA_ENDPOINT_URL='AGENT_URL' -e INSTANA_AGENT_KEY='AGENT_KEY' -e INSTANA_DEBUG='true' -e AWS_LAMBDA_FUNCTION_TIMEOUT='900000' -p 9000:8080 myfunction:latest ``` -------------------------------- ### Install npm Package from Tarball Source: https://github.com/instana/nodejs/blob/main/packages/shared-metrics/test/dependencies/npm-installed-app/README.md Installs a Node.js application packaged as a .tgz file into the current directory's node_modules. This is useful for testing scenarios where an entire application is treated as a single npm dependency. ```bash npm install npm-installed-test-app-1.0.0.tgz ``` -------------------------------- ### Conventional Commits Example Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md An example commit message adhering to the Conventional Commits standard, including a ticket link. ```git fix: Add missing error handling for API calls This commit addresses an issue where API calls could fail without proper error logging. Refs: #1234 ``` -------------------------------- ### Run Unit Tests Source: https://github.com/instana/nodejs/blob/main/example-apps/eum-lambda/README.md Executes unit tests using Karma. Ensure Node.js version 18.19 or higher is installed. ```bash ng test ``` -------------------------------- ### Fetch Plain Text or HTML Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Make a GET request to a URL and retrieve the response body as plain text. ```javascript fetch('https://github.com/') .then(res => res.text()) .then(body => console.log(body)); ``` -------------------------------- ### Revert to Stable Node.js Versions Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Unset the NVM_NODEJS_ORG_MIRROR environment variable to return to installing stable versions of Node.js. ```bash unset NVM_NODEJS_ORG_MIRROR ``` -------------------------------- ### Add Production Dependency to Specific Package Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Installs a production dependency for the specified package, equivalent to running the command within the package directory. ```bash npm install ${dependency-name} -w packages/collector ``` -------------------------------- ### Add Dev Dependency to Specific Package Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Installs a development dependency for the specified package, equivalent to running the command within the package directory. ```bash npm install -D ${dependency-name} -w packages/collector ``` -------------------------------- ### Build Test Application Image for Google Cloud Run Source: https://github.com/instana/nodejs/blob/main/packages/google-cloud-run/images/README.md Scripts to build various versions of a test application image that uses the base image from `instana-google-cloud-run`. These images represent a customer's application using the Instana Node.js Google Cloud Run monitoring setup. ```bash test-images/build.sh ``` ```bash test-images/build-and-push.sh ``` ```bash test-images/build-and-run.sh ``` ```bash test-images/build-and-push.sh local ``` -------------------------------- ### Build and Run Test Application Image Locally Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Builds the test application image and runs it locally. ```bash test-images/build-and-run.sh ``` -------------------------------- ### Build and Deploy Serverless Application Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/serverless-framework/README.md Build and deploy the serverless application with Instana monitoring. Requires INSTANA_ENDPOINT_URL and INSTANA_AGENT_KEY. ```bash INSTANA_ENDPOINT_URL=url INSTANA_AGENT_KEY=key npm run deploy ``` -------------------------------- ### Build and Push Test Application Image Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Builds the test application image and pushes it to a container registry. ```bash test-images/build-and-push.sh ``` -------------------------------- ### Create and Manage a Table with Integer Data Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/currencies/databases/ibm_db/resources/sample1.txt Shows how to create a table for integer data, insert values, select all records, and then drop the table. Remember to substitute {TABLE_NAME} with your actual table name. ```sql create table {TABLE_NAME}(no integer); ``` ```sql insert into {TABLE_NAME} values(1); ``` ```sql insert into {TABLE_NAME} values(2); ``` ```sql select * from {TABLE_NAME}; ``` ```sql drop table {TABLE_NAME} ``` -------------------------------- ### Build Project Source: https://github.com/instana/nodejs/blob/main/example-apps/eum-lambda/README.md Builds the project for production. Artifacts are stored in the dist/ directory. ```bash ng build ``` -------------------------------- ### Create and Manage a Table with String Data Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/currencies/databases/ibm_db/resources/sample1.txt Demonstrates creating a table, inserting string data, selecting all records, and then dropping the table. Replace {TABLE_NAME} with your desired table name. ```sql create table {TABLE_NAME}(no integer,name varchar(10)); ``` ```sql insert into {TABLE_NAME} values(1,'pri'); ``` ```sql insert into {TABLE_NAME} values(2,'anbu'); ``` ```sql select * from {TABLE_NAME}; ``` ```sql drop table {TABLE_NAME}; ``` -------------------------------- ### Build Serverless Application Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/serverless-framework/README.md Build the serverless application with Instana monitoring enabled. Ensure INSTANA_ENDPOINT_URL and INSTANA_AGENT_KEY are set. ```bash INSTANA_ENDPOINT_URL=url INSTANA_AGENT_KEY=key npm run build ``` -------------------------------- ### Deploy Serverless Application (No Build) Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/serverless-framework/README.md Deploy the serverless application without rebuilding, assuming Instana monitoring is already configured. Requires environment variables. ```bash INSTANA_ENDPOINT_URL=url INSTANA_AGENT_KEY=key npm run deploy:nobuild ``` -------------------------------- ### Build Test Application Image with Azure Base Image Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md This command builds a test application image using a pre-built Instana Node.js Azure base image. Specify the source of the base image (e.g., 'azure'), Node.js version, Linux distribution, and the Docker tag of the base image. ```bash test-images/build-and-push.sh azure 18 standard next ``` -------------------------------- ### Test HTTP Endpoint Source: https://github.com/instana/nodejs/blob/main/example-apps/otel/serverless-otlp-format-grpc/README.md Sends a GET request to the local HTTP endpoint to test its availability. ```sh curl http://localhost:6215/http ``` -------------------------------- ### Fetch JSON Data Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Make a GET request to an API endpoint and parse the JSON response. ```javascript fetch('https://api.github.com/users/github') .then(res => res.json()) .then(json => console.log(json)); ``` -------------------------------- ### Build Instana Node.js Fargate Test Application Image Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md After building the base image, use this script to create a test application image. Specify the image source (e.g., 'aws' for ECR), Node.js version, Linux distribution ('standard' for Debian), and the Docker tag corresponding to the npm dist-tag used for the base image. ```bash test-images/build-and-push.sh aws 18 standard next ``` -------------------------------- ### Build Test Application Image Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Builds a test application image using the base image from instana-azure-container-services. ```bash test-images/build.sh ``` -------------------------------- ### Create and Manage Table with String Data Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/currencies/databases/ibm_db/resources/sample2.txt This snippet shows how to create a table with integer and varchar columns, insert string data, select all records, and then drop the table. ```sql create table {TABLE_NAME}(no integer,name varchar(10))%insert into {TABLE_NAME} values(1,'pri')%insert into {TABLE_NAME} values(2,'anbu')%select * from {TABLE_NAME}%drop table {TABLE_NAME} ``` -------------------------------- ### Invoke Lambda Function Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/runtime_emulator/README.md Send a POST request to the RIE endpoint to trigger your Lambda function. The payload is an empty JSON object in this example. ```sh curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' ``` -------------------------------- ### Publish Stable Release After Pre-Release Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Use this command for a stable release when a pre-release already exists. The `--conventional-graduate` flag is essential for this scenario. ```bash NPM_CONFIG_OTP={TOKEN} lerna publish --force-publish --conventional-graduate ``` -------------------------------- ### Build Test Image with Local Modifications Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Builds an Instana Node.js Azure container image layer from local sources, uses it to build a test image container, and pushes it to the registry. ```bash test-images/build-and-push.sh local ``` -------------------------------- ### Force Legacy CLS Usage Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/misc/sdk/examples/README.md Force the @instana/collector to use the legacy cls-hooked library instead of AsyncLocalStorage for context propagation in the async recursive example. ```bash INSTANA_FORCE_LEGACY_CLS=true node packages/collector/test/integration/misc/sdk/examples/async_recursive.js ``` -------------------------------- ### Deploy Experimental Lambda Layer and Test Function Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/README.md Builds and deploys an experimental Lambda layer, then deploys the `simple-nodejs-lambda` function to use this layer. ```bash bin/redeploy-experimental-layer-and-test-lambda.sh ``` -------------------------------- ### Request cancellation with AbortSignal Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Cancel requests using AbortController and AbortSignal. This example shows how to time out a request after 150ms. Note that streamed requests can only be cancelled on Node >= v8.0.0. ```javascript import AbortController from 'abort-controller'; const controller = new AbortController(); const timeout = setTimeout( () => { controller.abort(); }, 150, ); fetch(url, { signal: controller.signal }) .then(res => res.json()) .then( data => { useData(data) }, err => { if (err.name === 'AbortError') { // request was aborted } }, ) .finally(() => { clearTimeout(timeout); }); ``` -------------------------------- ### Custom HTTP/HTTPS Agent Configuration Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Demonstrates how to configure custom http.Agent and https.Agent instances for the fetch 'agent' option. This allows for advanced networking configurations like keep-alive connections. ```javascript const httpAgent = new http.Agent({ keepAlive: true }); const httpsAgent = new https.Agent({ keepAlive: true }); const options = { agent: function (_parsedURL) { if (_parsedURL.protocol == 'http:') { return httpAgent; } else { return httpsAgent; } } } ``` -------------------------------- ### Build Lambda Zip Files with Local Package Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/README.md Use this command to build Lambda zip files including a local tar.gz of the current `packages/aws-lambda` content. Useful for testing local modifications. ```bash BUILD_LAMBDAS_WITH=local bin/create-zip.sh ``` -------------------------------- ### Create and Manage Table with Integer Data Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/currencies/databases/ibm_db/resources/sample2.txt This snippet demonstrates creating a table with an integer column, inserting integer data, selecting all records, and then dropping the table. ```sql create table {TABLE_NAME}(no integer)%insert into {TABLE_NAME} values(1)%insert into {TABLE_NAME} values(2)%select * from {TABLE_NAME}%drop table {TABLE_NAME} ``` -------------------------------- ### Publish Pre-Release with Lerna Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Use this command to publish a pre-release for the next major version. Ensure package versions are bumped to x.0.0 beforehand. ```bash NPM_CONFIG_OTP={your token} lerna publish --dist-tag next --preid rc ``` -------------------------------- ### Build and Push Instana Node.js Google Cloud Run Base Image Source: https://github.com/instana/nodejs/blob/main/packages/google-cloud-run/images/README.md Builds the Instana Node.js Google Cloud Run base image from local sources or a published npm package and pushes it to a container image registry. Use 'npm ' to specify an npm dist-tag, like 'next' for release candidates. ```bash instana-google-cloud-run/build.sh ``` ```bash instana-google-cloud-run/build-and-push.sh ``` ```bash instana-google-cloud-run/build-and-push.sh npm next ``` -------------------------------- ### Build Base Image from npm Registry Package Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Builds the base container image using a specified package from the npm registry. The 'next' argument indicates a release candidate or non-latest tag. ```bash instana-azure-container-services/build-and-push.sh npm next ``` -------------------------------- ### POST Request - Simple Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Illustrates how to send a POST request with simple data and expect a JSON response. ```APIDOC ## POST /post ### Description Sends a POST request with simple form-encoded data and returns the server's response, typically in JSON format. ### Method POST ### Endpoint /post ### Parameters #### Request Body - **body** (string) - Required - The data to send in the request body (e.g., 'a=1'). ### Request Example ```js fetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' }) .then(res => res.json()) // expecting a json response .then(json => console.log(json)); ``` ### Response #### Success Response (200) - **json** (object) - The server's response, usually containing details about the request. #### Response Example ```json { "example": { "args": {}, "data": "a=1", "files": {}, "form": { "a": "1" }, "headers": { "Content-Length": "3", "Content-Type": "application/x-www-form-urlencoded", "Host": "httpbin.org" }, "json": null, "origin": "...", "url": "https://httpbin.org/post" } } ``` ``` -------------------------------- ### Build Lambda Zip Files with npm Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/README.md Use this command to build Lambda zip files including the latest npm package `@instana/aws-lambda`. This is the default behavior. ```bash BUILD_LAMBDAS_WITH=npm bin/create-zip.sh ``` -------------------------------- ### Build Custom Docker Image for s390x Source: https://github.com/instana/nodejs/blob/main/packages/autoprofile/CONTRIBUTING.md Builds a custom Docker image locally for the s390x architecture using a provided Dockerfile. This is a workaround for the lack of official Docker images. ```sh scripts/custom-dockerfiles/Dockerfile.s390x ``` -------------------------------- ### Build Instana Node.js Azure Base Image Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Builds the Instana Node.js Azure base image. Can use local sources or a published npm package. ```bash instana-azure-container-services/build.sh ``` -------------------------------- ### Configure Instana EUM Settings Source: https://github.com/instana/nodejs/blob/main/example-apps/eum-lambda/src/index.html Configure Instana EUM by setting the reporting URL, website key, and enabling session tracking. These calls should follow the initialization. ```javascript ineum('reportingUrl', 'https://example.com'); ``` ```javascript ineum('key', 'website-key'); ``` ```javascript ineum('trackSessions'); ``` -------------------------------- ### Build and Push Test Image with Local Modifications Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md Builds an Instana Node.js Fargate container image layer from local sources, uses it to build a test image, and pushes it to the registry. Enables testing of uncommitted changes. ```bash ./test-images/build-and-push.sh local ``` -------------------------------- ### Rebuild and Redeploy Lambda Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/README.md Combines the build and deploy steps into a single command. Accepts the same environment variables as `create-zip.sh` and `deploy-zip.sh` for customization. ```bash bin/rebuild-redeploy.sh ``` -------------------------------- ### Build and Push Instana Node.js Test Application Image Source: https://github.com/instana/nodejs/blob/main/packages/google-cloud-run/images/README.md Builds and pushes a test application image using a pre-built Instana Node.js Google Cloud Run base image. Specify the registry, Node.js version, Linux distribution, and the base image's Docker tag. ```shell # Remember to provide an .env file in test-images, too. test-images/build-and-push.sh internal-icr 18 standard next ``` -------------------------------- ### Set Environment Variables for RIE Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/runtime_emulator/README.md Configure essential environment variables by copying the template file. Ensure INSTANA_ENDPOINT_URL and INSTANA_AGENT_KEY are set. ```sh image_tag_prefix= container_name_prefix= instana_endpoint_url= instana_agent_key= ``` -------------------------------- ### Build Test Application Image Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md Builds a test application image that uses the Instana Node.js Fargate base image. This represents a customer's application running with Instana monitoring. ```bash ./test-images/build.sh ``` -------------------------------- ### Execute Code Coverage Tool Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Run this command to generate a code coverage report for actively developed features. The report will open in the browser upon completion. ```bash npm run coverage --npm_command="test:ci:opentelemetry-exporter" ``` -------------------------------- ### Build and Push Instana Node.js Azure Base Image Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Builds the Instana Node.js Azure base image and pushes it to a specified container image registry. ```bash instana-azure-container-services/build-and-push.sh ``` -------------------------------- ### Rebuild Precompiled Native Dependencies Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Run these commands in the 'native-dep-packs' directory to generate prebuilds for event-loop-stats and gcstats. The second command specifically builds for macOS. ```bash cd native-dep-packs ./rebuild-precompiled-addons.sh ``` ```bash BUILD_FOR_MACOS=true ./rebuild-precompiled-addons.sh ``` -------------------------------- ### Build Instana Node.js Fargate Base Image with Specific npm Package Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md Use this script to build the base container image for Instana Node.js Fargate, specifying an npm package and its dist-tag (e.g., 'next' for release candidates). The 'npm' mode indicates using a package from the npm registry. ```bash instana-aws-fargate/build-and-push.sh npm next ``` -------------------------------- ### Bump Versions and Create Git Tag with Lerna Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md This command bumps all package versions and creates a git tag. It's a prerequisite for the 'lerna publish from-package' step if the initial release action only partially succeeded. ```bash lerna version ``` -------------------------------- ### Publish Local AWS Lambda Layer Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Navigate to the layer's bin directory and execute this script to publish a local layer to AWS. Specify the desired regions and layer name. ```bash cd packages/aws-lambda/layer/bin/ REGIONS= SKIP_DOCKER_IMAGE=true BUILD_LAYER_WITH=local LAYER_NAME=experimental-instana-nodejs-with-extension ./publish-layer.sh ``` -------------------------------- ### Build and Push Instana Node.js Fargate Base Image Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md Builds the Instana Node.js Fargate base image and pushes it to a specified container image registry. Useful for local testing and deployment. ```bash ./instana-aws-fargate/build-and-push.sh ``` -------------------------------- ### Build Instana Node.js Fargate Base Image Source: https://github.com/instana/nodejs/blob/main/packages/aws-fargate/images/README.md Builds the Instana Node.js Fargate base image from local sources or a published npm package. Used for creating production-ready monitoring images. ```bash ./instana-aws-fargate/build.sh ``` -------------------------------- ### Initialize Instana EUM Object Source: https://github.com/instana/nodejs/blob/main/example-apps/eum-lambda/src/index.html This snippet initializes the InstanaEumObject in the browser. Ensure this code runs before any other Instana EUM calls. ```javascript (function (s, t, a, n) { s[t] || ((s[t] = a), (n = s[a] = function () { n.q.push(arguments); }), (n.v = 2), (n.l = 1 * new Date())); })(window, 'InstanaEumObject', 'ineum'); ``` -------------------------------- ### Build and Package Node.js Application Source: https://github.com/instana/nodejs/blob/main/packages/shared-metrics/test/dependencies/npm-installed-app/README.md Rebuilds a Node.js application's tar.gz package. This involves removing the old archive, packing the application using npm pack, and moving the newly created .tgz file to the parent directory. ```bash rm -f npm-installed-test-app-1.0.0.tgz && pushd package && npm pack && mv npm-installed-test-app-1.0.0.tgz .. && popd ``` -------------------------------- ### Deploy Lambda Zip File with Specific Layer Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/README.md Deploys a Lambda zip file and explicitly specifies the Lambda layer version and ARN to be added. This is useful when `BUILD_LAMBDAS_WITH=layer` was used. ```bash LAYER_VERSION=167 LAYER_ARN=arn:aws:lambda:ap-southeast-1:767398002385:layer:instana-nodejs:167 bin/deploy-zip.sh ``` -------------------------------- ### Troubleshooting node-abi Error Source: https://github.com/instana/nodejs/blob/main/packages/autoprofile/CONTRIBUTING.md Resolves 'Could not detect abi' errors by updating the 'node-abi' sub-dependency to its latest version. ```sh npm update node-abi ``` -------------------------------- ### Manually Run Tests Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Execute tests manually using the provided script. Use the --watch flag to enable watch mode. ```bash bin/run-tests.sh --scope=@instana/collector bin/run-tests.sh --scope=@instana/collector --watch ``` -------------------------------- ### Publish Major Release with Lerna Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Execute this command to publish the next major version without pre-releases. The `--no-verify-access` flag bypasses access verification. ```bash NPM_CONFIG_OTP={TOKEN} lerna publish --no-verify-access --force-publish ``` -------------------------------- ### Lerna Publish Command with 'from-package' Option Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md This command is used when the GitHub release action needs to publish packages separately from versioning and tagging. It's useful for retrying failed npm publishes. ```bash lerna publish from-package ``` -------------------------------- ### Add Support for New Node.js Version Source: https://github.com/instana/nodejs/blob/main/packages/autoprofile/CONTRIBUTING.md Adds support for a new Node.js version by rebuilding prebuilds. This command is used for adding new versions. ```sh node scripts/prebuilds.js --node=22.0.0 [build specific node version] ``` -------------------------------- ### Build Lambda Zip Files with Layer Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/README.md Use this command to build Lambda zip files without including the `@instana/aws-lambda` package. Assumes the Lambda function is configured with the Instana Node.js layer. ```bash BUILD_LAMBDAS_WITH=layer bin/create-zip.sh ``` -------------------------------- ### Test Application Tracing Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md After deploying your Instana-instrumented Node.js application to Azure App Service, use this command to send requests and verify that tracing data is being reported to Instana. Inspect the results in the Instana UI. ```bash watch curl https://$PUBLIC_SERVICE_URL ``` -------------------------------- ### Build Instana Node.js Google Cloud Run Base Image Source: https://github.com/instana/nodejs/blob/main/packages/google-cloud-run/images/README.md Use this script to build the Instana Node.js base image for Google Cloud Run. It requires specifying the package mode ('npm' or 'next') and the desired package version tag. ```shell # "npm" is the build mode, that is, use a package from the npm registry # "next" is the dist tag of the package you want to use. Any existing npm dist-tag can be used instead of "next". # Example of building the image: # instana-google-cloud-run/build.sh npm next ``` -------------------------------- ### Login to Azure Container Registry Source: https://github.com/instana/nodejs/blob/main/packages/azure-container-services/images/README.md Authenticates with the Azure container registry. This is necessary for pushing images to Instana's internal Azure container registry. ```bash packages/azure-container-services/images/azure-registry-login.sh ``` -------------------------------- ### Deploy Local Layer & Test Lambda Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/test/load-test/README.md This script publishes a local experimental Instana Lambda layer, deploys the function, and runs load tests. Useful for testing local changes. ```sh cd packages/aws-lambda awstoken {verifyToken} INSTANA_ENDPOINT_URL=... INSTANA_AGENT_KEY=... REGION=us-east-1 ./load-test/deploy.sh REGION=ap-east-1 node ./load-test/run.js ./load-test/cleanup.sh ``` -------------------------------- ### Run Kafka Consumer Source: https://github.com/instana/nodejs/blob/main/example-apps/otel/serverless-otlp-format-grpc/README.md Executes the Kafka consumer script for processing messages. ```sh node kafka-consumer.js ``` -------------------------------- ### Rebuild Existing Node.js Versions Source: https://github.com/instana/nodejs/blob/main/packages/autoprofile/CONTRIBUTING.md Rebuilds prebuilds for existing Node.js versions, specifying the operating system, architecture, and Node.js version. ```sh node scripts/prebuilds.js --os=darwin --node=20.0.0 [build v20 only for darwin] ``` ```sh node scripts/prebuilds.js --os=linux --node=18.0.0 [build v18 only for linux] ``` ```sh node scripts/prebuilds.js --os=linux --arch=linux-arm64 --node=18.0.0 [build v18 only for linux arm64] ``` ```sh node scripts/prebuilds.js --node=22.0.0 [build specific node version] ``` ```sh node scripts/prebuilds.js --node=22.0.0,21.0.0 [build specific node versions] ``` -------------------------------- ### Trigger GitHub Release Action Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md This describes the manual process of triggering the release GitHub action. No specific code is executed here, but it outlines the UI steps on GitHub. ```text Run workflow Run workflow ``` -------------------------------- ### Switch Node.js Version Source: https://github.com/instana/nodejs/blob/main/packages/autoprofile/CONTRIBUTING.md Switches the active Node.js version using nvm. Ensure the target version matches the project's requirements. ```sh nvm use v22.0.0 [target prebuild Node.js version] ``` -------------------------------- ### Configure AWS Credentials Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Add your AWS access key and secret key to the `~/.aws/credentials` file to allow the AWS CLI access to IAM credentials. ```ini [default] aws_access_key_id = aws_secret_access_key = ``` -------------------------------- ### Fetch Options Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Configuration options for customizing fetch requests, including method, headers, body, and more. ```APIDOC ## Fetch Options ### Description Options for the HTTP(S) request. ### Properties - **method** (string) - Default: `'GET'` - The HTTP method. - **headers** (object) - Default: `{}` - Request headers. - **body** (string | Buffer | Blob | ReadableStream | null) - Default: `null` - Request body. - **redirect** (string) - Default: `'follow'` - Set to `'manual'` to extract redirect headers, `'error'` to reject redirect. - **signal** (AbortSignal | null) - Default: `null` - An instance of AbortSignal to optionally abort requests. - **follow** (number) - Default: `20` - Maximum redirect count. `0` to not follow redirects. - **timeout** (number) - Default: `0` - Request/response timeout in ms. `0` to disable. - **compress** (boolean) - Default: `true` - Support gzip/deflate content encoding. `false` to disable. - **size** (number) - Default: `0` - Maximum response body size in bytes. `0` to disable. - **agent** (http.Agent | https.Agent | function | null) - Default: `null` - An http(s).Agent instance or a function that returns an instance. ``` -------------------------------- ### Load node-fetch Module Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Load the node-fetch module using require. If using a Promise library other than native, set it through fetch.Promise. ```javascript const fetch = require('node-fetch'); ``` ```javascript const Bluebird = require('bluebird'); fetch.Promise = Bluebird; ``` -------------------------------- ### Build Lambda Function Docker Image Source: https://github.com/instana/nodejs/blob/main/packages/aws-lambda/lambdas/runtime_emulator/README.md Build a Docker image for your container-based Lambda function. Ensure you are in the correct directory before running the build command. ```sh cd packages/aws-lambda/lambdas/container-based docker build -t myfunction:latest . ``` -------------------------------- ### Locally Preview Release Changes with Lerna Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Execute this command locally to preview changes before a release. Inspect the diff and discard changes afterward. This command is useful for reviewing CHANGELOG updates and version bumps. ```bash lerna version --no-git-tag-version --no-push --conventional-commits ``` -------------------------------- ### Fetch Options Configuration Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/metrics/npm_installed_app/node_modules/node-fetch/README.md Defines the available options for the fetch function, including standard Fetch API properties and node-fetch extensions. Default values are shown for each option. ```javascript { // These properties are part of the Fetch Standard method: 'GET', headers: {}, body: null, redirect: 'follow', signal: null, // The following properties are node-fetch extensions follow: 20, timeout: 0, compress: true, size: 0, agent: null } ``` -------------------------------- ### Recreate Package Lock File Source: https://github.com/instana/nodejs/blob/main/CONTRIBUTING.md Use this command to recreate the package lock file if it becomes corrupted or needs to be reset to a specific version. ```bash npm i --lockfile-version 2 ``` -------------------------------- ### Run Instana Agent Stub Source: https://github.com/instana/nodejs/blob/main/packages/collector/test/integration/misc/sdk/examples/README.md Use this command to run a stub for the Instana agent if you are not interested in inspecting reported data. This prevents the SDK from attempting to connect to a real agent. ```bash DROP_DATA=true node packages/collector/test/apps/agentStub ```