Skip to content

Commit d35f2f0

Browse files
authored
Merge pull request #1 from utopia-php/initial-commit
feat: opentelemetry adapter
2 parents 53a25ec + 590ddcc commit d35f2f0

File tree

20 files changed

+5462
-0
lines changed

20 files changed

+5462
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "Linter"
2+
3+
on: [pull_request]
4+
jobs:
5+
lint:
6+
name: Linter
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 2
14+
15+
- run: git checkout HEAD^2
16+
17+
- name: Run Linter
18+
run: |
19+
docker run --rm -v $PWD:/app composer sh -c \
20+
"composer install --profile --ignore-platform-reqs && composer lint"

.github/ISSUE_TEMPLATE/bug.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: "🐛 Bug Report"
2+
description: "Submit a bug report to help us improve"
3+
title: "🐛 Bug Report: "
4+
labels: [bug]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out our bug report form 🙏
10+
- type: textarea
11+
id: steps-to-reproduce
12+
validations:
13+
required: true
14+
attributes:
15+
label: "👟 Reproduction steps"
16+
description: "How do you trigger this bug? Please walk us through it step by step."
17+
placeholder: "When I ..."
18+
- type: textarea
19+
id: expected-behavior
20+
validations:
21+
required: true
22+
attributes:
23+
label: "👍 Expected behavior"
24+
description: "What did you think would happen?"
25+
placeholder: "It should ..."
26+
- type: textarea
27+
id: actual-behavior
28+
validations:
29+
required: true
30+
attributes:
31+
label: "👎 Actual Behavior"
32+
description: "What did actually happen? Add screenshots, if applicable."
33+
placeholder: "It actually ..."
34+
- type: dropdown
35+
id: utopia-version
36+
attributes:
37+
label: "🎲 Utopia Framework version"
38+
description: "What version of Utopia are you running?"
39+
options:
40+
- Version 0.18.x
41+
- Version 0.17.x
42+
- Version 0.16.x
43+
- Version 0.15.x
44+
- Version 0.14.x
45+
- Different version (specify in environment)
46+
validations:
47+
required: true
48+
- type: dropdown
49+
id: php-version
50+
attributes:
51+
label: "🐘 PHP Version"
52+
description: "What version of PHP are you running?"
53+
options:
54+
- PHP 8.0
55+
- Different version (specify in environment)
56+
validations:
57+
required: true
58+
- type: dropdown
59+
id: operating-system
60+
attributes:
61+
label: "💻 Operating system"
62+
description: "What OS is your server / device running on?"
63+
options:
64+
- Linux
65+
- MacOS
66+
- Windows
67+
- Something else
68+
validations:
69+
required: true
70+
- type: textarea
71+
id: environment
72+
validations:
73+
required: false
74+
attributes:
75+
label: "🧱 Your Environment"
76+
description: "Is your environment customized in any way?"
77+
placeholder: "I use Cloudflare for ..."
78+
- type: checkboxes
79+
id: no-duplicate-issues
80+
attributes:
81+
label: "👀 Have you spent some time to check if this issue has been raised before?"
82+
description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
83+
options:
84+
- label: "I checked and didn't find similar issue"
85+
required: true
86+
- type: checkboxes
87+
id: read-code-of-conduct
88+
attributes:
89+
label: "🏢 Have you read the Code of Conduct?"
90+
options:
91+
- label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
92+
required: true
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "📚 Documentation"
2+
description: "Report an issue related to documentation"
3+
title: "📚 Documentation: "
4+
labels: [documentation]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to make our documentation better 🙏
10+
- type: textarea
11+
id: issue-description
12+
validations:
13+
required: true
14+
attributes:
15+
label: "💭 Description"
16+
description: "A clear and concise description of what the issue is."
17+
placeholder: "Documentation should not ..."
18+
- type: checkboxes
19+
id: no-duplicate-issues
20+
attributes:
21+
label: "👀 Have you spent some time to check if this issue has been raised before?"
22+
description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
23+
options:
24+
- label: "I checked and didn't find similar issue"
25+
required: true
26+
- type: checkboxes
27+
id: read-code-of-conduct
28+
attributes:
29+
label: "🏢 Have you read the Code of Conduct?"
30+
options:
31+
- label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
32+
required: true
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "🚀 Feature"
2+
description: "Submit a proposal for a new feature"
3+
title: "🚀 Feature: "
4+
labels: [feature]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out our feature request form 🙏
10+
- type: textarea
11+
id: feature-description
12+
validations:
13+
required: true
14+
attributes:
15+
label: "🔖 Feature description"
16+
description: "A clear and concise description of what the feature is."
17+
placeholder: "You should add ..."
18+
- type: textarea
19+
id: pitch
20+
validations:
21+
required: true
22+
attributes:
23+
label: "🎤 Pitch"
24+
description: "Please explain why this feature should be implemented and how it would be used. Add examples, if applicable."
25+
placeholder: "In my use-case, ..."
26+
- type: checkboxes
27+
id: no-duplicate-issues
28+
attributes:
29+
label: "👀 Have you spent some time to check if this issue has been raised before?"
30+
description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
31+
options:
32+
- label: "I checked and didn't find similar issue"
33+
required: true
34+
- type: checkboxes
35+
id: read-code-of-conduct
36+
attributes:
37+
label: "🏢 Have you read the Code of Conduct?"
38+
options:
39+
- label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
40+
required: true
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "CodeQL"
2+
3+
on: [pull_request]
4+
jobs:
5+
lint:
6+
name: CodeQL
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
13+
- name: Run CodeQL
14+
run: |
15+
docker run --rm -v $PWD:/app composer sh -c \
16+
"composer install --profile --ignore-platform-reqs && composer check"
17+

