Skip to content

Conversation

@liustve
Copy link
Contributor

@liustve liustve commented May 28, 2025

Description of changes:
There are currently no OTel supported logs being emitted from the sample-app.

Replaces sample-app logging with bunyan in order for OpenTelemetry to auto-instrument the logging library from the app.

/aws-sdk-s3:

{"name":"express-app","hostname":"ip-172-31-7-29.us-west-2.compute.internal","pid":2522078,"level":30,"msg":"done aws sdk s3 request","time":"2025-05-28T17:52:53.115Z","v":0}
{"name":"express-app","hostname":"ip-172-31-7-29.us-west-2.compute.internal","pid":2522078,"level":50,"msg":"Exception thrown: Invalid value \"undefined\" for header \"X-Amzn-Trace-Id\"","time":"2025-05-28T17:52:54.132Z","v":0}

/http:

{"name":"express-app","hostname":"ip-172-31-7-29.us-west-2.compute.internal","pid":2522078,"level":30,"msg":"random value from http request: [94]\n","time":"2025-05-28T17:54:09.786Z","v":0}

/rolldice:

{"name":"express-app","hostname":"ip-172-31-7-29.us-west-2.compute.internal","pid":2522987,"level":30,"msg":"rolldice: 1","time":"2025-05-28T17:54:52.830Z","v":0}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@liustve liustve requested a review from a team as a code owner May 28, 2025 17:57
@liustve liustve changed the title Replace Console with bunyan logger Replace Console with bunyan logger in Sample App May 28, 2025
@liustve liustve merged commit 914fdd7 into aws-observability:main Jun 2, 2025
9 checks passed
Jeel-mehta added a commit to aws-observability/aws-application-signals-test-framework that referenced this pull request Jul 3, 2025
*Issue description:*
There are currently no OTel supported logs being emitted from the
sample-app.

*Description of changes:*
- Replaced console.log statements with Bunyan logging library throughout
the application
- Added Bunyan dependency (^1.8.15) to package.json
- Implemented structured logging with consistent format across all
endpoints
- Updated the following files:
  - frontend_service/index.js
  - remote-service/index.js
  - package.json for both frontend-service and remote-service
This is similar to [[PR
[#186]]](aws-observability/aws-otel-js-instrumentation#186)
from ADOT JS repository
  
  Testing:
  *Testing:*
Tested locally using docker-compose:
1. Built and ran both frontend and remote services successfully
2. Verified all endpoints working as expected:
   - /healthcheck - ✅ Success
   - /outgoing-http-call - ✅ Success
   - /aws-sdk-call - ✅ Success with testingId parameter
   - /remote-service - ✅ Success
   - /client-call - ✅ Success
   - /mysql - Attempted (Expected error due to no local DB setup)

3. Verified Bunyan structured logs appearing correctly for both
services:
   - Frontend service logs showing proper formatting and levels
   - Remote service logs showing proper formatting and levels

All endpoints tested using curl commands against localhost:8000 and
localhost:8001.
Services started and stopped successfully using docker-compose up/down.

I am attaching two screenshots for reference of my testing:
![Screenshot 2025-07-02 at 3 40
35 PM](https://github.com/user-attachments/assets/dbf89192-f330-406c-9668-d4fa1ad181e9)
![Screenshot 2025-07-02 at 3 40
14 PM](https://github.com/user-attachments/assets/c1a59195-9bdf-4597-83fc-17743119d21c)

Also I tested the updated sample app after adot js instrumentation to
see if I receive logs in my personal cloudwatch account. Here are the
screenshots for the logs received
![Screenshot 2025-07-02 at 5 58
38 PM](https://github.com/user-attachments/assets/4c8d978d-a86f-44f8-a173-5278be9ddb42)
![Screenshot 2025-07-02 at 5 59
00 PM](https://github.com/user-attachments/assets/20bcd0f6-6ddd-4ecd-955d-972efec7099d)


  
*Rollback procedure:*

<Can we safely revert this commit if needed? If not, detail what must be
done to safely revert and why it is needed.>

*Ensure you've run the following tests on your changes and include the
link below:*

To do so, create a `test.yml` file with `name: Test` and workflow
description to test your changes, then remove the file for your PR. Link
your test run in your PR description. This process is a short term
solution while we work on creating a staging environment for testing.

NOTE: TESTS RUNNING ON A SINGLE EKS CLUSTER CANNOT BE RUN IN PARALLEL.
See the
[needs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds)
keyword to run tests in succession.
- Run Java EKS on `e2e-playground` in us-east-1 and eu-central-2
- Run Python EKS on `e2e-playground` in us-east-1 and eu-central-2
- Run metric limiter on EKS cluster `e2e-playground` in us-east-1 and
eu-central-2
- Run EC2 tests in all regions
- Run K8s on a separate K8s cluster (check IAD test account for master
node endpoints; these will change as we create and destroy clusters for
OS patching)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Co-authored-by: Jeel Mehta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants