Welcome to the Linux Foundation Forum!

KeyError in "Instruments to Measure Golden Signals" code

You'll get a KeyError when trying to access http.server.request.duration in request_instruments.

https://trainingportal.linuxfoundation.org/learn/course/getting-started-with-opentelemetry-lfs148/hands-on-lab-manual-instrumentation-metrics/instruments-to-measure-golden-signals?page=5

Change:

  1. request_instruments["http.server.request.duration"].record(
  2. duration,
  3. attributes = {
  4. "http.request.method": request.method,
  5. "http.route": request.path,
  6. "http.response.status_code": response.status_code
  7. }
  8. )

to:

  1. request_instruments["request_latency"].record(
  2. duration,
  3. attributes = {
  4. "http.request.method": request.method,
  5. "http.route": request.path,
  6. "http.response.status_code": response.status_code
  7. }
  8. )

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training