GCP StackDriver: 정보 로그를 추적 로그와 상호 연결(및 중첩)하려면 어떻게 해야 하나요?

GCP StackDriver: 정보 로그를 추적 로그와 상호 연결(및 중첩)하려면 어떻게 해야 하나요?

도와주세요. 3일 동안 실패했습니다.

저는 Google Cloud Run에 몇 가지 서비스를 배포하고 있으며, 요청이 서비스를 통과할 때 요청을 추적하고 해당 요청과 로그를 연관시키고 싶습니다. StackDriver의 "StackDriver Trace"에는 이를 위한 훌륭한 플랫폼이 있습니다. 내 asp.net 핵심 웹 API에서 Google.Cloud.Diagnostics 라이브러리를 사용하고 있습니다. 요청을 성공적으로 추적하고 범위를 시작할 수 있으며 StackDriver Trace Timeline에서 추적 내부에 중첩된 범위를 볼 수 있습니다. 그러나 내 로그를 추적 및 범위와 연관시키려면 어떻게 해야 할지 난감합니다.

StackDriver 문서에는 LogEntry객체에 "특수 필드"를 쓰는 것이 Logging API에 의해 인식된다고 명시되어 있습니다.

이 분야 에 대해 구체적으로 다음과 같이 말합니다 trace.

The value of this field should be formatted as projects/[PROJECT-ID]/traces/[TRACE-ID], so it can be used by the Logs Viewer and the Trace Viewer to group log entries and display them in line with traces. 

원천:https://cloud.google.com/logging/docs/agent/configuration#special-fields

구조화된 JSON에 대해 다양한 작업을 시도했지만 Stackdriver Trace View가 내 로그를 인식하지 못하고 요청 추적 내에 중첩하지 않습니다. 현재 JSON에 추적과 범위 ID를 모두 포함하고 있습니다.

StackDriver Trace가 추적에 중첩되지 않는 로그 중 하나는 다음과 같습니다.

{
 insertId: "5da6c3a200j0923bx23x2"  
 jsonPayload: {
  ConnectionId: "0HLQI121N94JM"   
  CorrelationId: null   
  RequestId: "0HLQI121N94JM:00000001"   
  RequestPath: "/graphql"   
  message: "Getting Collection of type: FakeItem in GetCollectionOfItemsAsync"   
  messageTemplate: "Getting Collection of type: FakeItem in GetCollectionOfItemsAsync"   
  spanId: "4560986706170855936"   
  timestamp: "2019-10-16T07:15:46.8713740Z"   
  trace: "projects/myProject/traces/04b4a840df0289bb9fddcd62235d3ee4"   
 }
 labels: {
  instanceId: "00bf4bf02d34e072dc1c49x8dj943x4b5609mubm0409u566ad08acf6283d2b5135651fd8f2633e7b06e7dde4b96cfddbf5373a642da0b65fb21cf87a5aad"   
 }
 logName: "projects/myProject/logs/run.googleapis.com%2Fstdout"  
 receiveTimestamp: "2019-10-16T07:15:47.113845061Z"  
 resource: {
  labels: {
   configuration_name: "baseproject-graphql"    
   location: "us-central1"    
   project_id: "myProject"    
   revision_name: "baseproject-graphql-vhglp"    
   service_name: "baseproject-graphql"    
  }
  type: "cloud_run_revision"   
 }
 timestamp: "2019-10-16T07:15:46.871489Z"  
}

다음은 인식되는 gcp에 의해 생성된 로그입니다.

{
 httpRequest: {
  latency: "0.026068056s"   
  protocol: "HTTP/1.1"   
  remoteIp: "73.158.189.48"   
  requestMethod: "POST"   
  requestSize: "1950"   
  requestUrl: "https://baseproject-api.myUrl.com/graphql"   
  responseSize: "2768"   
  serverIp: "152.289.4.125"   
  status: 200   
  userAgent: "PostmanRuntime/7.18.0"   
 }
 insertId: "5da6c3a8j90kjo9db8346"  
 labels: {
  instanceId: "00bf4bf02d34e072dc1cfda1073f2f5ec6888d75e1d75f26259006ad08acf6283d2b5135651fd8f26398n9hu0h9h09gm08g76f67f567fb21cf87a5aad"   
 }
 logName: "projects/myProject/logs/run.googleapis.com%2Frequests"  
 receiveTimestamp: "2019-10-16T07:15:47.207098181Z"  
 resource: {
  labels: {
   configuration_name: "baseproject-graphql"    
   location: "us-central1"    
   project_id: "myProject"    
   revision_name: "baseproject-graphql-vhglp"    
   service_name: "baseproject-graphql"    
  }
  type: "cloud_run_revision"   
 }
 severity: "INFO"  
 timestamp: "2019-10-16T07:15:46.877387Z"  
 trace: "projects/myProject/traces/04b4a840df0289bb9fddcd62235d3ee4"  
}

이견있는 사람???

관련 정보