yoursurprisecom / monolog-dd-udp-handler
Monolog Datadog UDP Handler
Installs: 16 458
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- ext-json: *
- ext-sockets: *
- datadog/dd-trace: >=0.94 <0.100 || ^1.0
- monolog/monolog: ^3.4
Requires (Dev)
- doctrine/coding-standard: ^12.0
- phpstan/phpstan: ^2.0.0
README
Overview
This Monolog handler will send the messages to the dd-log-proxy over UDP and the dd-log-proxy
will send the messages over TCP to the Datadog API.
Datadog Log Proxy
This handler is build to use in conjunction with the Datadog Log Proxy written in go. The proxy can be run as a container next to you application as a sidecar or as a standalone service.
One proxy for all applications
As this handler gather the information from the current trace, only one proxy is needed for all your applications. The logs will be connected to the correct trace and service.
Usage
Install the package using composer: composer require yoursurprisecom/monolog-dd-udp-handler
Simply create the handler with the proxy hostname and port, and push the handler into monolog:
<?php use Monolog\Logger; use YourSurpriseCom\Monolog\DatadogUdp\Handler\DataDogUdpHandler; $logger = new Logger('my_logger'); $handler = new DataDogUdpHandler("<proxy host>",1053); $logger->pushHandler($handler); $logger->info("This log message is sent non blocking over UDP to Datadog!");
Data flow
The data flow is as following:
+-----+ +-------------------------+ +--------------+ +-------------+
| PHP | ==> | Monolog Datadog Handler | ==> (UDP) | dd-log-proxy | ==> (TCP) | Datadog API |
+-----+ +-------------------------+ +--------------+ +-------------+
Datadog
This handler uses the Datadog PHP ddtrace package to gather information about the current span and trace. Logs will be connected to the trace in the UI.
It will also create its own Datadog service log-proxy
with it own spans.