Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
9f5fec8b67 | |
|
9a73e8e926 | |
|
79183991eb | |
|
7734cbc9d4 | |
|
78889a2b3c | |
|
054e51bc94 |
36
README.md
36
README.md
|
@ -1,44 +1,36 @@
|
||||||
Certainly! Here's the updated `README.md` for the Simple Otel plugin:
|
# Simple Otel Package Installation
|
||||||
|
|
||||||
# Simple Otel Plugin Installation
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To install or update the Simple Otel plugin, run the following command from the root of your WordPress HTML directory:
|
To install or update the Simple Otel package, run the following command from the root of your Concrete5 directory:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -sSL https://git.nixc.us/colin/SimpleOtel/raw/branch/main/install.sh | bash
|
curl -sSL https://git.nixc.us/colin/SimpleOtel-c5/raw/branch/main/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
## Enabling the Plugin
|
## Enabling the Package
|
||||||
|
|
||||||
After running the install script, you need to activate the plugin. You can do this via the WordPress admin dashboard:
|
After running the install script, you need to install the package. You can do this via the Concrete5 admin dashboard:
|
||||||
|
|
||||||
1. Log in to your WordPress admin dashboard.
|
1. Log in to your Concrete5 admin dashboard.
|
||||||
2. Navigate to `Plugins > Installed Plugins`.
|
2. Navigate to `Extend Concrete5`.
|
||||||
3. Find `Simple Otel` in the list and click `Activate`.
|
3. Find `Simple Otel` in the list and click `Install`.
|
||||||
|
|
||||||
Alternatively, you can activate the plugin using WP-CLI:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
wp plugin activate simple-otel --allow-root
|
|
||||||
```
|
|
||||||
|
|
||||||
## What `install.sh` Does
|
## What `install.sh` Does
|
||||||
|
|
||||||
The `install.sh` script performs the following actions:
|
The `install.sh` script performs the following actions:
|
||||||
|
|
||||||
1. Defines the URL for downloading the `simple-otel.php` file.
|
1. Defines the URL for downloading the `simple-otel.php` file.
|
||||||
2. Creates the target directory (`wp-content/plugins/simple-otel`) if it doesn't exist.
|
2. Creates the target directory (`packages/simple_otel`) if it doesn't exist.
|
||||||
3. Downloads the `simple-otel.php` file into the target directory.
|
3. Downloads the `simple-otel.php` file into the target directory.
|
||||||
4. Downloads and unzips the `vendor` directory containing pre-installed dependencies.
|
4. Downloads and unzips the `vendor` directory containing pre-installed dependencies.
|
||||||
5. Creates a blank `config.php` file if it doesn't already exist and provides a template for configuration.
|
5. Creates a blank `config.php` file if it doesn't already exist and provides a template for configuration.
|
||||||
6. Sets the correct permissions for the `simple-otel.php` and `config.php` files.
|
6. Sets the correct permissions for the `simple-otel.php` and `config.php` files.
|
||||||
7. Prints a message indicating that the Simple Otel plugin has been installed or updated successfully.
|
7. Prints a message indicating that the Simple Otel package has been installed or updated successfully.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
After installing the plugin, you can customize its behavior by editing the `config.php` file located in `wp-content/plugins/simple-otel/`.
|
After installing the package, you can customize its behavior by editing the `config.php` file located in `packages/simple_otel/`.
|
||||||
|
|
||||||
### Example `config.php`
|
### Example `config.php`
|
||||||
|
|
||||||
|
@ -66,10 +58,10 @@ if (isset($GLOBALS['tracer'])) {
|
||||||
- **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`.
|
- **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 SigNoz 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.
|
You can add more configuration options as needed. The package will include this file and apply the configurations when it initializes.
|
||||||
|
|
||||||
## 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 package, please refer to the documentation or visit the [OpenTelemetry PHP documentation](https://opentelemetry.io/docs/php/).
|
||||||
|
|
||||||
By following these instructions, you can set up the Simple Otel plugin with pre-installed dependencies, making it easier for end-users to install and activate the plugin without needing to run Composer themselves.
|
By following these instructions, you can set up the Simple Otel package with pre-installed dependencies, making it easier for end-users to install and activate the package without needing to run Composer themselves.
|
|
@ -1,10 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Define plugin details
|
# Define plugin details
|
||||||
PLUGIN_URL="https://git.nixc.us/colin/SimpleOtel/raw/branch/main/simple-otel.php"
|
PLUGIN_URL="https://git.nixc.us/colin/SimpleOtel-c5/raw/branch/main/simple-otel.php"
|
||||||
PLUGIN_DIR="./wp-content/plugins/simple-otel"
|
PLUGIN_DIR="./packages/simple_otel"
|
||||||
CONFIG_FILE="$PLUGIN_DIR/config.php"
|
CONFIG_FILE="$PLUGIN_DIR/config.php"
|
||||||
VENDOR_URL="https://git.nixc.us/colin/SimpleOtel/raw/branch/main/vendor.zip"
|
VENDOR_URL="https://git.nixc.us/colin/SimpleOtel-c5/raw/branch/main/vendor.zip"
|
||||||
|
|
||||||
# Create plugin directory if it doesn't exist
|
# Create plugin directory if it doesn't exist
|
||||||
mkdir -p "$PLUGIN_DIR"
|
mkdir -p "$PLUGIN_DIR"
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "colin/simple-otel",
|
||||||
|
"description": "Integrate OpenTelemetry with Concrete5.",
|
||||||
|
"require": {
|
||||||
|
"open-telemetry/sdk": "^1.0",
|
||||||
|
"open-telemetry/opentelemetry-php": "^1.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
// Configuration for Simple Otel plugin
|
||||||
|
// Set default values using environment variables or fallback to manual configuration
|
||||||
|
$otel_service_name = getenv('OTEL_SERVICE_NAME') ?: 'default-service-name';
|
||||||
|
$otel_exporter_otlp_endpoint = getenv('OTEL_EXPORTER_OTLP_ENDPOINT') ?: 'http://localhost:4317';
|
||||||
|
?>
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
namespace Concrete\Package\SimpleOtel;
|
||||||
|
|
||||||
|
use Concrete\Core\Package\Package;
|
||||||
|
use OpenTelemetry\SDK\Trace\TracerProvider;
|
||||||
|
use OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor;
|
||||||
|
use OpenTelemetry\Contrib\OtlpGrpc\Exporter as OtlpGrpcExporter;
|
||||||
|
|
||||||
|
class Controller extends Package
|
||||||
|
{
|
||||||
|
protected $pkgHandle = 'simple_otel';
|
||||||
|
protected $appVersionRequired = '8.0';
|
||||||
|
protected $pkgVersion = '1.0';
|
||||||
|
|
||||||
|
public function getPackageName()
|
||||||
|
{
|
||||||
|
return t('Simple Otel');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPackageDescription()
|
||||||
|
{
|
||||||
|
return t('Integrate OpenTelemetry with Concrete5.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function on_start()
|
||||||
|
{
|
||||||
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/config.php';
|
||||||
|
|
||||||
|
$otlpExporter = new OtlpGrpcExporter([
|
||||||
|
'endpoint' => $otel_exporter_otlp_endpoint,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$tracerProvider = new TracerProvider(
|
||||||
|
new SimpleSpanProcessor($otlpExporter)
|
||||||
|
);
|
||||||
|
|
||||||
|
\OpenTelemetry\API\Globals::setTracerProvider($tracerProvider);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
namespace Concrete\Package\SimpleOtel\Src;
|
||||||
|
|
||||||
|
class SimpleOtel
|
||||||
|
{
|
||||||
|
public static function traceExample()
|
||||||
|
{
|
||||||
|
$tracer = \OpenTelemetry\API\Globals::tracerProvider()->getTracer('example-tracer');
|
||||||
|
$span = $tracer->startAndActivateSpan('example-span');
|
||||||
|
$span->end();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue