Skip to content

Feat/phase4 fe consumer - #17

Merged
ravin00 merged 16 commits into
mainfrom
feat/phase4-fe-consumer
Aug 4, 2026
Merged

Feat/phase4 fe consumer#17
ravin00 merged 16 commits into
mainfrom
feat/phase4-fe-consumer

Conversation

@ravin00

@ravin00 ravin00 commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduce IMetricEventConsumer strategy with two implementations:
    LocalJsonlTailConsumer (active in dev) and EventHubConsumer
    (Phase-8 stub, disabled by default).
  • Tail consumer polls every 500ms, tracks byte offset in
    experiments/state/fe_consumer_offset.json, handles daily UTC
    rollover, and skips malformed lines instead of crashing.
  • /health now reports real staleness: Degraded if no events yet or
    last event older than 45s.
  • Adds Azure Event Hubs NuGets so the stub compiles.

Test plan

  • dotnet build AFIE.slnx clean
  • dotnet test tests/AFIE.FeatureEngineering.Tests/ — 11 passing
  • dotnet test tests/AFIE.Telemetry.Tests/ — 20 still passing
  • Smoke: append a MetricEvent to today's JSONL file, /health
    shows eventsConsumedTotal=1, workloadsTracked=1,
    sourceFileReachable=true
  • Restart the service and confirm the offset file resumes cleanly
  • Set ConsumerMode=eventhub and confirm the stub warning logs

Summary by CodeRabbit

  • New Features
    • Added telemetry ingestion from local JSONL files with offset-based resumption and daily rollover.
    • Added configurable consumer modes, input paths, polling intervals, and Event Hub settings.
    • Added graceful handling for malformed telemetry records.
  • Bug Fixes
    • Improved health reporting for stale telemetry and unavailable data sources.
    • Added runtime directories and initial offset state for reliable startup.
  • Tests
    • Added coverage for ingestion, offset resumption, malformed records, and missing-file scenarios.

@ravin00
ravin00 requested a lite review from Copilot and removed request for Copilot August 4, 2026 15:12
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c5b76ba-33ee-4313-bc96-4a646c615f5c

📥 Commits

Reviewing files that changed from the base of the PR and between 78934f8 and 20c8be7.

📒 Files selected for processing (3)
  • src/api/feature-engineering/Consumers/LocalJsonlTailConsumer.cs
  • src/api/feature-engineering/Dockerfile
  • src/api/feature-engineering/appsettings.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/api/feature-engineering/appsettings.json
  • src/api/feature-engineering/Consumers/LocalJsonlTailConsumer.cs

📝 Walkthrough

Walkthrough

The feature-engineering service now supports local JSONL telemetry ingestion and an Event Hub consumer stub. It adds configuration, persisted offsets, health updates, container directories, Azure dependencies, and integration tests.

Changes

Telemetry consumer integration

