open-telemetry / opentelemetry-ruby

OpenTelemetry Ruby API & SDK, and related gems
https://opentelemetry.io/
Apache License 2.0
487 stars 238 forks source link

Examples Exporting Traces to Collector. #771

Closed contractormarketplace closed 3 years ago

contractormarketplace commented 3 years ago

We are trying to build a proof of concept application that will export traces to the collector. We did NOT find any examples that export traces to collector. Are there any sample apps that will export traces to collector? Can you please provide references.

ahayworth commented 3 years ago

Hi @contractormarketplace -

One place to look would be the instrumentation/ directory in this repo - most of the auto-instrumentation libraries ship with runnable examples that will export traces. It may vary by example file, but in general you could point any of those examples at an OTLP collector and the traces would end up there (instead of in your console).

I've played around with the idea of sample applications as well, and here's a ruby / protobuf example: https://github.com/ahayworth/hipster-shop/tree/master/src/cartservice . It's not up to the latest ruby API, but the gist of it should be the same. (Note that the cartservice.rb file contains a whole service, not just the instrumentation bits - but I trust you can see where opentelemetry is being used, etc).

If you have any specific questions, please let us know - we are always looking to improve documentation. 😄

contractormarketplace commented 3 years ago

Hi @ahayworth , I am new to Ruby but thanks to your guidance I found a simple application in instrumentation/http_client.

I did the following :- sudo gem install opentelemetry-instrumentation-http_client

opentelemetry-ruby/instrumentation/http_client/example$ ruby trace_demonstration.rb

And ended up with the following error : Traceback (most recent call last): 1: from trace_demonstration.rb:5:in <main>' trace_demonstration.rb:5:inrequire': cannot load such file -- httpclient (LoadError)

We have an instance of collector running on our servers and listening on port 55680, are there any environment variables that need to be set to transfer the traces over to the server?

arielvalentin commented 3 years ago

@contractormarketplace if I understand your need you are looking for an example of how to configure the SDK to export to open-telemetry-collector using OTLP. Is that correct?

contractormarketplace commented 3 years ago

@arielvalentin , yes that is correct.

Basically, we have a server in our intranet that runs the collector listening on port 55680. We are trying to send traces (not metrics) to the collector.

ahayworth commented 3 years ago
Traceback (most recent call last):
1: from trace_demonstration.rb:5:in <main>' trace_demonstration.rb:5:in require': cannot load such file -- httpclient (LoadError)

This error implies that your local ruby installation cannot find the httpclient gem; which you'll also need to install.

contractormarketplace commented 3 years ago

I did the following :- sudo gem install httpclient And then ran the application ruby trace_demonstration.rb But ran into the same error...

ahayworth commented 3 years ago

I believe using sudo may be putting things in your system-wide ruby installation; and so you may need to run the example script with sudo as well.

Since you said you're new to ruby, I think you may wish to consult some of the bundler documentation, and general how-tos on getting a working ruby environment. I would start here:

For now I'll close out this issue, since I think this is related to your overall ruby installation not working correctly and that's out of scope for this project. However, please re-open it if you find something specific that we can help out with for opentelemetry!