jonnx/datadog-client
Composer 安装命令:
composer require jonnx/datadog-client
包简介
Standalone DataDog PHP Client, works without datadog agent
关键字:
README 文档
README
Lightweight php-only datadog client
This is a simple php client for datadog which does not require setting up the DataDog Agent This library supports sending metric data or events at the moment, as those should be the most common use cases. Feel free to extend it to your own needs or sending pull requests.
Installation
This library can be installed using composer
composer require jonnx/datadog-client
Getting Started
To start sending requests to Datadog you need to provider your personal API key first. You find that key in Datadog API Settings.
$client = new Client('mysecretapikey');
Sending Events
Events can be sent directly to Datadog using the provided Event class:
$myEvent = new Event('This is my test event', 'Optional event title');
$client->sendEvent($myEvent);
Additional properties can be set the usual way:
$myEvent->setAlertType(Event::TYPE_ERROR);
There is also a shortcut method which handles all that stuff for you:
// Create and send event in one call
$client->event('My test event', 'Optional event title', array(
'alert_type' => Event::TYPE_ERROR
));
Event Properties
dateHappened
Type: integer
Timestamp of the event. Defaults to current timestamp.
priority
Type: Event::PRIORITY_
Event priority. Datadog supports LOW and NORMAL
alertType
Type: Event::TYPE_
Event alert_type. Datadog supports INFO, WARNING, ERROR and SUCCESS
aggregationKey
Type: string
Arbitary string used to group events
Sending Metrics
Datadog requires metric data to be encapsulated into a series. One series contains one or more metric objects, which itself contains one or more measurement points.
// Create Series
$mySeries = new Series();
// Create a new metric with multiple points
$firstMetric = new Metric('my.metric.name', array(
array(20), // Dummy points
array(13456789, 30), // Point with timestamp set
array(40), // If not set, timestamp default to current time
));
// Create a new metric with one point
$secondMetric = new Metric('my.second.metric', array(20));
$mySeries->addMetrics(array(
$firstMetric,
$secondMetric
));
// Send data
$client->sendSeries($mySeries);
If you want to send just one metric at a time, you can use the Client::sendMetric method:
// Create a new metric with multiple points
$myMetric = new Metric('my.metric.name', array(
array(20), // Dummy points
array(13456789, 30), // Point with timestamp set
array(40), // If not set, timestamp default to current time
));
$client->sendMetric($myMetric);
Again, there is a shortcut method which can handle that for you:
$client->metric('my.test.metric', array(
array(20),
array(13456789, 30),
array(40),
));
Metric Properties
name
Type: string
Name of the metric. Can contain underscored or dots for easier grouping, e.g. web.exception.404
type
Type: Metric::TYPE_
Type of the metric. Datadog supports gauge or counter
host
Type: string
Hostname of the source machine
points
Type: array
Array of data points.
A point consists of an optional timestamp and a numeric value. If no timestamp is specified, the current timestamp will be used. Order matters. If a timestamp is specified, it should be the first value.
Examples:
// Timestamp will be set to time()
$simplePoint = array(20);
// Set timestamp to explicit value
$pointWithTimestamp = array(1234567, 20);
Origin of this package
This is a re-upload of the original repository removed by the orignal author Matthias Bayer. Class names and paths have been updated to submit this project to packagist. This ensures it can easily be installed using composer out of the box.
Source: https://twitter.com/JonasWeigert/status/1590894486397538306
jonnx/datadog-client 适用场景与选型建议
jonnx/datadog-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 48.36k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 11 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「client」 「standalone」 「DataDog」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jonnx/datadog-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jonnx/datadog-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jonnx/datadog-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Standalone library to create timelines
repository php library
Standalone version of Laravel Mix php class
Mock PSR-18 HTTP client
MIDDAG PHP Framework — DDD kernel, container, Inertia adapter, router, form engine, and domain abstractions
Asynchronous MQTT client built on React
统计信息
- 总下载量: 48.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-14