Documentation forSolarWinds Observability

Add a Go service

SolarWinds Observability documentation for the early access program - The following content includes descriptions of features that are part of an early access program. The features are available only to customers registered in the early access program. All feature functionality is subject to change when the feature is deployed to all customers. Contact SolarWinds using the in-product feedback button or email SWO-support@solarwinds.com if you would like to be added to the early access program.

The Go Library provides tracing and metrics for Go-based applications via wrappers and SDK calls that your application can use to instrument web requests and other workloads. For more details about the early access version of the Go library, see the SolarWinds APM Go GitHub repo.

Get started

Before you start

Verify the following to ensure the library can collect and transmit data:

  • The platform where your APM library will be installed is supported.

  • Your firewall configuration permits TCP/HTTPS/TLS outbound connections to apm.collector.xx-yy.cloud.solarwinds.com (where xx-yy is determined by the URL you use to access SolarWinds Observability, described in Data centers and endpoint URIs) using port 443. See Firewall or access control requirements.

    If your firewall or access control requirements do not allow such connections, configure the library to send data through a proxy.

Remove other APM libraries from your Go application before using the SolarWinds Observability Go Library.

To enable instrumentation for a Go application and send the data to SolarWinds Observability:

  1. In SolarWinds Observability, click Add Data at the top.

  2. In the Add Data dialog, click Services.

  3. Type a Name for your service and select the Golang (Linux) - Early Access language.

  4. Create or select an API Ingestion token to use when sending your collected service data by doing either of the following:

    • Select Generate New Token and enter an Ingestion Token Name, and then click Next.
    • Select Use Existing Token and select an ingestion token from the list, and then click Next.
  5. Use the following command to install the Go Library in your project.

    go get github.com/solarwinds/apm-go
  6. Initialize the library for monitoring. This is most often done in the main function of your project.

    // Initialize the SolarWinds APM library
    cb, err := swo.Start(
    	// Optionally add service-level resource attributes 
    	semconv.ServiceName("my-service"),
    	semconv.ServiceVersion("v0.0.1"),
    	attribute.String("environment", "testing"),
    )
    if err != nil {
    	// Handle error
    }
    // This function returned from `Start()` will tell the apm library to
    // shut down, often deferred until the end of `main()`.
    defer cb()
  7. Instrument the code using an instrumentation library. Libraries supported by SolarWinds include:

    For even more instrumentation options, OpenTelemetry provides a registry to find libraries, plugins, integrations, and other useful tools for extending OpenTelemetry.

    Each library is at a different maturity level, as the OpenTelemetry landscape is developing at a rapid pace.

    Alternatively, you can manually instrument your code using the OpenTelemetry SDK and it will be properly propagated to SolarWinds Observability. See Manual Instrumentation in the OpenTelemetry Go documentation.

  8. Configure environment variables that define the Service key and APM collector endpoint for your service and organization. Use the code provided under Configure in the Add Data dialog or manually create the following environment variables:

    • SW_APM_SERVICE_KEY — The Service key is used to identify your account and the service being instrumented. It should be in the form ofYourApiToken:YourServiceName.

      Replace YourApiToken with the SolarWinds Observability API token (ingestion type) generated for this service, and replace YourServiceName with your chosen name for this service. See API Tokens.

    • SW_APM_COLLECTOR — The collector is the ingestion endpoint the library connects to and exports data to. It should be defined using the format host:port. , and typically is in the format apm.collector.xx-yy.cloud.solarwinds.com, where xx-yy represents the data center that is hosting your organization's data.

      To determine the endpoint for your organization, see Data centers and endpoint URIs. The port is optional and defaults to 443.

  9. Wait for the Go Library to successfully connect to the SolarWinds APM collector and for the Waiting for Connection button in SolarWinds Observability to change to OK. It may take several requests for traces to show up.

  10. Click OK to finish setting up the service.

    To view data collected for the newly configured entity in the Entity Explorer, click the name of the entity type in the confirmation dialog in the lower-left corner. It may take a few seconds for data to appear for the newly created entity. See Entity Explorer for details.

    For transaction and trace data to appear in the Entity Explorer and Traces Explorer, your service must be running and in use.