Skip to content

Commit 5e3af56

Browse files
committed
feat: orc-9153 refactoring existing bundle
Signed-off-by: Serhii Donii <[email protected]>
1 parent 41199b9 commit 5e3af56

File tree

5 files changed

+31
-41
lines changed

5 files changed

+31
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ var/coverage/
44
composer.lock
55
/.phpunit.result.cache
66
/.phpcs-cache
7+
/var/cache

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ COMPOSE_FILE := docker-compose.yml
1818
COMPOSE_OVERRIDE := docker-compose.override.yml
1919

2020
## Environment Management
21-
start: ## Start the complete testing environment
21+
up: ## Start the complete testing environment
2222
@echo "$(BLUE)🐳 Starting Symfony OpenTelemetry Bundle Test Environment$(NC)"
2323
@docker-compose up -d --build
2424
@echo "$(GREEN)✅ Environment started successfully!$(NC)"
@@ -29,12 +29,12 @@ start: ## Start the complete testing environment
2929
@echo ""
3030
@echo "$(YELLOW)Run 'make test' to run sample tests$(NC)"
3131

32-
stop: ## Stop all services
32+
down: ## Stop all services
3333
@echo "$(YELLOW)🛑 Stopping services...$(NC)"
3434
@docker-compose down
3535
@echo "$(GREEN)✅ Services stopped$(NC)"
3636

37-
restart: stop start ## Restart all services
37+
restart: up down ## Restart all services
3838

3939
build: ## Build/rebuild all services
4040
@echo "$(BLUE)🔨 Building services...$(NC)"
@@ -145,13 +145,13 @@ load-test: ## Run simple load test
145145
@echo "$(GREEN)✅ Load test completed$(NC)"
146146

147147
## Access Commands
148-
shell: ## Access PHP container shell
148+
bash: ## Access PHP container shell
149149
@echo "$(BLUE)🐚 Accessing PHP container shell...$(NC)"
150-
@docker-compose exec php-app /bin/sh
150+
@docker-compose exec php-app /bin/bash
151151

152-
shell-tempo: ## Access Tempo container shell
152+
bash-tempo: ## Access Tempo container shell
153153
@echo "$(BLUE)🐚 Accessing Tempo container shell...$(NC)"
154-
@docker-compose exec tempo /bin/sh
154+
@docker-compose exec tempo /bin/bash
155155

156156
## Web Access
157157
grafana: ## Open Grafana in browser

Resources/config/otel_bundle.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
otel_bundle:
2-
tracer_name: '%env(OTEL_TRACER_NAME)%'
3-
service_name: '%env(OTEL_SERVICE_NAME)%'
2+
# tracer_name: '%env(OTEL_TRACER_NAME)%'
3+
# service_name: '%env(OTEL_SERVICE_NAME)%'
4+
tracer_name: example
5+
service_name: example
46
span_tracers:
57
- { class: 'Macpaw\SymfonyOtelBundle\Span\ExecutionTimeSpanTracer', tag: 'kernel.event_subscriber' }

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"php-http/discovery": true,
4343
"tbachert/spi": true,
4444
"infection/extension": true,
45-
"infection/extension-installer": true
45+
"infection/extension-installer": true,
46+
"symfony/runtime": true
4647
}
4748
},
4849
"require-dev": {
@@ -56,7 +57,8 @@
5657
"react/socket": "^1.15",
5758
"react/http": "^1.10",
5859
"react/promise": "^3.2",
59-
"react/stream": "^1.4"
60+
"react/stream": "^1.4",
61+
"symfony/runtime": "^6.4|7.0"
6062
},
6163
"scripts": {
6264
"phpcs": "phpcs",

test_app/src/Kernel.php

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
namespace App;
66

7+
use Macpaw\SymfonyOtelBundle\DependencyInjection\SymfonyOtelCompilerPass;
78
use Macpaw\SymfonyOtelBundle\SymfonyOtelBundle;
89
use OpenTelemetry\Contrib\Symfony\OtelBundle\OtelBundle;
910
use OpenTelemetry\Contrib\Symfony\OtelSdkBundle\OtelSdkBundle;
1011
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1112
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
13+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1214
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1315
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
1416
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
@@ -27,8 +29,20 @@ public function registerBundles(): iterable
2729
];
2830
}
2931

32+
protected function build(ContainerBuilder $container): void
33+
{
34+
parent::build($container);
35+
36+
$container->addCompilerPass(new SymfonyOtelCompilerPass());
37+
}
38+
3039
protected function configureContainer(ContainerConfigurator $container): void
3140
{
41+
putenv('APP_DEBUG=true');
42+
$_ENV['APP_DEBUG'] = $_SERVER['APP_DEBUG'] = true;
43+
44+
$container->import(__DIR__ . '/../../Resources/config/otel_bundle.yml');
45+
$container->import(__DIR__ . '/../../Resources/config/services.yml');
3246
$container->import('../config/services.yaml');
3347

3448
$container->extension('framework', [
@@ -37,39 +51,10 @@ protected function configureContainer(ContainerConfigurator $container): void
3751
'utf8' => true,
3852
],
3953
]);
40-
41-
$container->extension('open_telemetry', [
42-
'resource' => [
43-
'service' => [
44-
'name' => '%env(OTEL_SERVICE_NAME)%',
45-
'version' => '1.0.0',
46-
],
47-
],
48-
'tracing' => [
49-
'enabled' => true,
50-
'exporter' => [
51-
'otlp' => [
52-
'endpoint' => '%env(OTEL_EXPORTER_OTLP_ENDPOINT)%',
53-
'protocol' => '%env(OTEL_EXPORTER_OTLP_PROTOCOL)%',
54-
],
55-
],
56-
],
57-
]);
58-
59-
$container->extension('otel_bundle', [
60-
'tracer_name' => '%env(OTEL_TRACER_NAME)%',
61-
'service_name' => '%env(OTEL_SERVICE_NAME)%',
62-
'span_tracers' => [
63-
[
64-
'class' => 'Macpaw\SymfonyOtelBundle\Span\ExecutionTimeSpanTracer',
65-
'tag' => 'kernel.event_subscriber',
66-
],
67-
],
68-
]);
6954
}
7055

7156
protected function configureRoutes(RoutingConfigurator $routes): void
7257
{
7358
$routes->import('../config/routes.yaml');
7459
}
75-
}
60+
}

0 commit comments

Comments
 (0)