我有機會兩週前與 honeycomb.io 合作,主要是我正在更改發送資料的程式碼 appinsights azre 現在也需要將資料傳送到 honeycomb。雖然不太複雜,但是很難捕捉到這些
記錄行並確保我們是否正確調用端點以及發送了哪些資料。 appinsights 有一個很棒的插件 https://github.com/Socolin/ApplicationInsightsRiderPlugin 但沒有可以顯示 opentelemetry 呼叫的插件,是的 honeycomb.io 使用 OTEL 協定意味著 opentelemetry 現在是可觀察性的行業標準。
所以我需要學習如何查看 opentelemetry 調試日誌,這不容易配置,因為 opentelemetry API 要求你配置控制台導出器,它會在日誌中顯示一些數據,如下所示
Activity.TraceId: 39de3d235089b014c5e37abefdc3a7f8 Activity.SpanId: 03ae17902e901577 Activity.TraceFlags: Recorded Activity.ActivitySourceName: Microsoft.AspNetCore Activity.DisplayName: GET Hello Activity.Kind: Server Activity.StartTime: 2024-10-06T21:53:05.9553689Z Activity.Duration: 00:00:00.2187686 Activity.Tags: server.address: localhost server.port: 8080 http.request.method: GET url.scheme: http url.path: /Hello network.protocol.version: 1.1 user_agent.original: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0 http.route: Hello http.response.status_code: 200 Resource associated with Activity: service.name: my-service-name telemetry.sdk.name: opentelemetry telemetry.sdk.language: dotnet telemetry.sdk.version: 1.9.0
這需要更改為 json 以便我解析它並在騎手調試窗口中更好地顯示它,所以我編寫了這個新的導出器。
{"activity":{"traceId":"b49d03d8b55c2f8dfc9f385b3191fdee","spanId":"47c531f9a5a32dca","activityTraceFlags":"Recorded","parentSpanId":"0000000000000000","activitySourceName":"Microsoft.AspNetCore","activitySourceVersion":"","displayName":"GET Hello","kind":"Server","startTime":"2024-10-06T21:54:22.8551436Z","duration":"00:00:00.0013247","tags":{"server.address":"localhost","server.port":"8080","http.request.method":"GET","url.scheme":"http","url.path":"/Hello","network.protocol.version":"1.1","user_agent.original":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0","http.route":"Hello","http.response.status_code":"200"},"statusCode":"Unset","events":[],"links":[],"resource":{"service.name":"my-service-name","telemetry.sdk.name":"opentelemetry","telemetry.sdk.language":"dotnet","telemetry.sdk.version":"1.9.0"},"rootId":"b49d03d8b55c2f8dfc9f385b3191fdee","operationName":"Microsoft.AspNetCore.Hosting.HttpRequestIn"}}
現在我有了 json 偵錯日誌,我所需要的就是從 Socolin 的插件中刪除 appinsights 並解析 opentelemetry json 並將其顯示在偵錯視窗中。
在此處查看影片或螢幕截圖
以上是如何發布用於 opentelemetry/honeycomb 的 JetBrains Rider 插件的詳細內容。更多資訊請關注PHP中文網其他相關文章!