Skip to content

feat(MCP): Set up logging and OpenTelemetry export#7706

Merged
khvn26 merged 1 commit into
mainfrom
feat/mcp-structlog
Jun 4, 2026
Merged

feat(MCP): Set up logging and OpenTelemetry export#7706
khvn26 merged 1 commit into
mainfrom
feat/mcp-structlog

Conversation

@khvn26
Copy link
Copy Markdown
Member

@khvn26 khvn26 commented Jun 4, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Stacked on #7705.

Reuses flagsmith-common's structlog stack:

  • setup_logging for console/JSON rendering supporting LOG_LEVEL, LOG_FORMAT environment variables.
  • When OTEL_EXPORTER_OTLP_ENDPOINT is set: OTLP export of structlog events with trace correlation, and a global tracer provider — which also activates FastMCP's built-in per-request server spans. OTEL_SERVICE_NAME defaults to flagsmith-mcp.

No structured events are emitted yet — tool call events are a follow-up.

How did you test this code?

Unit and integration tests (100% coverage gate). Manually: ran the server in both log formats and verified every output line parses as JSON under LOG_FORMAT=json.

@khvn26 khvn26 requested a review from a team as a code owner June 4, 2026 10:19
@khvn26 khvn26 requested review from gagantrivedi and removed request for a team June 4, 2026 10:19
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jun 4, 2026 5:55pm
flagsmith-frontend-preview Ignored Ignored Preview Jun 4, 2026 5:55pm
flagsmith-frontend-staging Ignored Ignored Preview Jun 4, 2026 5:55pm

Request Review

@github-actions github-actions Bot added the feature New feature or request label Jun 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-7706 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-7706 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-7706 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-7706 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7706 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7706 Finished ✅ Results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34 seconds
commit  b43159c
info  🔄 Run: #17241 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.5 seconds
commit  b43159c
info  🔄 Run: #17241 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  33.2 seconds
commit  b43159c
info  🔄 Run: #17241 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  38.8 seconds
commit  b43159c
info  🔄 Run: #17241 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  39.6 seconds
commit  7298c54
info  🔄 Run: #17252 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  39.9 seconds
commit  7298c54
info  🔄 Run: #17252 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  19 passed

Details

stats  19 tests across 15 suites
duration  1 minute, 9 seconds
commit  7298c54
info  🔄 Run: #17252 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.4 seconds
commit  7298c54
info  🔄 Run: #17252 (attempt 1)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Visual Regression

19 screenshots compared. See report for details.
View full report

@khvn26 khvn26 requested review from emyller and removed request for gagantrivedi June 4, 2026 10:59
emyller
emyller previously approved these changes Jun 4, 2026
Copy link
Copy Markdown
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool.

Comment thread mcp/src/flagsmith_mcp/telemetry.py
@khvn26 khvn26 changed the base branch from feat/mcp-prometheus-metrics to main June 4, 2026 17:48
@khvn26 khvn26 dismissed emyller’s stale review June 4, 2026 17:48

The base branch was changed.

Reuse flagsmith-common's structlog stack: console/JSON log rendering
via setup_logging, and — when OTEL_EXPORTER_OTLP_ENDPOINT is set —
OTLP export of structlog events with trace correlation, plus a global
tracer provider, which also activates FastMCP's built-in per-request
spans. The FastMCP banner is disabled and uvicorn logs propagate to
the root logger, keeping output machine-readable under LOG_FORMAT=json.

beep boop
@khvn26 khvn26 force-pushed the feat/mcp-structlog branch from b43159c to 7298c54 Compare June 4, 2026 17:54
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 4, 2026
@khvn26 khvn26 merged commit f3c738b into main Jun 4, 2026
31 checks passed
@khvn26 khvn26 deleted the feat/mcp-structlog branch June 4, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants