In this video, I will be setting up OpenTelemetry so that it can be used to ingest data into the FusionReactor Cloud. This is a simple procedure that will only take a few minutes, and in doing so, give you additional insight into your product and the metrics it produces so you can quickly investigate and pinpoint issues.
In my demonstration, I am using Docker and a simple Go app based on the OpenTelemetry Go GitHub project available from [ Ссылка ]. Scraped metrics and traces will be available in both explore and the Integrations dashboards within the Fusion Reactor Cloud.
To configure my app to send telemetry data, I will need a function to initialize OpenTelemetry. I've added the following code in my main.go file under Import to add the required dependencies for my project. I've also added a variable to define my Otel Collector endpoint. Since I'm using Docker containers, note the address here uses the docker container name of my Otel Collector, instead of localhost.
I will now add two functions to my project: One to set up metrics, the other to set up traces. To break this down; here I create a new exporter. That exporter will be sending my trace or metric data to my collector listening on my endpoint that I previously defined as otelcollector on port 4318.
For demonstration purposes I am using no security here, however, it is recommended to use something like mutual TLS.
Next, I create a provider. A provider creates more information about what has happened for a given operation, such as a specific metric or trace.
Finally for tracing, I set the propagator here.Propagation is the mechanism by which a trace can be disseminated and communicated from one service to another across transport boundaries.
Under the Main function, I aad the following to initialize the metric and trace exporters. The attributes here are just example key-value descriptors that you can manually set for your trace.
So my main function here calls the setup functions, then creates a trace that runs for 30 seconds, along with a counter metric that increments each second.
Now we can create the docker containers, In your Go project's directory, create the docker file with the following code. This creates the Go docker image, sets the traces and metrics endpoint for Otel to point to our collector Docker container, and tells this image to start our go file.
Ещё видео!