jlewi / foyle

Foyle is a copilot to help developers deploy and operate their applications.
https://foyle.io
Apache License 2.0
108 stars 9 forks source link

OTEL traces use "contextID" and "contextId" #246

Open jlewi opened 2 months ago

jlewi commented 2 months ago

We are using "contextID" and "contextId" as attributes on the spans. We need to pick a preferred form and stick to it. We should document it in a style guide.

jlewi commented 2 months ago

Claude says "contextId" https://stackoverflow.com/questions/779929/id-id-or-id

In proto -> GoLang "context_id" becomes "contextId" https://github.com/jlewi/foyle/blob/5f30c461b1f178474d23e08a5bca073ca93724f8/protos/foyle/logs/sessions.proto#L16

Which also means the JSON serialization is contextId

{
  "insertId": "1vqy98uf1w00ei",
  "jsonPayload": {
    "severity": "info",
    "message": "Anthropic:CreateMessages",
    "function": "github.com/jlewi/foyle/app/pkg/anthropic.(*Completer).Complete",
    "traceId": "dd7e1d3650987812ec3bf8a7accc3a51",
    "streamTraceId": "1c73737a0ab5311452d572072bc72df3",
    "time": 1726632316.254349,
    "evalMode": false,
    "request": {
      ...
     },
    "contextId": "01J81MWH3DVVCW9ZMV564ED325",
    "caller": "anthropic/completer.go:68"
  },
  "resource": {
    "type": "project",
    "labels": {
      "project_id": "foyle-dev"
    }
  },
}

But seems like this contradicts GoStyle and linter https://www.reddit.com/r/golang/comments/168r2fc/id_or_id/ https://google.github.io/styleguide/go/decisions#initialisms