Skip to content

Commit

Permalink
Merge branch 'brefphp:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
hschimpf authored Mar 12, 2024
2 parents 2a1de5c + 1803f42 commit 378e25f
Show file tree
Hide file tree
Showing 81 changed files with 4,421 additions and 2,505 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EditorConfig is awesome: http://EditorConfig.org
# EditorConfig is awesome: https://editorconfig.org/

# top-most EditorConfig file
root = true
Expand Down
3 changes: 2 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# These are supported funding model platforms

github: Nyholm
github: [Nyholm, mnapoli]
custom: 'https://bref.sh/#enterprise'
2 changes: 1 addition & 1 deletion .github/workflows/blackfire.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
ARR[2]=$((${ARR[2]}+1))
NEW_TAG="${ARR[0]}.${ARR[1]}.${ARR[2]}"
sed -i -re "s/^## $LATEST_TAG/## $NEW_TAG\n\n### Added\n\n- Updated Blackfire to version ${{ steps.fetch_version.outputs.last }}.\n\n## $LATEST_TAG/" CHANGELOG.md
sed -i -re "s/^## $LATEST_TAG/## $NEW_TAG\n\n- Updated Blackfire to version ${{ steps.fetch_version.outputs.last }}.\n\n## $LATEST_TAG/" CHANGELOG.md
- name: Publish
env:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- prepare-release
workflow_dispatch:

jobs:
matrix:
Expand All @@ -20,6 +21,8 @@ jobs:
run: |
git fetch --prune --unshallow
echo "::set-output name=list::$(git diff --name-only HEAD $(git describe --tags --abbrev=0) | grep layers/ | cut -d / -f 2 | sort | uniq | jq -R -s -c 'split("\n")[:-1]')"
# If the workflow was triggered manually, then build all layers
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then echo "::set-output name=list::$(ls layers | jq -R -s -c 'split("\n")[:-1]')"; fi
outputs:
# Make the outputs accessible outside this job
Expand Down
83 changes: 82 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,91 @@
# Change log

## 1.4.1

- Updated Blackfire to version 1.92.9.

## 1.4.0

- Updated Blackfire to version 1.92.8.
- Added support for PHP 8.3
- Added xmlrpc extension

## 1.3.3

- Updated Blackfire to version 1.92.2.

## 1.3.2

- Updated Blackfire to version 1.90.0.

## 1.3.1

- Update PDO sqlsrv to 5.11.1

## 1.3.0

- Added extension SNMP
- Added extension Excimer
- Update elastic apm to version 1.8.4
- Use openssl 1.1.1w in relay extension

## 1.2.6

### Added

- Updated Blackfire to version 1.89.0.

## 1.2.5

### Added

- Updated Blackfire to version 1.88.1.

## 1.2.4

### Added

- Updated Blackfire to version 1.88.0.

## 1.2.3

* Fix Laravel support
* Upgrade Imagick

## 1.2.2

* Update layer versions (previous release did not include them).

## 1.2.1

* Specify specific version, so upgrades are explicit and not cached by @GrahamCampbell in https://github.com/brefphp/extra-php-extensions/pull/446
* Fixed broken amqp extension by @GrahamCampbell in https://github.com/brefphp/extra-php-extensions/pull/445
* Upgrade to grpc 1.55.0 by @GrahamCampbell in https://github.com/brefphp/extra-php-extensions/pull/449
* Fix the relay extension by @mnapoli in https://github.com/brefphp/extra-php-extensions/pull/448
* Update Blackfire extension by @bref-bot in https://github.com/brefphp/extra-php-extensions/pull/450
* Update FUNDING.yml by @mnapoli in https://github.com/brefphp/extra-php-extensions/pull/451

## 1.2.0

* Added `datadog` extension by @wolflingorg in https://github.com/brefphp/extra-php-extensions/pull/442
* ImageMagick upgrades by @GrahamCampbell in https://github.com/brefphp/extra-php-extensions/pull/434
* Upgrade NewRelic agent to v10.9.0.324 by @starred-gijs in https://github.com/brefphp/extra-php-extensions/pull/438
* OCI8 Update by @mixaster in https://github.com/brefphp/extra-php-extensions/pull/439
* Update Blackfire extension by @bref-bot in https://github.com/brefphp/extra-php-extensions/pull/444

## 1.1.2

### Added

- Updated Blackfire to version 1.87.1.

## 1.1.1

### Added

- Updated Blackfire to version 1.86.6.
- Specify grpc version for reliable builds (#435)
- Rebuild MongoDB (#436)
- Updated Blackfire to version 1.86.8.

## 1.1.0

Expand Down
115 changes: 65 additions & 50 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ a limit of 5 layers per Lambda. You can also utilise the provided docker images

> **Note**
>
> If you are using Bref v2, you need to use version `1.x` of the `bref/extra-php-extensions` package (:warning: ARM64 is not supported yet).
> If you are using Bref v2, you need to use version `1.x` of the `bref/extra-php-extensions` package.
>
> If you are using Bref v1, you need to use version `0.x` of the `bref/extra-php-extensions` package.

> **Warning**
>
> **ARM64 is not supported yet with Bref v2.**

We are happy to get contributions for other extensions. Sky is the limit! (And also your knowledge with Docker...)

## Install and configure
Expand Down Expand Up @@ -42,53 +48,58 @@ functions:
### Available layers
| Name | Serverless config (php 8.1) |
|:-------------------|:--------------------------------------|
| AMQP | `${bref-extra:amqp-php-81}` |
| Blackfire | `${bref-extra:blackfire-php-81}` |
| Bsdiff | `${bref-extra:bsdiff-php-81}` |
| Calendar | `${bref-extra:calendar-php-81}` |
| Cassandra | `${bref-extra:cassandra-php-81}` |
| Decimal | `${bref-extra:decimal-php-81}` |
| DS | `${bref-extra:ds-php-81}` |
| Elastic APM | `${bref-extra:elastic-apm-php-81}` |
| GD | `${bref-extra:gd-php-81}` |
| gnupg | `${bref-extra:gnupg-php-81}` |
| GMP | `${bref-extra:gmp-php-81}` |
| gRPC | `${bref-extra:grpc-php-81}` |
| Igbinary | `${bref-extra:igbinary-php-81}` |
| Imagick | `${bref-extra:imagick-php-81}` |
| IMAP | `${bref-extra:imap-php-81}` |
| LDAP | `${bref-extra:ldap-php-81}` |
| Mailparse | `${bref-extra:mailparse-php-81}` |
| MaxMind DB | `${bref-extra:maxminddb-php-81}` |
| Memcache | `${bref-extra:memcache-php-81}` |
| Memcached | `${bref-extra:memcached-php-81}` |
| MongoDB | `${bref-extra:mongodb-php-81}` |
| MsgPack | `${bref-extra:msgpack-php-81}` |
| Newrelic | `${bref-extra:newrelic-php-81}` |
| ODBC Snowflake | `${bref-extra:odbc-snowflake-php-81}` |
| OpenSwoole | `${bref-extra:openswoole-php-81}` |
| Oracle | `${bref-extra:oci8-php-80}` |
| Pcov | `${bref-extra:pcov-php-81}` |
| PostgreSQL | `${bref-extra:pgsql-php-81}` |
| RdKafka | `${bref-extra:rdkafka-php-81}` |
| Redis (phpredis) | `${bref-extra:redis-php-81}` |
| Redis-Igbinary | `${bref-extra:redis-igbinary-php-81}` |
| Relay | `${bref-extra:relay-php-81}` |
| Scout APM | `${bref-extra:scoutapm-php-81}` |
| Scrypt | `${bref-extra:scrypt-php-81}` |
| SPX | `${bref-extra:spx-php-81}` |
| SSH2 | `${bref-extra:ssh2-php-81}` |
| Swoole | `${bref-extra:swoole-php-81}` |
| Symfony Runtime | `${bref-extra:symfony-runtime-php-81}`|
| Microsoft SQLSRV | `${bref-extra:sqlsrv-php-81}` |
| Tideways | `${bref-extra:tideways-php-81}` |
| Tidy | `${bref-extra:tidy-php-81}` |
| UUID | `${bref-extra:uuid-php-81}` |
| Xdebug | `${bref-extra:xdebug-php-81}` |
| Xlswriter | `${bref-extra:xlswriter-php-81}` |
| Yaml | `${bref-extra:yaml-php-81}` |
| Name | Serverless config (php 8.1) |
|:-----------------|:---------------------------------------|
| AMQP | `${bref-extra:amqp-php-81}` |
| Blackfire | `${bref-extra:blackfire-php-81}` |
| Bsdiff | `${bref-extra:bsdiff-php-81}` |
| Calendar | `${bref-extra:calendar-php-81}` |
| Cassandra | `${bref-extra:cassandra-php-81}` |
| Datadog | `${bref-extra:datadog-php-81}` |
| Decimal | `${bref-extra:decimal-php-81}` |
| DS | `${bref-extra:ds-php-81}` |
| Elastic APM | `${bref-extra:elastic-apm-php-81}` |
| Excimer | `${bref-extra:excimer-php-81}` |
| GD | `${bref-extra:gd-php-81}` |
| gnupg | `${bref-extra:gnupg-php-81}` |
| GMP | `${bref-extra:gmp-php-81}` |
| gRPC | `${bref-extra:grpc-php-81}` |
| Igbinary | `${bref-extra:igbinary-php-81}` |
| Imagick | `${bref-extra:imagick-php-81}` |
| IMAP | `${bref-extra:imap-php-81}` |
| LDAP | `${bref-extra:ldap-php-81}` |
| Mailparse | `${bref-extra:mailparse-php-81}` |
| MaxMind DB | `${bref-extra:maxminddb-php-81}` |
| Memcache | `${bref-extra:memcache-php-81}` |
| Memcached | `${bref-extra:memcached-php-81}` |
| MongoDB | `${bref-extra:mongodb-php-81}` |
| MsgPack | `${bref-extra:msgpack-php-81}` |
| Newrelic | `${bref-extra:newrelic-php-81}` |
| ODBC Snowflake | `${bref-extra:odbc-snowflake-php-81}` |
| OpenSwoole | `${bref-extra:openswoole-php-81}` |
| OpenTelemetry | `${bref-extra:opentelemetry-php-81}` |
| Oracle | `${bref-extra:oci8-php-80}` |
| Pcov | `${bref-extra:pcov-php-81}` |
| PostgreSQL | `${bref-extra:pgsql-php-81}` |
| RdKafka | `${bref-extra:rdkafka-php-81}` |
| Redis (phpredis) | `${bref-extra:redis-php-81}` |
| Redis-Igbinary | `${bref-extra:redis-igbinary-php-81}` |
| Relay | `${bref-extra:relay-php-81}` |
| Scout APM | `${bref-extra:scoutapm-php-81}` |
| Scrypt | `${bref-extra:scrypt-php-81}` |
| SNMP | `${bref-extra:snmp-php-81}` |
| SPX | `${bref-extra:spx-php-81}` |
| SSH2 | `${bref-extra:ssh2-php-81}` |
| Swoole | `${bref-extra:swoole-php-81}` |
| Symfony Runtime | `${bref-extra:symfony-runtime-php-81}` |
| Microsoft SQLSRV | `${bref-extra:sqlsrv-php-81}` |
| Tideways | `${bref-extra:tideways-php-81}` |
| Tidy | `${bref-extra:tidy-php-81}` |
| UUID | `${bref-extra:uuid-php-81}` |
| Xdebug | `${bref-extra:xdebug-php-81}` |
| Xlswriter | `${bref-extra:xlswriter-php-81}` |
| xmlrpc | `${bref-extra:xmlrpc-php-81}` |
| Yaml | `${bref-extra:yaml-php-81}` |

### Blackfire installation

Expand Down Expand Up @@ -142,6 +153,10 @@ in your `serverless.yaml` in order to tell unixODBC to load the required ini fil

Read [the New Relic tutorial](docs/newrelic.md).

### Datadog

Read [the Datadog tutorial](docs/datadog.md).

## Docker images

There are Docker images for every layer. They are updated on every push to master
Expand All @@ -167,8 +182,8 @@ docker-compose.yml
Dockerfile-phpFpm
```
FROM bref/php-82-fpm-dev
COPY --from=bref/extra-mongodb-php-82 /opt /opt
FROM bref/php-82-fpm-dev:2
COPY --from=bref/extra-mongodb-php-82:1 /opt /opt
```
## For contributors and maintainers
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
},
"conflict": {
"bref/bref": "<2.0.0"
"bref/bref": "<2.1.15"
},
"license": "MIT",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"latest_versions": {
"v0": "0.12.4",
"v1": "1.1.0"
"v1": "1.4.2"
}
}
86 changes: 86 additions & 0 deletions docs/datadog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
### Datadog installation

This layer enables the installation of only the Datadog PHP extension.

To use the extension, you must also install the Datadog agent.
You can achieve this by installing another Datadog Lambda Extension layer.
For more information see https://docs.datadoghq.com/serverless/installation/python/?tab=custom the "Install the Datadog Lambda Extension" section.

If you are running an x86-based Lambda in AWS commercial regions, use the following ARN:
`arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-Extension:<version>`

If you are running an ARM-based Lambda in AWS commercial regions, use the following ARN:
`arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-Extension-ARM:<version>`

## Configuration

After installing the layer and the agent, you must configure the Datadog extension by adding the following key/value pair to a Lambda environment variable:

- `DD_ENV=<enviroment>`
- `DD_SERVICE=<service>`
- `DD_SITE=<datadoghq.eu|datadoghq.com>` (depending on your Datadog account region)
- `DD_API_KEY=<api_key>`
- `DD_SERVICE=<your service name>`
- `DD_VERSION=<your service version>`

For more details about the configuration, see https://docs.datadoghq.com/tracing/trace_collection/library_config/php/

You should also consider adding similar AWS tags to your Lambda function to link APM and Infrastructure data together using the tag/value syntax:

- `Env=<the same as DD_ENV>`
- `Service=<the same as DD_SERVICE>`
- `Team=<the team name>` (use `a-z0-9\-` pattern)
- `Tier=<A|B|C|...>` (to indicate how important the service is)

Find more about infrastructure tagging:
- https://www.datadoghq.com/blog/tagging-best-practices/
- https://learn.datadoghq.com/courses/tagging-best-practices (online course)
- Enroll in free technical sessions at https://www.datadoghq.com/technical-enablement/sessions/

## Custom instrumentation

DataDog works out of the box with the php-xx-fpm runtime. However, if you are using the php-xx runtime and BREF_LOOP_MAX>1, you must add custom instrumentation.
Otherwise, DataDog will wait until the end of a loop and only send one trace.
To add custom instrumentation, create an `instrumentation.php` file and add the following code:

```php
<?php

\DDTrace\trace_method(
'Bref\Runtime\Invoker',
'invoke',
function (\DDTrace\SpanData $span, $args, $ret, $exception) {
$span->service = getenv('DD_SERVICE');
$span->type = \DDTrace\Type::CLI;
$span->name = 'invoke';
}
);
```

This code will enable you to see all traces.

*do not forget to add `instrumentation.php` to a `composer.json` file

For EventBridge Lambdas, add the following code to the function above:

```php
<?php
if ($args[0] instanceof \Bref\Event\EventBridge\EventBridgeEvent) {
$span->resource = $args[0]->getDetailType();
}
```

This code will name your traces with the EventBridge event name.

For more information about custom instrumentation, refer to the following resources:

- https://github.com/DataDog/dd-trace-php/blob/master/examples/long-running/long-running-script.php
- https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/php/?tab=currentspan
- to link traces with a parent one: https://docs.datadoghq.com/tracing/trace_collection/trace_context_propagation/php/

## service.datadog.yaml

Consider also creating a `service.datadog.yaml` file in the root of your project.
It will give you more control over the traces and ability to add links to documentation and contact information.

To find more: https://www.datadoghq.com/blog/manage-service-catalog-categories-with-service-definition-json-schema/
Loading

0 comments on commit 378e25f

Please sign in to comment.