I am trying to send open telemetry traces to OpenSearch but I am unable to. The traces are visible on Jeager UI but they are not getting ingested in OpenSearch .I have tried everything ,created collectors and pipelines still no use
This is my otel.yaml file for otel collector
receivers:
otlp:
endpoint: "otelcol:4317"
exporters:
opensearch:
endpoint: "http://\<domain-name\>:9200"
username: "username"
password: "password"
index: traces-otel-v1-%{yyyy.MM.dd}"
and this is my index.php file
`<?php
use OpenTelemetry\API\Common\Instrumentation\Globals;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use OpenTelemetry\Contrib\Grpc\GrpcTransportFactory;
use OpenTelemetry\Contrib\Otlp\OtlpUtil;
use OpenTelemetry\Contrib\Otlp\SpanExporter;
use OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor;
use OpenTelemetry\SDK\Trace\TracerProvider;
use OpenTelemetry\API\Common\Signal\Signals;
require __DIR__ . '/vendor/autoload.php';
// Create a transport that connects to the OpenSearch endpoint
$transport = (new GrpcTransportFactory())->create('http://localhost:4317' . OtlpUtil::method(Signals::TRACE));
// Create a SpanExporter instance and pass the transport to the constructor
$exporter = new SpanExporter($transport);
// Create a TracerProvider instance and add the SpanProcessor
$tracerProvider = new TracerProvider(new SimpleSpanProcessor($exporter));
// Get the tracer for the current application
$tracer = $tracerProvider->getTracer('io.opentelemetry.contrib.php');
// Create an application
$app = AppFactory::create();
// Add routes to the application
$app->get('/', function (Request $request, Response $response) use ($tracer) {
// Create a span for the home page request
$span = $tracer->spanBuilder('home-page')->startSpan();
// Write the home page HTML to the response body
$response->getBody()->write('<h1>Welcome to our E-Commerce Store</h1>');
$response->getBody()->write('<a href="/products">View Products</a>');
// End the span
$span->end();
return $response;
});
$app->get('/products', function (Request $request, Response $response) use ($tracer) {
// Create a span for the products page request
$span = $tracer->spanBuilder('product-list')->startSpan();
// Fetch product data from the database
$products = [
['name' => 'Product 1', 'price' => 10.99],
['name' => 'Product 2', 'price' => 19.99],
// ... more products
];
// Write the products list HTML to the response body
$response->getBody()->write('<h2>Product Listings</h2>');
foreach ($products as $product) {
$response->getBody()->write('<p>' . $product['name'] . ' - $' . $product['price'] . '</p>');
}
$response->getBody()->write('<a href="/cart">Go to Cart</a>');
// End the span
$span->end();
return $response;
});
$app->get('/cart', function (Request $request, Response $response) use ($tracer) {
// Create a span for the cart page request
$span = $tracer->spanBuilder('cart')->startSpan();
// Simulate fetching cart items from the session
$cartItems = [
['product' => 'Product 1', 'quantity' => 2],
// ... more cart items
];
// Write the cart items HTML to the response body
$response->getBody()->write('<h2>Shopping Cart</h2>');
foreach ($cartItems as $item) {
$response->getBody()->write('<p>' . $item['product'] . ' - Quantity: ' . $item['quantity'] . '</p>');
}
$response->getBody()->write('<a href="/checkout">Proceed to Checkout</a>');
// End the span
$span->end();
return $response;
});
// Run the application
$app->run();`
` I tried sending to jeager and then to opensearch ,it's visible on jeager UI but not in opensearch