.github/workflows/lint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Linter"
2+
3+
on: [pull_request]
4+
jobs:
5+
lint:
6+
name: Linter
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
13+
- name: Run Linter
14+
run: |
15+
docker run --rm -v $PWD:/app composer sh -c \
16+
"composer install --profile --ignore-platform-reqs && composer lint"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
/.idea/
3+
*.cache

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Utopia Telemetry
2+
3+
![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/telemetry.svg)
4+
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)
5+
6+
Utopia Telemetry is a powerful Telemtry library. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).
7+
8+
Although this library is part of the [Utopia System](https://github.com/utopia-php) project it is dependency free and can be used as standalone with any other PHP project or framework.
9+
10+
## Getting Started
11+
12+
Install using composer:
13+
14+
```bash
15+
composer require utopia-php/telemetry
16+
```
17+
18+
Init in your application:
19+
20+
```php
21+
<?php
22+
23+
require_once __DIR__ . '/vendor/autoload.php';
24+
25+
// Create a Telemetry instance using OpenTelemetry adapter.
26+
use Utopia\Telemetry\Adapter\OpenTelemetry;
27+
28+
$telemetry = new OpenTelemetry('http://localhost:4138', 'namespace', 'app', 'unique-instance-name');
29+
$counter = $telemetry->createUpDownCounter('http.server.active_requests', '{request}');
30+
31+
$counter->add(1);
32+
$counter->add(2);
33+
34+
// Periodically collect metrics and send them to the configured OpenTelemetry endpoint.
35+
$telemetry->collect();
36+
37+
// Example using Swoole
38+
\Swoole\Timer::tick(60_000, fn () => $telemetry->collect());
39+
```
40+
41+
## System Requirements
42+
43+
Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.
44+
45+
## Copyright and license
46+
47+
The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)

composer.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "utopia-php/telemetry",
3+
"type": "library",
4+
"keywords": [
5+
"php",
6+
"framework",
7+
"upf"
8+
],
9+
"license": "MIT",
10+
"minimum-stability": "stable",
11+
"autoload": {
12+
"psr-4": {
13+
"Utopia\\": "src/"
14+
}
15+
},
16+
"scripts": {
17+
"lint": "vendor/bin/pint --test",
18+
"format": "vendor/bin/pint",
19+
"check": "vendor/bin/phpstan analyse -c phpstan.neon",
20+
"test": "vendor/bin/phpunit --configuration phpunit.xml",
21+
"bench": "vendor/bin/phpbench run --report=benchmark"
22+
},
23+
"require": {
24+
"ext-protobuf": "*",
25+
"ext-opentelemetry": "*",
26+
"php": ">=8.0",
27+
"open-telemetry/sdk": "^1.1",
28+
"symfony/http-client": "^7.1",
29+
"nyholm/psr7": "^1.8",
30+
"open-telemetry/exporter-otlp": "^1.1"
31+
},
32+
"require-dev": {
33+
"phpunit/phpunit": "^9.5.25",
34+
"laravel/pint": "^1.2",
35+
"phpstan/phpstan": "^1.10",
36+
"phpbench/phpbench": "^1.2"
37+
},
38+
"config": {
39+
"allow-plugins": {
40+
"php-http/discovery": true,
41+
"tbachert/spi": true
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)