Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit fe3ae1b

Browse files
committed
fix: rename
1 parent aa34c87 commit fe3ae1b

File tree

7 files changed

+68
-183
lines changed

7 files changed

+68
-183
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ php artisan vendor:publish --provider="Overtrue\LaravelOpenTelemetry\OpenTelemet
2929
### Update the environment variables
3030

3131
```dotenv
32-
OTLE_ENABLED=true
33-
OTLE_AUTO_TRACE_REQUESTS=true
32+
OTEL_ENABLED=true
33+
OTEL_AUTO_TRACE_REQUESTS=true
3434
OTEL_PHP_AUTOLOAD_ENABLED=true
3535
OTEL_PHP_TRACE_CLI_ENABLED=true
3636
OTEL_SERVICE_NAME=my-app
@@ -52,7 +52,7 @@ protected $middleware = [
5252
];
5353
```
5454

55-
or you can set the env variable `OTLE_AUTO_TRACE_REQUESTS` to `true` to enable it automatically.
55+
or you can set the env variable `OTEL_AUTO_TRACE_REQUESTS` to `true` to enable it automatically.
5656

5757
### Custom span
5858

config/otel.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
use OpenTelemetry\SemConv\ResourceAttributes;
4+
use Overtrue\LaravelOpenTelemetry\Watchers;
5+
6+
return [
7+
/**
8+
* Enable or disable the OpenTelemetry Laravel Extension.
9+
*/
10+
'enabled' => env('OTEL_ENABLED', true),
11+
12+
/**
13+
* Auto Register the MeasureRequest middleware.
14+
*/
15+
'automatically_trace_requests' => env('OTEL_AUTO_TRACE_REQUESTS', true),
16+
17+
/**
18+
* Allow to trace requests with specific headers. You can use `*` as wildcard.
19+
*/
20+
'allowed_headers' => [
21+
'referer',
22+
'x-*',
23+
'accept',
24+
'request-id',
25+
],
26+
27+
/**
28+
* Sensitive headers will be marked as *** from the span attributes. You can use `*` as wildcard.
29+
*/
30+
'sensitive_headers' => [
31+
// 'cookie',
32+
// 'authorization',
33+
// ...
34+
],
35+
36+
/**
37+
* The name of the header that will be used to pass the trace id in the response.
38+
* if set to `null`, the header will not be added to the response.
39+
*/
40+
'response_trace_header_name' => env('OTEL_RESPONSE_TRACE_HEADER_NAME', 'X-Trace-Id'),
41+
42+
/**
43+
* Watchers to be registered.
44+
*/
45+
'watchers' => [
46+
Watchers\ExceptionWatcher::class,
47+
Watchers\AuthenticateWatcher::class,
48+
Watchers\EventWatcher::class,
49+
Watchers\QueueWatcher::class,
50+
Watchers\RedisWatcher::class,
51+
// App\Trace\Watchers\YourCustomWatcher::class, // Add your custom watcher here.
52+
],
53+
];

config/otle.php

Lines changed: 0 additions & 168 deletions
This file was deleted.

src/Facades/Measure.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
use Illuminate\Support\Facades\Facade;
66
use OpenTelemetry\API\Trace\SpanInterface;
7+
use OpenTelemetry\API\Trace\TracerInterface;
78
use OpenTelemetry\Context\ContextInterface;
89
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;
910
use OpenTelemetry\Context\ScopeInterface;
1011
use Overtrue\LaravelOpenTelemetry\Support\SpanBuilder;
1112
use Overtrue\LaravelOpenTelemetry\Support\StartedSpan;
12-
use Overtrue\LaravelOpenTelemetry\Tracer;
1313

1414
/**
1515
* @method static SpanBuilder span(string $name)
@@ -18,7 +18,7 @@
1818
* @method static SpanInterface activeSpan()
1919
* @method static ScopeInterface|null activeScope()
2020
* @method static string traceId()
21-
* @method static Tracer tracer()
21+
* @method static TracerInterface tracer()
2222
* @method static TextMapPropagatorInterface propagator()
2323
* @method static array propagationHeaders(?ContextInterface $context = null)
2424
* @method static ContextInterface extractContextFromPropagationHeaders(array $headers)

src/Middlewares/MeasureRequest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ class MeasureRequest
2626
*/
2727
public function handle(Request $request, Closure $next, ?string $name = null)
2828
{
29-
static::$allowedHeaders = $this->normalizeHeaders(config('otle.allowed_headers', []));
29+
static::$allowedHeaders = $this->normalizeHeaders(config('otel.allowed_headers', []));
3030

3131
static::$sensitiveHeaders = array_merge(
32-
$this->normalizeHeaders(config('otle.sensitive_headers', [])),
32+
$this->normalizeHeaders(config('otel.sensitive_headers', [])),
3333
$this->defaultSensitiveHeaders
3434
);
3535

3636
$span = Measure::activeSpan()->setAttributes($this->getRequestSpanAttributes($request));
37-
$scope = Measure::activeScope();
3837
$context = Context::getCurrent();
3938

4039
try {
@@ -48,7 +47,7 @@ public function handle(Request $request, Closure $next, ?string $name = null)
4847
}
4948

5049
// Add trace id to response header if configured.
51-
if ($traceIdHeaderName = config('otle.response_trace_header_name')) {
50+
if ($traceIdHeaderName = config('otel.response_trace_header_name')) {
5251
$response->headers->set($traceIdHeaderName, Measure::traceId());
5352
}
5453

src/OpenTelemetryServiceProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ class OpenTelemetryServiceProvider extends ServiceProvider
1414
public function boot(): void
1515
{
1616
$this->publishes([
17-
__DIR__.'/../config/otle.php' => $this->app->configPath('otle.php'),
17+
__DIR__.'/../config/otel.php' => $this->app->configPath('otel.php'),
1818
], 'config');
1919

20-
if (config('otle.enabled') === false) {
20+
if (config('otel.enabled') === false) {
2121
return;
2222
}
2323

24-
if (config('otle.automatically_trace_requests')) {
24+
if (config('otel.automatically_trace_requests')) {
2525
$this->injectHttpMiddleware(app(Kernel::class));
2626
}
2727

28-
foreach (config('otle.watchers') as $watcher) {
28+
foreach (config('otel.watchers') as $watcher) {
2929
$this->app->make($watcher)->register($this->app);
3030
}
3131
}
3232

3333
public function register(): void
3434
{
3535
$this->mergeConfigFrom(
36-
__DIR__.'/../config/otle.php', 'otle',
36+
__DIR__.'/../config/otel.php', 'otel',
3737
);
3838

39-
if (config('otle.enabled') === false) {
39+
if (config('otel.enabled') === false) {
4040
return;
4141
}
4242

src/Support/SpanBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use OpenTelemetry\API\Trace\SpanContextInterface;
88
use OpenTelemetry\API\Trace\SpanInterface;
99
use OpenTelemetry\Context\ContextInterface;
10+
use OpenTelemetry\SDK\Common\Time\SystemClock;
1011

1112
// this file is copied from https://github.com/keepsuit/laravel-opentelemetry/blob/main/src/Support/SpanBuilder.php
1213
class SpanBuilder

0 commit comments

Comments
 (0)