Laravel Go
Send traces, logs, errors, and profiles from a Laravel Go app to Everr. Hand the setup to your agent, or wire it up yourself.
Laravel Go exports OpenTelemetry traces on its own: requests, database queries, cache and Redis operations, outgoing HTTP, queued jobs, workflows, scheduled tasks, background tasks, mail, and console commands. It keeps its log lines local, records failures only on spans, and has no profiler, so on its own it fills Everr's traces but not its logs, Errors page, or profiles.
The everrlaravel Go module adds the rest. It becomes Laravel's tracer provider, sends your log lines to the same endpoint, turns every failure Laravel reports, whether a request, job, command, or background task error or a panic, into an error that Everr groups by where it happened, and profiles the app's CPU and memory, linking each CPU sample to the request or job that was running.
In development
The everrlaravel module and the Laravel Go setup in the everr-setup-telemetry skill are still
in development, in everr-labs/everr#744. Until
they're released, go get github.com/everr-labs/everr/sdk/go/everrlaravel and the Agent setup
below don't work yet. Laravel's own trace export works today: configure the
endpoint.
Let your agent wire it up
/everr-setup-telemetry Instrument this Laravel Go app and send traces, logs, errors, and profiles to EverrThe Agent adds everrlaravel, configures the endpoint, and verifies the data in your local collector.
Alternative: wire it up by hand
Add the module:
go get github.com/everr-labs/everr/sdk/go/everrlaravelRun the app through it in main.go, in place of laravel.Run:
import "github.com/everr-labs/everr/sdk/go/everrlaravel"
func main() {
everrlaravel.Run(bootstrap.Options())
}everrlaravel.Run adds a Laravel package and makes it the app's tracer provider, then runs your app as laravel.Run does. When the app stops, Laravel shuts the package down, which sends the last spans, log lines, and profiles. Don't set TracerProvider in your options yourself: the package reads Laravel's own log lines and error descriptions from its spans.
If your main.go calls laravel.New itself, add an everrlaravel.New() value to Packages and set the same value as TracerProvider:
everr := everrlaravel.New()
options.Packages = append(options.Packages, everr)
options.TracerProvider = everrRoute templates in the browser
If your app also sends browser telemetry with @everr/otel-web, add the route header middleware to the web and API stacks in bootstrap/app.go:
Middleware: func(m *laravel.Middleware, cfg *config.Config) {
// ...
m.Web.Append(everrlaravel.RouteHeader{})
m.API.Append(everrlaravel.RouteHeader{})
},Each response then carries an x-everr-route header with the route that handled it, such as /api/orders/{id}. The browser SDK names its span for the request after it, so fetch("/api/orders/42") shows up as GET /api/orders/{id}, the same name as the server's span. For requests from another origin, also list x-everr-route in Access-Control-Expose-Headers.
Pages need one more step, because your page routes live in Go and the browser can't map /users/42 to /users/{user}. With Inertia, share the route as a prop from the share function in bootstrap/app.go:
func share(r *web.Request) (inertia.Props, error) {
return inertia.Props{
// ...
"everrRoute": r.Route().URI,
}, nil
}Then tell the SDK how to read it, in the module that sets up @everr/otel-web:
import { setRouteResolver } from "@everr/otel-web";
type InertiaPage = { url: string; props?: { everrRoute?: unknown } };
const patterns = new Map<string, string>();
function remember(page: InertiaPage | null | undefined): void {
const route = page?.props?.everrRoute;
if (page && typeof route === "string" && route !== "") {
patterns.set(new URL(page.url, window.location.origin).pathname, route);
}
}
// The first page is in the HTML: a JSON script in Inertia 3, a `data-page` attribute before.
const initial = document.querySelector("[data-page]");
if (initial) {
const json =
initial instanceof HTMLScriptElement ? initial.textContent : initial.getAttribute("data-page");
remember(JSON.parse(json ?? "null"));
}
// Learn every page Inertia visits, even one that sends no record while it's current.
document.addEventListener("inertia:navigate", (event) => {
remember((event as CustomEvent<{ page: InertiaPage }>).detail.page);
});
setRouteResolver({
page: (url) => {
// A visit pushes the new page to history before the SDK records its page view.
remember(window.history.state?.page);
return patterns.get(new URL(url).pathname);
},
});Import it first in resources/js/app.tsx, so the resolver is set before the app's other imports run:
import "./telemetry";Page views, page leaves, errors, and web vitals then carry the page's route as everr.route.pattern. With Inertia's encryptHistory option on, page views after the first miss it, because the SDK records them before Inertia's navigate event, but each page's other records still carry it.
Configure the endpoint
Laravel reads OpenTelemetry settings from .env, and variables set in the process environment take precedence.
For local development, use the otlp: URL from everr local status:
OTEL_EXPORTER_OTLP_ENDPOINT=<otlp-url-from-status>
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=developmentFor production, use an API key with the Send telemetry capability (see Production telemetry) and keep it in your secret manager:
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.everr.dev
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20<your-api-key>
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=production- Use the base endpoint. The package adds
/v1/traces,/v1/logs, and/v1development/profiles. To send one signal somewhere else, set its own variables, such asOTEL_EXPORTER_OTLP_LOGS_ENDPOINTandOTEL_EXPORTER_OTLP_LOGS_HEADERS. OTEL_TRACES_SAMPLERandOTEL_TRACES_SAMPLER_ARGwork as in Laravel. A trace the sampler drops is still recorded in memory, but not sent, so its log lines and errors still arrive.- Set
OTEL_PROFILES_EXPORTER=noneto turn profiling off. - The service name defaults to
APP_NAME. SetOTEL_SERVICE_NAMEifAPP_NAMEisn't a stable name for the service. LOG_LEVELsets which log lines are sent, as it does for Laravel's local log channels, including per-package overrides such asinfo,app/orders=debug.- Tests built with
laraveltestsetOTEL_SDK_DISABLED=true, so they send nothing.
What is sent
- Traces from Laravel, with the standard OpenTelemetry attributes. A job's spans join the trace of the request that dispatched it.
- Your application's log lines written with
slog, as written, with the trace andrequest_idof the request or job they ran in. Keep secrets and personal data out of them. - One error per failure, with its type, message, and location. Panics are recorded as fatal with their stack, including panics in work started with
r.Backgroundorlaravel.Background. A panic in a goroutine started with a baregostatement crashes the process before anything can record it, so start background work through Laravel. When the failure comes from a framework error, such as a database, Redis, or JSON error, Laravel's summary (for exampleJSON error) replaces the error's text, which can quote query values, URLs, or response bodies. - Laravel's own log lines, as Laravel describes them on its spans: only safe fields, and errors as their summaries. They're sent when the request or job they ran in ends. Lines that quote message content, such as mail recipients or SMS numbers, stay local, and so do Laravel's warnings and errors logged outside any request or job, since they can quote an error's text.
- Warnings and errors from other modules that log through
slog. Their lower-level lines stay local. - CPU and heap profiles every 15 seconds. CPU samples taken while a sampled request or job ran carry its trace and span IDs.
Verify
Exercise a route that touches the database, a route that fails, and a queued job (laravel dev runs a worker). Stop the app, so it sends what it buffered, then check the errors it sent. Replace my-service with your service name:
everr local query "SELECT Timestamp, SeverityText, Body, LogAttributes.\`exception.type\` AS type FROM logs WHERE ServiceName = 'my-service' AND SeverityNumber >= 17 AND Timestamp >= now() - INTERVAL 15 MINUTE ORDER BY Timestamp DESC LIMIT 20"To check traces and other log lines, see Instrument your app.