Layer / File(s) Summary
Consumer contracts and selection
src/api/feature-engineering/Models/*, src/api/feature-engineering/Program.cs, src/api/feature-engineering/appsettings.json, src/api/feature-engineering/AFIE.FeatureEngineering.csproj
Adds consumer options, Event Hub options, configuration values, Azure package references, and conditional hosted-service registration.
Local JSONL ingestion and checkpointing
src/api/feature-engineering/Consumers/LocalJsonlTailConsumer.cs, src/api/feature-engineering/experiments/state/fe_consumer_offset.json, experiments/results/telemetry_2026-08-04.jsonl, tests/AFIE.FeatureEngineering.Tests/Consumers/LocalJsonlTailConsumerTests.cs
Tails telemetry files, resumes persisted offsets, processes valid events, skips malformed lines, updates health and storage state, and validates these flows with tests.
Event Hub consumer stub
src/api/feature-engineering/Consumers/EventHubConsumer.cs
Adds a hosted Event Hub consumer that logs configured identifiers and exits without consuming events.
Health and container runtime support
src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs, src/api/feature-engineering/Dockerfile
Adds consumer mode to health data, applies fixed telemetry staleness values, changes degraded conditions, and creates experiment directories in the image.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Program
  participant LocalJsonlTailConsumer
  participant TelemetryFile
  participant WindowStore
  participant HealthState
  Program->>LocalJsonlTailConsumer: Start selected hosted consumer
  LocalJsonlTailConsumer->>TelemetryFile: Poll and read appended JSONL
  TelemetryFile-->>LocalJsonlTailConsumer: Return telemetry records
  LocalJsonlTailConsumer->>WindowStore: Add valid events
  LocalJsonlTailConsumer->>HealthState: Update reachability and metrics
  LocalJsonlTailConsumer->>TelemetryFile: Persist offset
Loading

Possibly related PRs

  • ravin00/AFIE#14: Both changes modify the metric-event contract flow used by LocalJsonlTailConsumer.
  • ravin00/AFIE#16: This change extends the feature-engineering options, startup wiring, health check, container, and consumer architecture.

Suggested reviewers: dinuda, copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the feature engineering consumer work, which is the main change in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/phase4-fe-consumer

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/api/feature-engineering/appsettings.json`:
- Line 19: Align the Blob Storage configuration names so options binding
populates the value: update src/api/feature-engineering/appsettings.json:19-19
and Models/EventHubOptions.cs:10-10 to use the same case-insensitive
key/property name, preserving the existing BlobStorageUrl usage.

In `@src/api/feature-engineering/Consumers/LocalJsonlTailConsumer.cs`:
- Around line 90-121: Replace the StreamReader-based processing in the consumer
method with a byte-tracking reader that records each fully consumed line’s byte
offset, and use that tracked offset when updating _offset instead of
fs.Position. Preserve the existing event processing and periodic checkpoint
behavior, and move the final offset update and FlushOffset into a finally block
so the latest confirmed offset is persisted even when ReadLineAsync is
cancelled.

In `@src/api/feature-engineering/Dockerfile`:
- Around line 13-16: Update the runtime stage after the directory-creation RUN
instruction to set USER app before ENV ASPNETCORE_URLS and the ENTRYPOINT,
ensuring the application runs as the image’s non-root app user. Preserve the
existing runtime configuration and verify deployment security settings do not
override this user with a privileged identity.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 48c36a0a-2b04-4995-9cdf-4d5a92b2cb6d

📥 Commits

Reviewing files that changed from the base of the PR and between e51996f and 78934f8.

📒 Files selected for processing (13)
  • experiments/results/telemetry_2026-08-04.jsonl
  • src/api/feature-engineering/AFIE.FeatureEngineering.csproj
  • src/api/feature-engineering/Consumers/EventHubConsumer.cs
  • src/api/feature-engineering/Consumers/IMetricEventConsumer.cs
  • src/api/feature-engineering/Consumers/LocalJsonlTailConsumer.cs
  • src/api/feature-engineering/Dockerfile
  • src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
  • src/api/feature-engineering/Models/EventHubOptions.cs
  • src/api/feature-engineering/Models/FeatureEngineeringOptions.cs
  • src/api/feature-engineering/Program.cs
  • src/api/feature-engineering/appsettings.json
  • src/api/feature-engineering/experiments/state/fe_consumer_offset.json
  • tests/AFIE.FeatureEngineering.Tests/Consumers/LocalJsonlTailConsumerTests.cs

Comment thread src/api/feature-engineering/appsettings.json Outdated
Comment thread src/api/feature-engineering/Consumers/LocalJsonlTailConsumer.cs Outdated
Comment thread src/api/feature-engineering/Dockerfile Outdated
Copilot AI lite review requested due to automatic review settings August 4, 2026 15:31
@ravin00
ravin00 removed the request for review from Copilot August 4, 2026 15:32
@ravin00
ravin00 merged commit c292717 into main Aug 4, 2026
2 checks passed
@ravin00
ravin00 deleted the feat/phase4-fe-consumer branch August 4, 2026 15:33
This was referenced Aug 5, 2026
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.

1 participant