Update README.md
This commit is contained in:
parent
e335be441c
commit
b47108d242
47
README.md
47
README.md
|
@ -68,50 +68,3 @@ You can add more configuration options as needed. The plugin will include this f
|
||||||
## Additional Information
|
## Additional Information
|
||||||
|
|
||||||
For more information on how to use and configure the Simple Otel plugin, please refer to the documentation or visit the [OpenTelemetry PHP documentation](https://opentelemetry.io/docs/php/).
|
For more information on how to use and configure the Simple Otel plugin, please refer to the documentation or visit the [OpenTelemetry PHP documentation](https://opentelemetry.io/docs/php/).
|
||||||
|
|
||||||
## Example `simple-otel.php` Plugin File
|
|
||||||
|
|
||||||
Here is an example of what the `simple-otel.php` plugin file might look like:
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Plugin Name: Simple Otel
|
|
||||||
Description: Integrate OpenTelemetry with WordPress.
|
|
||||||
Version: 1.0
|
|
||||||
Author: Your Name
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Ensure the autoload file is included
|
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
|
||||||
require_once __DIR__ . '/config.php';
|
|
||||||
|
|
||||||
use OpenTelemetry\SDK\Trace\TracerProvider;
|
|
||||||
use OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor;
|
|
||||||
use OpenTelemetry\Contrib\OtlpGrpc\Exporter as OtlpGrpcExporter;
|
|
||||||
|
|
||||||
// Create an OTLP GRPC exporter
|
|
||||||
$otlpExporter = new OtlpGrpcExporter([
|
|
||||||
'endpoint' => $otel_exporter_otlp_endpoint,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Create a tracer provider with the OTLP exporter
|
|
||||||
$tracerProvider = new TracerProvider(
|
|
||||||
new SimpleSpanProcessor($otlpExporter)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Register the tracer provider globally
|
|
||||||
\OpenTelemetry\API\Globals::setTracerProvider($tracerProvider);
|
|
||||||
|
|
||||||
// Example usage of the tracer
|
|
||||||
function otel_trace_example() {
|
|
||||||
$tracer = \OpenTelemetry\API\Globals::tracerProvider()->getTracer('example-tracer');
|
|
||||||
$span = $tracer->startAndActivateSpan('example-span');
|
|
||||||
// Your custom code here
|
|
||||||
$span->end();
|
|
||||||
}
|
|
||||||
add_action('wp_head', 'otel_trace_example');
|
|
||||||
?>
|
|
||||||
```
|
|
||||||
|
|
||||||
By following these instructions, you can set up the Simple Otel plugin to send telemetry data directly to SigNoz without the need for an intermediate OpenTelemetry Collector.
|
|
Loading…
Reference in New Issue