diff --git a/README.md b/README.md index 0bdb283..650697e 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,57 @@ if (isset($GLOBALS['tracer'])) { ### Explanation - **Service Name**: Set the name of the service as it will appear in your observability platform. It uses the `OTEL_SERVICE_NAME` environment variable if set; otherwise, it defaults to `default-service-name`. -- **OTLP Endpoint**: Specify the endpoint where the OpenTelemetry Collector is running. It uses the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable if set; otherwise, it defaults to `http://localhost:4317`. +- **OTLP Endpoint**: Specify the endpoint where SigNoz is running. It uses the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable if set; otherwise, it defaults to `http://localhost:4317`. You can add more configuration options as needed. The plugin will include this file and apply the configurations when it initializes. ## 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/). \ No newline at end of file +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 + $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. \ No newline at end of file