Skip to content

feat: added logging and otel - #232

Merged
wim07101993 merged 29 commits into
mainfrom
feat/metrics
Jun 15, 2026
Merged

feat: added logging and otel#232
wim07101993 merged 29 commits into
mainfrom
feat/metrics

Conversation

@wim07101993

@wim07101993 wim07101993 commented Jun 9, 2026

Copy link
Copy Markdown
Member

This pull request adds structured logging and OpenTelemetry-based instrumentation. The configuration system is extended to support detailed instrumentation settings, and several new dependencies are added to support these features.

Parts of this have been taken from the current otel implementation in zitadel.

Copilot AI review requested due to automatic review settings June 9, 2026 09:07
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

@wim07101993 must be a member of the zitadel team on Vercel to deploy.
- Click here to add @wim07101993 to the team.
- If you initiated this build, request access.
- If you're already a member of the zitadel team, make sure that your Vercel account is connected to your GitHub account.

Learn more about collaboration on Vercel and other options here.

@wim07101993
wim07101993 marked this pull request as draft June 9, 2026 09:08
@wim07101993
wim07101993 marked this pull request as ready for review June 9, 2026 09:12
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
nextgen Error Error Jun 15, 2026 6:31am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the server’s observability and lifecycle wiring by introducing structured logging (slog) and OpenTelemetry-based logging export, adding request/operation identification middleware, and refactoring startup/shutdown into more modular components.

Changes:

  • Added new instrumentation configuration and logging/OTEL initialization during server startup.
  • Refactored startup/shutdown flow (including a shutdown helper) and migrated various log.* calls to slog.
  • Introduced HTTP middleware for request IDs, operation IDs, and request logging.

Reviewed changes

Copilot reviewed 29 out of 33 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
cmd/server/config.go Extends server config to include instrumentation configuration.
cmd/server/server.go Refactors server startup/shutdown flow; adds instrumentation setup; adds HTTP middleware wiring.
cmd/server/shutdown.go Introduces shutdown hook aggregation/execution helper.
go.mod Adds dependencies for slog fanout and OpenTelemetry logging/export.
go.sum Updates checksums for new/updated dependencies.
internal/api/middleware/logging.go Adds request logging middleware and response-writer wrapper for status tracking.
internal/api/middleware/operation_id.go Adds ogen middleware to inject operation IDs into context.
internal/api/middleware/request_id.go Adds request ID generation and context storage middleware.
internal/api/integration_test/setup_pg_test.go Migrates integration test logging to slog.
internal/api/integration_test/setup_spanner_test.go Migrates integration test logging to slog.
internal/bootstrap/users/import.go Migrates bootstrap logging to slog.
internal/build/info.go Adds build metadata helpers (version/commit/date) for logging/resource attributes.
internal/domain/auth_check.go Adds go:generate enumer directive for AuthCheckType.
internal/instrumentation/config.go Introduces instrumentation config types (log format, masking, exporter wiring).
internal/instrumentation/logformat_enumer.go Generated enum helpers for log format configuration.
internal/instrumentation/otel/exporter_config.go Adds OTEL exporter config and exporter type enum.
internal/instrumentation/otel/exportertype_enumer.go Generated enum helpers for OTEL exporter types.
internal/instrumentation/otel/logging.go Implements OTEL log exporter/provider construction.
internal/instrumentation/zlog/context.go Adds context-based logging helpers built on slog-context.
internal/instrumentation/zlog/error_context_logger.go Adds an error-context logger wrapper with Panic/Fatal helpers.
internal/instrumentation/zlog/extractors/err_cause.go Adds extractor for context cancellation/error “cause”.
internal/instrumentation/zlog/extractors/request_details.go Adds placeholder extractor for request details.
internal/instrumentation/zlog/level.go Defines logging levels (including sloggcp-specific levels).
internal/instrumentation/zlog/logger.go Adds helper to enrich loggers with stream/version attributes.
internal/instrumentation/zlog/replacers/err_replacer.go Adds replacer for error key mapping (GCP error reporting).
internal/instrumentation/zlog/source.go Adds global toggle state for “add source” behavior.
internal/instrumentation/zlog/stream.go Adds stream enum and enablement map for log stream filtering.
internal/instrumentation/zlog/stream_enumer.go Generated enum helpers for log streams.
internal/service/postgres_testmain_test.go Migrates test setup logging to slog.
internal/storage/database/config.go Migrates fallback DB dialect logging to slog.
internal/storage/database/dialect/postgres/embedded/start.go Migrates embedded Postgres shutdown logging to slog.
internal/storage/database/repository/auth_attempt.go Migrates unsupported auth-check logging to slog.
internal/storage/database/repository/repository_test.go Migrates repository integration test setup logging to slog.
Files not reviewed (3)
  • internal/instrumentation/logformat_enumer.go: Language not supported
  • internal/instrumentation/otel/exportertype_enumer.go: Language not supported
  • internal/instrumentation/zlog/stream_enumer.go: Language not supported

Comment thread cmd/server/server.go
Comment thread cmd/server/server.go Outdated
Comment thread cmd/server/server.go
Comment thread cmd/server/server.go
Comment thread cmd/server/server.go
Comment thread internal/storage/database/repository/repository_test.go Outdated
Comment thread internal/instrumentation/config.go
Comment thread internal/instrumentation/zlog/error_context_logger.go
Comment thread internal/build/info.go
Comment thread internal/instrumentation/zlog/source.go
@wim07101993
wim07101993 marked this pull request as draft June 9, 2026 10:00
@wim07101993

Copy link
Copy Markdown
Member Author

@mridang tracing and other metrics are currently not implemented indeed. I thought to first fix logging, than move on to the other metrics.

@wim07101993 wim07101993 changed the title feat: added logging feat: added logging and otel Jun 11, 2026
@wim07101993 wim07101993 linked an issue Jun 12, 2026 that may be closed by this pull request
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

@mridang must be a member of the zitadel team on Vercel to deploy.
- Click here to add @mridang to the team.
- If you initiated this build, request access.

Learn more about collaboration on Vercel and other options here.

@wim07101993
wim07101993 enabled auto-merge (squash) June 15, 2026 06:31
@wim07101993
wim07101993 merged commit b92cdbf into main Jun 15, 2026
12 of 13 checks passed
@wim07101993
wim07101993 deleted the feat/metrics branch June 15, 2026 06:32
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.

improve telemetry

3 participants