-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
Symfony | ||
Fastly | ||
Monolog | ||
OpenTelemetry | ||
Blackfire | ||
gRPC | ||
OTLP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1598,3 +1598,9 @@ YYYY | |
zlib | ||
zsh | ||
ZSH | ||
Grafana | ||
OpenTelemetry | ||
OTLP | ||
gRPC | ||
Datadog | ||
NewRelic |
8 changes: 4 additions & 4 deletions
8
...sting/configurations/framework/monolog.md → ...g/configurations/observability/logging.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
nav: | ||
title: Profiling / Tracing | ||
position: 20 | ||
|
||
--- | ||
|
||
# Profiling | ||
|
||
Shopware provides a built-in profiler abstraction to measure the performance of code parts and publish this data to a profiler backend. | ||
|
||
## Enabling the profiler backends | ||
|
||
By default, only the Stopwatch profiler (Symfony Profiler Bar) is enabled. To enable the other profiler backends, you have to add the following configuration to your `config/packages/shopware.yaml` file: | ||
|
||
```yaml | ||
shopware: | ||
profiler: | ||
integrations: | ||
- Symfony | ||
- Datadog | ||
- Tideways | ||
- OpenTelemetry | ||
``` | ||
::: info | ||
The OpenTelemetry profiler is not installed by default. Checkout the [OpenTelemetry Integration](./opentelemetry.md) to learn how to install it. | ||
::: | ||
## Adding custom spans | ||
To add custom spans to the profiler, you can use the `Shopware\Core\Profiling\Profiler::trace` method: | ||
|
||
```php | ||
Check failure on line 34 in guides/hosting/configurations/observability/profiling.md GitHub Actions / LanguageTool[LanguageTool] guides/hosting/configurations/observability/profiling.md#L34
Raw output
|
||
use Shopware\Core\Profiling\Profiler; | ||
$value = Profiler::trace('my-example-trace', function () { | ||
return $myFunction(); | ||
}); | ||
``` | ||
|
||
And then you can see the trace in the configured profiler backends. | ||
|
||
## Adding a custom profiler backend | ||
|
||
To add a custom profiler backend, you need to implement the `Shopware\Core\Profiling\Integration\ProfilerInterface` interface and register it as a service with the tag `shopware.profiler`. | ||
|
||
The following example shows a custom profiler backend that logs the traces to the console: | ||
|
||
```php | ||
Check failure on line 50 in guides/hosting/configurations/observability/profiling.md GitHub Actions / LanguageTool[LanguageTool] guides/hosting/configurations/observability/profiling.md#L50
Raw output
|
||
namespace App\Profiler; | ||
use Shopware\Core\Profiling\Integration\ProfilerInterface; | ||
class ConsoleProfiler implements ProfilerInterface | ||
{ | ||
public function start(string $title, string $category, array $tags): void | ||
{ | ||
echo "Start $name\n"; | ||
} | ||
public function stop(string $title): void | ||
{ | ||
echo "Stop $name\n"; | ||
} | ||
} | ||
``` | ||
|
||
```xml | ||
Check failure on line 70 in guides/hosting/configurations/observability/profiling.md GitHub Actions / LanguageTool[LanguageTool] guides/hosting/configurations/observability/profiling.md#L70
Raw output
|
||
<service id="App\Profiler"> | ||
<tag name="shopware.profiler" integration="Console"/> | ||
</service> | ||
``` | ||
|
||
The attribute `integration` is used to identify the profiler backend in the configuration. |