Conversation
Refactored BracketCompletionService, BracketService, MatchCascadePositionCalculator, and MatchCorrectionService from static to instance classes to support dependency injection.
Introduced TournamentActivitySource-based tracing spans to key operations (bracket creation, match correction, round updates, auto-closing) in core services and mutation handlers. Enriched spans with tags like tournament ID, bracket ID, match ID, round number, participant count, correlation ID, and auto-close count for improved observability and diagnostics.
Introduced UserMetrics class to monitor login attempts, registrations, and refresh token failures using .NET metrics APIs. Registered UserMetrics as a singleton in DI. Updated UserMutations to record metrics and added logging for failed login and refresh token events. Injected ILoggerFactory to support enhanced observability.
BracketMutations now records success and failure via BracketMetrics when generating brackets, tracking unique constraint violations and successful creations. BracketMetrics is registered as a singleton in the DI container for application-wide access.
Added MatchMetrics class with counters for matches played, replays, and result corrections. Registered as a singleton service and injected into MatchMutations. Updated PlayMatch and CorrectMatchResult to increment metrics accordingly.
Introduce ParticipantMetrics as a singleton service and inject it into ParticipantMutations and TournamentMutations. Mutation methods now record metrics for slot contention, join attempts, and various participant-related events by calling ParticipantMetrics methods in relevant validation and exception handling branches.
Added tournaments_closed_total (by reason) and tournaments_deleted_total metrics. Updated auto-close and manual close logic to increment tournaments_closed_total with appropriate reason. Increment tournaments_deleted_total on tournament deletion.
…ic classes Refactored BracketMutations.cs and MatchMutations.cs to inject BracketService, BracketMetrics, MatchCorrectionService, BracketCompletionService, and ILoggerFactory as parameters instead of using static service calls. Updated logger usage to utilize the injected logger instance. This enhances testability and aligns with dependency injection best practices.
Introduced GraphQLMetrics class to encapsulate OpenTelemetry metrics for GraphQL requests, including request duration and error counting. Registered GraphQLMetrics as a singleton service. Updated ExecutionEventListener to use GraphQLMetrics for recording request durations and errors during execution. Modified error handling to record errors via GraphQLMetrics.
Introduced PushEntityContext extension for IResolverContext to inject entity type and ID into both Serilog LogContext and GraphQL context data. Applied this in mutation resolvers to ensure entity context is available for logging during and after resolver execution. Enables more informative and request-level logging tied to specific entities.
Replaced direct ApplicationDbContext injection with IDbContextFactory<ApplicationDbContext> in MatchService and UserTournamentsService. Each method now creates its own DbContext instance using CreateDbContextAsync, improving lifetime management in async and multi-threaded scenarios., following official HotChocolate docs
Expanded MetricConstants with new meter names for Brackets, Matches, Participants, Users, and GraphQL. Registered these meters in TelemetryExtensions to enable metric collection and export for these domains.
Logs a warning with the client's IP and request path when a request is rejected due to rate limiting, using the application's logger.
Improved observability by logging trace and span IDs from Activity, distinguishing between anonymous and named operations, and normalizing operation type handling. Added entity type and ID logging from context data. Replaced requestId with traceId and spanId in logs. Simplified error extraction and updated log messages to include new trace, span, entity, and error details for both successful and error-completed GraphQL requests.
Introduced TournamentActivitySource static class for consistent tracing with a defined source name. Updated TelemetryExtensions to register this source in the OpenTelemetry pipeline, enabling improved traceability within the TournamentAPI.
Integrated OpenTelemetry.Instrumentation.EntityFrameworkCore for EF Core tracing. Updated OpenTelemetry.Api and ProviderBuilderExtensions to 1.18.0. Modified TelemetryExtensions.cs to enable EF Core instrumentation. Updated project and lock files for dependency consistency.
Introduce UnhandledExceptionErrorFilter to log unhandled GraphQL exceptions and assign a custom error code. Register the filter, its logger, and additional services for metrics and event listeners in GraphQLExtensions.cs.
Introduced ParticipantMetrics in TournamentAPI.Metrics using System.Diagnostics.Metrics. Tracks tournament join attempts with a "result" tag and slot contention events via counters. Metrics are initialized with IMeterFactory and exposed through public increment methods.
Added ILogger injection and warning log for invalid API key with client IP. Removed requestId global state generation and addition.
Replaced existing logging setup in Program.cs with Serilog and OpenTelemetry integration. Updated appsettings.json to configure Serilog log levels and overrides. Removed obsolete "Logging" sections from appsettings.Development.json and appsettings.json.
Refactored BracketServiceTests and MatchCascadePositionCalculatorTests to use instance methods instead of static methods. Introduced private readonly _sut fields initialized with NullLogger for each service under test. Updated all static method calls to use the instance methods on _sut, improving testability and supporting dependency injection practices.
Closed
12 tasks
Dejmenek
deleted the
feat/159-expand-gathered-telemetry-golden-signals-traces-business-metrics-and-service-logging
branch
September 18, 2026 16:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This branch expands observability across the API: distributed tracing, business-level metrics, structured logging via Serilog, and GraphQL error handling improvements.
Changes
TournamentActivitySourceand wired distributed tracing into core services, with EF Core instrumentation added to the OpenTelemetry tracing pipeline.BracketMetrics,MatchMetrics,ParticipantMetrics,UserMetrics,GraphQLMetrics), registered as singletons and recorded from the relevant mutations/services.UnhandledExceptionErrorFilterto log unhandled GraphQL exceptions and set anUNHANDLED_EXCEPTIONerror code when one isn't already present.ExecutionEventListenerandHttpRequestInterceptorlogging and removed the unusedrequestIdfrom the interceptor.PushEntityContexttoResolverContextExtensionsfor entity-aware log enrichment.DbContexttoIDbContextFactory) so they can take metrics/tracing dependencies and be unit tested.OnRejectedhandler for the rate limiter that logs rejected requests.