You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `laravel-go` library provides integrated structured logging (using `zerolog`) and distributed tracing (using `OpenTelemetry`).
4
+
5
+
## Trace IDs and Span IDs
6
+
7
+
When a job is processed, the worker automatically:
8
+
1. Starts a new OpenTelemetry trace.
9
+
2. Creates a structured logger attached to the context.
10
+
3. Injects the `trace_id` and `job_id` into the logger.
11
+
12
+
This ensures that every log message generated during the job execution is automatically tagged with the Trace ID, allowing you to correlate logs across different services or even within a single job execution.
13
+
14
+
## Using the Logger
15
+
16
+
To use the logger in your job handlers, you should retrieve it from the context using `telemetry.LoggerFromContext(ctx)`.
The telemetry system is initialized automatically when using the `queue:work` command. You can customize the behavior by setting the global logger or tracer provider in your application setup if needed, but the default setup is sufficient for most use cases.
The `queue.Job` struct provides a helper method `GetArg(key string)` to access public properties of the unserialized PHP job object.
58
+
59
+
```go
60
+
ifid:= job.GetArg("id"); id != nil {
61
+
// Use id
62
+
}
63
+
```
64
+
65
+
## Logging
66
+
67
+
The system uses `zerolog` and `OpenTelemetry`. You should retrieve the logger from the context to ensure logs are correlated with the trace ID and job ID.
0 commit comments