Skip to content

Commit ea61b96

Browse files
committed
add otel instance id
1 parent 4c8ad5d commit ea61b96

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

packages/api/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func run() int {
162162
flag.Parse()
163163

164164
if !env.IsLocal() {
165-
otlpCleanup := telemetry.InitOTLPExporter(ctx, serviceName, commitSHA)
165+
otlpCleanup := telemetry.InitOTLPExporter(ctx, serviceName, commitSHA, "no")
166166
defer otlpCleanup(ctx)
167167
}
168168

packages/client-proxy/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func run() int {
148148
signalCtx, sigCancel := signal.NotifyContext(ctx, syscall.SIGTERM, syscall.SIGINT)
149149
defer sigCancel()
150150

151-
stopOtlp := telemetry.InitOTLPExporter(ctx, ServiceName, commitSHA)
151+
stopOtlp := telemetry.InitOTLPExporter(ctx, ServiceName, commitSHA, "no")
152152
defer func() {
153153
err := stopOtlp(ctx)
154154
if err != nil {

packages/orchestrator/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ func main() {
5050
// there's a panic.
5151
defer wg.Wait()
5252

53+
clientID := consul.GetClientID()
54+
5355
if !env.IsLocal() {
54-
shutdown := telemetry.InitOTLPExporter(ctx, server.ServiceName, "no")
56+
shutdown := telemetry.InitOTLPExporter(ctx, server.ServiceName, commitSHA, clientID)
5557
wg.Add(1)
5658
go func() {
5759
defer wg.Done()
@@ -96,8 +98,6 @@ func main() {
9698

9799
log.Println("Starting orchestrator", "commit", commitSHA)
98100

99-
clientID := consul.GetClientID()
100-
101101
srv, err := server.New(ctx, port, clientID, commitSHA)
102102
if err != nil {
103103
zap.L().Fatal("failed to create server", zap.Error(err))

packages/shared/pkg/telemetry/otel.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ type client struct {
3737
}
3838

3939
// InitOTLPExporter initializes an OTLP exporter, and configures the corresponding trace providers.
40-
func InitOTLPExporter(ctx context.Context, serviceName, serviceVersion string) func(ctx context.Context) error {
40+
func InitOTLPExporter(ctx context.Context, serviceName, serviceVersion string, instanceID string) func(ctx context.Context) error {
4141
attributes := []attribute.KeyValue{
4242
semconv.ServiceName(serviceName),
4343
semconv.ServiceVersion(serviceVersion),
44+
semconv.ServiceInstanceID(instanceID),
4445
semconv.TelemetrySDKName("otel"),
4546
semconv.TelemetrySDKLanguageGo,
4647
}

packages/template-manager/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func main() {
4949
}
5050

5151
if !env.IsLocal() {
52-
shutdown := telemetry.InitOTLPExporter(ctx, constants.ServiceName, "no")
52+
shutdown := telemetry.InitOTLPExporter(ctx, constants.ServiceName, "no", "no")
5353
defer shutdown(context.TODO())
5454
}
5555

0 commit comments

Comments
 (0)