Skip to content

Commit

Permalink
Merge pull request #10 from prashant-shahi/chore/update-insecure
Browse files Browse the repository at this point in the history
chore: update insecure env comparison logic and update docs
  • Loading branch information
makeavish authored Aug 25, 2023
2 parents 7178c0b + ac4d4c8 commit 1248752
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,36 @@ to download the required packages and populate the go.sum file.


## To run and configure app to send data to SigNoz:

For SigNoz Cloud:

```bash
SERVICE_NAME=goApp INSECURE_MODE=false OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token=<SIGNOZ-INGESTION-TOKEN> OTEL_EXPORTER_OTLP_ENDPOINT=ingest.{region}.signoz.cloud:443 go run main.go
```

- Update `<SIGNOZ-INGESTION-TOKEN>` with the ingestion token provided by SigNoz
- Update `ingest.{region}.signoz.cloud:443` with the ingestion endpoint of your region. Refer to the table below for the same.

| Region | Endpoint |
| ------ | -------------------------- |
| US | ingest.us.signoz.cloud:443 |
| IN | ingest.in.signoz.cloud:443 |
| EU | ingest.eu.signoz.cloud:443 |

For SigNoz OSS:

```
SERVICE_NAME=goApp INSECURE_MODE=true OTEL_EXPORTER_OTLP_ENDPOINT=<IP of SigNoz backend>:4317 go run main.go
```
*<IP of SigNoz backend:4317> should be without http/https scheme. Eg localhost:4317*

- `<IP of SigNoz backend:4317>` should be without http/https scheme. Eg `localhost:4317`.

---

This runs the gin application at port `8090`. Try accessing API at `http://localhost:8090/books`

Below are the apis available to play around. The API calls will generate telemetry data which will be sent to SigNoz which can be viewed at `<IP of SigNoz backend>:3000`

```
GET /books
GET /books/:id
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"log"
"os"
"strings"

"github.com/SigNoz/sample-golang-app/controllers"
"github.com/SigNoz/sample-golang-app/metrics"
Expand All @@ -29,8 +30,11 @@ var (

func initTracer() func(context.Context) error {

secureOption := otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
if len(insecure) > 0 {
var secureOption otlptracegrpc.Option

if strings.ToLower(insecure) == "true" || insecure == "1" || strings.ToLower(insecure) == "t" {
secureOption = otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
} else {
secureOption = otlptracegrpc.WithInsecure()
}

Expand Down

0 comments on commit 1248752

Please sign in to comment.