Update simple-otel.php
This commit is contained in:
parent
8f541c7e79
commit
c2ad549493
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: OpenTelemetry Integration
|
||||
Description: Integrate OpenTelemetry with WordPress.
|
||||
Version: 1.0
|
||||
Author: Colin
|
||||
*/
|
||||
|
||||
// Ensure the autoload file is included
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use OpenTelemetry\SDK\Trace\TracerProviderFactory;
|
||||
use OpenTelemetry\SDK\Common\Util\ShutdownHandler;
|
||||
|
||||
function otel_init() {
|
||||
$tracerProvider = (new TracerProviderFactory())->create();
|
||||
$GLOBALS['tracer'] = $tracerProvider->getTracer('wordpress');
|
||||
|
||||
$shutdownHandler = new ShutdownHandler($tracerProvider);
|
||||
register_shutdown_function([$shutdownHandler, 'shutdown']);
|
||||
}
|
||||
add_action('init', 'otel_init');
|
||||
|
||||
function otel_trace_example() {
|
||||
$tracer = $GLOBALS['tracer'];
|
||||
$span = $tracer->startAndActivateSpan('example-span');
|
||||
|
||||
// Your custom code
|
||||
|
||||
$tracer->endActiveSpan();
|
||||
}
|
||||
add_action('wp_head', 'otel_trace_example');
|
||||
?>
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: Simple Tracking
|
||||
Description: Embeds tracking code into your WordPress site.
|
||||
Version: 1.0
|
||||
Author: Colin
|
||||
Author URI: https://git.nixc.us/colin/SimpleTracking.git
|
||||
*/
|
||||
|
||||
function add_simple_tracking_code() {
|
||||
$tracking_code_path = plugin_dir_path(__FILE__) . 'tracking-code.php';
|
||||
if (file_exists($tracking_code_path)) {
|
||||
include $tracking_code_path;
|
||||
}
|
||||
}
|
||||
add_action('wp_head', 'add_simple_tracking_code');
|
Loading…
Reference in New Issue