Skip to content

Instantly share code, notes, and snippets.

@StevenACoffman
Last active June 5, 2025 01:27
Show Gist options
  • Save StevenACoffman/78e73148f507c1441acefa2ca3ad5b8f to your computer and use it in GitHub Desktop.
Save StevenACoffman/78e73148f507c1441acefa2ca3ad5b8f to your computer and use it in GitHub Desktop.
Wide Events and Cannonical Log Lines for Go

https://thefridaydeploy.substack.com/p/less-is-more-with-opentelemetry-spans?r=36rml&triedRedirect=true

https://github.com/GoogleCloudPlatform/kubernetes-engine-samples/blob/main/observability/distributed-tracing/main.go

https://github.com/GoogleCloudPlatform/opentelemetry-demo/blob/main/kubernetes/opentelemetry-demo.yaml

https://github.com/mterhar/otel-go-batch ( https://www.honeycomb.io/blog/exotic-trace-shapes )

https://blog.bitdrift.io/post/observability-3-0

https://jeremymorrell.dev/blog/a-practitioners-guide-to-wide-events/

All events can be represented as structured logs, but not all structured logs are events. An event contains information about what it took for a service to perform a "unit of work". Treating an event as a "unit of work" lets you adjust what it means depending on the goals of the observer. An event is a conceptual abstraction and a structured log is one possible representation of that abstraction. I like the idea of a "Arbitrarily wide structured events" / "canonical log line" collecting all possibly relevant key-values like a lint roller collects dust. Putting all the important telemetry data in a single log line makes it easy for everyone to query for answers, without the need for complex joins or manual piecing of things together with request IDs, especially during production outages. Arbitrarily wide structured events that describe the request and its context, one event per request per service

  • https://www.honeycomb.io/blog/structured-events-basis-observability

  • An event is a conceptual abstraction and a structured log is one possible representation of that abstraction. The interesting part of the conversation is where to draw the lines around that abstraction; the technical implementation part is how to represent that event.

  • Explicit propagation requires explicitly passing the active context from function to function as an argument (Go).

For distributed context propagation, OpenTelemetry supports several protocols that define how to serialize and pass context data:

canonical_log_line http_method=GET http_path=/v1/clusters duration=0.050 db_duration=0.045 db_num_queries=3 user=usr_123 status=200

https://signoz.io/guides/zap-logger/

https://github.com/GoogleCloudPlatform/microservices-demo

https://github.com/uptrace/opentelemetry-go-extra/tree/main/otelzap

Logging systems can’t afford to store data about every transaction anymore because the cost of those transactional logs is proportional to the number of microservices touched by an average transaction. Not to mention that the logs themselves are less useful (independent of cost) due to the analytical need to understand concurrency and causality in microservice transactions. So conventional logging isn’t sufficient in our brave new architectural world.

https://web.archive.org/web/20190213162559/https://lightstep.com/blog/three-pillars-zero-answers-towards-new-scorecard-observability/

https://github.com/mreider/sushi0/blob/ec2bdd964ef7aba133bf6a39c5ae05f28cf2a3f7/.github/workflows/deploy-things.yml#L23

    - name: End Docker Buildx
      run: |
        time_end=$(date +%Y-%m-%dT%H:%M:%S.%NZ)
        if [ "$GITHUB_EVENT_NAME" = "repository_dispatch" ]; then
          otel-cli span create \
          --endpoint=${{ secrets.DYNATRACE_ENDPOINT }}/api/v2/otlp/v1/traces \
          --otlp-headers="Authorization=Api-Token ${{ secrets.DYNATRACE_TOKEN}}" \
          --service=workflow \
          --name="Docker Build" \
          --force-parent-span-id=${{ env.parent_span_id }} \
          --start=${{ env.docker_time_start }}  \
          --end=$time_end \
          --kind=internal \
          --force-trace-id=${{ env.trace_id }} \
          --status-code="ok" \
          --status-description="Docker Built Successfully" \
          --verbose
        fi
        echo "deploy_time_start=$(date +%Y-%m-%dT%H:%M:%S.%NZ)" >> $GITHUB_ENV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment