1
0
Fork 1

Update simple-otel.php

This commit is contained in:
colin 2024-07-01 18:06:28 +00:00
parent 8f541c7e79
commit c2ad549493
2 changed files with 33 additions and 16 deletions

33
simple-otel.php Normal file
View File

@ -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');
?>

View File

@ -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');