Skip to content

Commit

Permalink
feat: add tracing configuration to services
Browse files Browse the repository at this point in the history
Add tracing configuration to all services by adding environment variables to the deployment files. The environment variables are used to configure the tracing settings for the services. The following environment variables were added to each service:
- HTTP_TRACE_TRACE_PARENT
- HTTP_TRACE_TRACE_STATE
- HTTP_TRACE_GRPC_TRACE_BIN
- GRPC_TRACE_TRACE_PARENT
- GRPC_TRACE_TRACE_STATE
- GRPC_TRACE_GRPC_TRACE_BIN

Also, change the app-protocol to grpc in the integration-grpc-service.yaml and remote.yaml files.

Add a launch.json file to the gateway service to enable debugging in VSCode.

In the grpc.go file, set the dapr-app-id header to "remote" to enable tracing.

Update the test.http file to include a test for the new /http endpoint and a test for the /grpc endpoint.
  • Loading branch information
shumkovdenis committed May 13, 2023
1 parent 0c2e51f commit 92bb1a9
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 29 deletions.
12 changes: 12 additions & 0 deletions deploy/services/gateway-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ spec:
value: "6000"
- name: INTEGRATION_APP_ID
value: "integration-grpc"
- name: HTTP_TRACE_TRACE_PARENT
value: "true"
- name: HTTP_TRACE_TRACE_STATE
value: "false"
- name: HTTP_TRACE_GRPC_TRACE_BIN
value: "false"
- name: GRPC_TRACE_TRACE_PARENT
value: "false"
- name: GRPC_TRACE_TRACE_STATE
value: "false"
- name: GRPC_TRACE_GRPC_TRACE_BIN
value: "false"
ports:
- containerPort: 6000
imagePullPolicy: Always
16 changes: 14 additions & 2 deletions deploy/services/integration-grpc-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "integration-grpc"
dapr.io/app-protocol: "http"
dapr.io/app-protocol: "grpc"
dapr.io/app-port: "6001"
dapr.io/enable-api-logging: "true"
dapr.io/config: "tracing"
Expand All @@ -29,7 +29,19 @@ spec:
- name: PORT
value: "6001"
- name: MODE
value: "http"
value: "grpc"
- name: HTTP_TRACE_TRACE_PARENT
value: "true"
- name: HTTP_TRACE_TRACE_STATE
value: "false"
- name: HTTP_TRACE_GRPC_TRACE_BIN
value: "false"
- name: GRPC_TRACE_TRACE_PARENT
value: "false"
- name: GRPC_TRACE_TRACE_STATE
value: "false"
- name: GRPC_TRACE_GRPC_TRACE_BIN
value: "false"
ports:
- containerPort: 6001
imagePullPolicy: Always
12 changes: 12 additions & 0 deletions deploy/services/integration-http-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ spec:
env:
- name: PORT
value: "7001"
- name: HTTP_TRACE_TRACE_PARENT
value: "true"
- name: HTTP_TRACE_TRACE_STATE
value: "false"
- name: HTTP_TRACE_GRPC_TRACE_BIN
value: "false"
- name: GRPC_TRACE_TRACE_PARENT
value: "false"
- name: GRPC_TRACE_TRACE_STATE
value: "false"
- name: GRPC_TRACE_GRPC_TRACE_BIN
value: "false"
ports:
- containerPort: 7001
imagePullPolicy: Always
16 changes: 14 additions & 2 deletions deploy/services/remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "remote"
dapr.io/app-protocol: "http"
dapr.io/app-protocol: "grpc"
dapr.io/app-port: "6003"
dapr.io/config: "tracing"
spec:
Expand All @@ -27,7 +27,19 @@ spec:
- name: PORT
value: "6003"
- name: MODE
value: "http"
value: "grpc"
- name: HTTP_TRACE_TRACE_PARENT
value: "true"
- name: HTTP_TRACE_TRACE_STATE
value: "false"
- name: HTTP_TRACE_GRPC_TRACE_BIN
value: "false"
- name: GRPC_TRACE_TRACE_PARENT
value: "false"
- name: GRPC_TRACE_TRACE_STATE
value: "false"
- name: GRPC_TRACE_GRPC_TRACE_BIN
value: "false"
ports:
- containerPort: 6003
imagePullPolicy: Always
15 changes: 15 additions & 0 deletions services/gateway/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
2 changes: 2 additions & 0 deletions services/integration/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func (s *GRPCServer) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.Hel

client := pb.NewGreeterClient(conn)

headersIn.Set("dapr-app-id", "remote")

ctx = metadata.NewOutgoingContext(context.Background(), headersIn)

headersOut, _ := metadata.FromOutgoingContext(ctx)
Expand Down
42 changes: 17 additions & 25 deletions test.http
Original file line number Diff line number Diff line change
@@ -1,58 +1,50 @@
@remote = https://denis.dev.releaseband.com
@remoteDapr = https://denis-dapred.dev.releaseband.com
@hostname = localhost
@contentType = application/json

###

# @name launch
POST /launch HTTP/1.1
Host: {{hostname}}:8080
Content-Type: {{contentType}}
Host: localhost:8080
Content-Type: application/json

{
"playerId": "player",
"gameId": "game"
}

###

@token = {{launch.response.body.token}}

# @name init
POST {{remote}}/init HTTP/1.1
# POST /init HTTP/1.1
# Host: {{hostname}}:8081
Content-Type: {{contentType}}
Content-Type: application/json

{
"token": "{{token}}"
}

###

# @name balance
POST /integration.v1.IntegrationService/GetBalance HTTP/1.1
Host: {{hostname}}:8081
Content-Type: {{contentType}}
Host: localhost:8080
Content-Type: application/json

{
"player_id": "123"
}

###

# @name dapr
POST /v1.0/invoke/gateway/method/init HTTP/1.1
Host: {{hostname}}:8282
Content-Type: {{contentType}}

{
"token": "{{token}}"
}
# @name http
POST {{remote}}/http HTTP/1.1
Content-Type: application/json

###
# @name grpc
POST {{remote}}/grpc HTTP/1.1
Content-Type: application/json

# @name gateway
POST {{remote}}/gateway HTTP/1.1
Content-Type: {{contentType}}
###
# @name test
POST /http HTTP/1.1
Host: localhost:6000
Content-Type: application/json
traceparent: 00-58f774820d1130301d91423693afc257-f8a45c3285e07fef-01

0 comments on commit 92bb1a9

Please sign in to comment.