Replace custom Loki HTTP push with native OpenTelemetry OTLP exporter#1876
Replace custom Loki HTTP push with native OpenTelemetry OTLP exporter#1876simonknittel merged 7 commits intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Co-authored-by: simonknittel <8451099+simonknittel@users.noreply.github.com>
Co-authored-by: simonknittel <8451099+simonknittel@users.noreply.github.com>
Co-authored-by: simonknittel <8451099+simonknittel@users.noreply.github.com>
|
@copilot Replace @vercel/otel with the original OTel packages instead of this vendor-specific one |
Co-authored-by: simonknittel <8451099+simonknittel@users.noreply.github.com>
Co-authored-by: simonknittel <8451099+simonknittel@users.noreply.github.com>
Replaced Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR migrates the Next.js app's logging infrastructure from a custom Loki HTTP implementation to the OpenTelemetry (OTel) standard. The change enables vendor-agnostic observability by using native OTel SDK packages instead of Vercel-specific tooling.
Changes:
- Replaced
@vercel/otelwith native OpenTelemetry SDK packages for traces and logs - Created new
otel.tsmodule that emits logs via the OTel Logs API with proper severity mapping - Removed custom Loki HTTP push logic and associated environment variables
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
app/src/modules/logging/otel.ts |
New module implementing OTel log emission with severity mapping and attribute handling |
app/src/modules/logging/loki.ts |
Deleted custom Loki HTTP push implementation |
app/src/modules/logging/index.ts |
Updated to use logToOTel instead of logToLoki, changed log functions from async to sync |
app/src/instrumentation.ts |
Replaced @vercel/otel registration with native NodeSDK configuration for traces and LoggerProvider for logs |
app/src/env.ts |
Removed LOKI_HOST, LOKI_AUTH_USER, and LOKI_AUTH_PASSWORD environment variables |
app/package.json |
Added native OTel packages and removed @vercel/otel dependency |
Files not reviewed (1)
- app/package-lock.json: Language not supported
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
90ac1d6 to
0e23f57
Compare
|



The Next.js app was pushing logs to Loki via a custom fetch implementation. This replaces it with the OpenTelemetry Logs API using native OpenTelemetry SDK packages.
Changes
@opentelemetry/sdk-node,@opentelemetry/exporter-trace-otlp-http,@opentelemetry/resources, and@opentelemetry/semantic-conventionsNodeSDKfor traces andLoggerProviderfor logs ininstrumentation.ts, sending traces to{OTEL_EXPORTER_OTLP_ENDPOINT}/v1/tracesand logs to{OTEL_EXPORTER_OTLP_ENDPOINT}/v1/logsotel.tsthat emits logs via OTel API with severity mapping (info/warn/error → SeverityNumber)log.info(),log.warn(),log.error()remain unchanged; now route to OTel instead of Lokiloki.tsandLOKI_*environment variablesImplementation
Traces and logs are batched and sent to any OTLP-compatible backend when
ENABLE_INSTRUMENTATION=true. Uses pure OpenTelemetry packages with no vendor lock-in.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.