Skip to content

Commit

Permalink
propagate host name config to Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Apr 19, 2024
1 parent d3a28f1 commit 1459437
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## v0.17.5

## v0.17.4

- Cache no candidate or ranked routes
Expand Down
9 changes: 6 additions & 3 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
func main() {
configPath := flag.String("config", "config.json", "config file location")

hostName := flag.String("host", "sqs", "the name of the host")

isDebug := flag.Bool("debug", false, "debug mode")
if *isDebug {
log.Println("Service RUN on DEBUG mode")
Expand Down Expand Up @@ -94,6 +96,7 @@ func main() {
)

err = sentry.Init(sentry.ClientOptions{
ServerName: *hostName,
Dsn: otelConfig.DSN,
SampleRate: otelConfig.SampleRate,
EnableTracing: otelConfig.EnableTracing,
Expand All @@ -109,7 +112,7 @@ func main() {

sentry.CaptureMessage("SQS started")

initOTELTracer()
initOTELTracer(*hostName)
}

chainClient, err := client.NewClient(config.ChainID, config.ChainGRPCGatewayEndpoint)
Expand Down Expand Up @@ -158,15 +161,15 @@ func main() {

// initOTELTracer initializes the OTEL tracer
// and wires it up with the Sentry exporter.
func initOTELTracer() {
func initOTELTracer(hostName string) {
exporter, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
if err != nil {
log.Fatalf("stdouttrace.New: %v", err)
}

resource, err := resource.New(context.Background(),
resource.WithAttributes(
semconv.ServiceNameKey.String("sqs"),
semconv.ServiceNameKey.String(hostName),
),
)
if err != nil {
Expand Down

0 comments on commit 1459437

Please sign in to comment.