Skip to content

fix: agentcore dev overwrites otel exporter env var#1742

Merged
tejaskash merged 2 commits into
aws:mainfrom
avi-alpert:aalpert/otel-env-fix
Jul 10, 2026
Merged

fix: agentcore dev overwrites otel exporter env var#1742
tejaskash merged 2 commits into
aws:mainfrom
avi-alpert:aalpert/otel-env-fix

Conversation

@avi-alpert

@avi-alpert avi-alpert commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

agentcore dev unconditionally overwrites OTel env vars (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, etc.) with its own values, ignoring any the user has already configured. This breaks workflows where users have their own collector or instrumentation setup.

Previously the only workaround was --no-traces, which is confusing since the user does want tracing — just not our defaults.

Fix: In startOtelCollector, respect any OTel env vars the user has already set in process.env. We provide sensible defaults only for vars that aren't already configured. User's env always wins.

Related Issue

Closes #1009

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Manual test:

# Start a dummy OTLP receiver:
python3 ~/Desktop/dummy-otel-collector.py  # listens on :9999

# Run agent with external endpoint:
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:9999 \
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
AGENT_OBSERVABILITY_ENABLED=true \
agentcore dev -l --skip-deploy

# Invoke agent → dummy server receives traces

Unit test: Added otel-collector.test.ts — verifies endpoint passthrough vs default behavior. Test fails without the fix, passes with it.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

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

@github-actions github-actions Bot added the size/s PR size: S label Jul 10, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jul 10, 2026
@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Jul 10, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.24.0.tgz

How to install

gh release download pr-1742-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.24.0.tgz

@github-actions github-actions Bot added size/s PR size: S and removed size/s PR size: S labels Jul 10, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Jul 10, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Jul 10, 2026
@avi-alpert avi-alpert marked this pull request as ready for review July 10, 2026 22:06
@avi-alpert avi-alpert requested a review from a team July 10, 2026 22:06
@tejaskash tejaskash merged commit 077bc92 into aws:main Jul 10, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a flag to allow pushing traces to custom OTEL endpoint

2 participants