Closed runtu666 closed 1 year ago
Because I found that the data reporting of php is performed synchronously, which will slow down our request response. We hope that the data can be reported asynchronously, so as to achieve the purpose of not affecting the business
No, we don't have any examples of using another data source to enqueue telemetry. We don't have a built-in way to asynchronous send yet, but we do have some future plans (probably using fibers, so not compatible with 7.4).
Have you looked at running the opentelemetry collector as an agent? Having a collector co-located with your application allows for very fast exporting. It also has some other features that can help you here, such as persistant queue and batch sending.
such as saving it in a file
We do support exporting telemetry to file. There is also an experimental part of the spec that deals with json file output for OTLP: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/file-exporter.md
You could achieve this now using stream transports to file:
$file = fopen('/path/to/traces.jsonl, 'a');
$transport = (new OpenTelemetry\SDK\Common\Export\Stream\StreamTransportFactory())->create($file, ContentTypes::NDJSON);
$exporter = new OpenTelemetry\Contrib\Otlp\SpanExporter($transport);
ok,Then how to report the json in the file to the collector? @brettmc
ok,Then how to report the json in the file to the collector?
I'm not aware of any tools that can do that, so you'd probably have to write something. You could look at how the exporter currently sends JSON signals over http to get you started - it's not complicated.
If you're already using the collector, then I think that the best thing you can do today is to run a collector as an agent (eg a sidecar). It's still synchronous, but so too is sending to a queue or database, yes?
If you are using a modern php runtime (react/amp/etc) you could also look at https://github.com/Nevay/opentelemetry-async-sdk. It's unsupported by us, but it will hopefully be integrated into our SDK in the future (after we go stable).
Now that collector is used, does it need to modify the code to switch to agent collection?
No, the collector can act as an agent or gateway/service with no changes: https://opentelemetry.io/docs/collector/deployment/ (it's more to do with placement and usage; a collector close to application is called an agent, a central collector accepting telemetry from multiple sources is a gateway).
For your application code, you only need to change your endpoint (assuming you are using OTLP) and configure the collector to forward to jaeger: application -> collector -> jaeger
ok thanks
Closing as I think this has been answered as best we can at the moment.
How do I save the tracing data first, such as saving it in a file, or saving it in a message queue or database, and then start another program to report these link tracking data to jeager?Is there a related demo for reference?