Digma Quick Start
Guide for GoLang

Get Digma up and running

  1. Install the Digma IDE plugin 

Start the Digma backend locally 

  1. Run the following from terminal/command line:

Linux & MacOS:

curl -L https://get.digma.ai/ --output docker-compose.yml

Windows (PowerShell):

iwr https://get.digma.ai/ -outfile docker-compose.yml
  1. Then run:
docker compose up -d

to start the Digma backend. (You’ll need Docker and Docker Compose installed)

Prefer to use a Helm file? Check out these instructions instead:

Set Up Tracing

Add Digma to your collector: 

Modify your collector configuration file to add Digma’s backend as a target. For example:

otlp/digma:
    endpoint: "localhost:5050"
    tls:
      insecure: true
service:
  pipelines:
    traces:
      exporters: [otlp/digma, ...]
  1. Connect Digma to your OTEL setup 

Install the Digma OpenTelemetry module:

go get -u github.com/digma-ai/otel-go-instrumentation@v1.0.10

Create and merge the OTEL resource with your resource:

import (
    "github.com/digma-ai/otel-go-instrumentation/detector"
)

res, err := resource.New(ctx,
    resource.WithAttributes(
// the service name used to display traces in backends and mandatory for digma backend
    semconv.ServiceNameKey.String(serviceName),
        ),

        resource.WithDetectors(
            &detector.DigmaDetector{
                        DigmaEnvironment:     “” //optional
                CommitId:              "", //optional
            },
        ))

Finally, connect your code to Digma!

Add one or two lines of code to instrument Digma.

Jump to: MUX, Echo, GRPC

Get More Out of Digma

To find out about adding environments, commit information, and other configuration options, check out the Digma instrumentation page.

New to observability? OpenTelemetry has extensive documentation explaining how to get started. [ Get started with OpenTelemetry ]

GoLang Quick Start Guide - separator

Adding Digma to your OTEL Instrumentation

GoLang / MUX

  1. Install the Digma OTEL instrumentation packages as well as the Mux instrumentation packages if you haven’t done so already:
go get -u github.com/digma-ai/otel-go-instrumentation/mux
  1. Add the Digma Mux middleware immediately following the OTEL one:
import (
    digmamux "github.com/digma-ai/otel-go-instrumentation/mux"
    "github.com/gorilla/mux"
    "go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
)

func main() {
    router := mux.NewRouter().StrictSlash(true)
    router.Use(otelmux.Middleware(appName))
    router.Use(digmamux.Middleware(router))
}

You’re good to go! Check out our sample MUX project for reference.

GoLang / Echo

  1. Install the Digma Echo instrumentation package:
go get -u github.com/digma-ai/otel-go-instrumentation/echo
  1. Add the Digma Echo middleware immediately following the OTEL one. For example:
import (
    digmaecho "github.com/digma-ai/otel-go-instrumentation/echo"
    "go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho"
)


func main() {
    r := echo.New()
    r.Use(otelecho.Middleware(appName))
    r.Use(digmaecho.Middleware())
    r.GET("/", index)
}

You’re good to go! Check out our sample Echo project for reference.

GoLang / GRPC

  1. Install the Digma GRPC instrumentation package.
go get -u github.com/digma-ai/otel-go-instrumentation/grpc
  1. Add the Digma instrumentation packages:
import (
    "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
    grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
    digmagrpc "github.com/digma-ai/otel-go-instrumentation/grpc"
)


func main() {
    server := grpc.NewServer(
        grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
            otelgrpc.UnaryServerInterceptor(),
            digmagrpc.UnaryServerInterceptor(),
        )),
        grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
            otelgrpc.StreamServerInterceptor(),
            digmagrpc.StreamServerInterceptor(),
        )),
    )
}

You’re good to go! Check out our sample GRPC project for reference.