Giter Site home page Giter Site logo

cowboy_telemetry's Introduction

cowboy_telemetry

Hex.pm Version Erlang CI

Telemetry instrumentation for the Cowboy HTTP server.

This package contains a cowboy_stream handler that will instrument each request and emit telemetry events.

Usage

Configure your cowboy server with the cowboy_telemetry_h stream handler first.

cowboy:start_clear(http, [{port, Port}], #{
    env => #{dispatch => Dispatch},
    stream_handlers => [cowboy_telemetry_h, cowboy_stream_h]
}.

Telemetry Events

[cowboy, request, start]

A span event emitted at the beginning of a request.

  • measurements: #{system_time => erlang:system_time()}
  • metadata: #{stream_id => cowboy_stream:streamid(), req => cowboy_req:req()}

[cowboy, request, stop]

A span event emitted at the end of a request.

  • measurements: measurements()
  • metadata: metadata()

If the request is terminated early - by the client or by the server - before a response is sent, the metadata will also contain an error:

  • metadata: metadata() + #{error => cowboy_stream:reason()}

[cowboy, request, exception]

A span event emitted if the request process exits.

  • measurements: measurements()
  • metadata: metadata() + #{kind => exit, stacktrace => list()}

[cowboy, request, early_error]

A single event emitted when Cowboy itself returns an early_error response before executing any handlers.

  • measurements: #{system_time => erlang:system_time(), resp_body_length => non_neg_integer()}
  • metadata: metadata() without procs or informational

Types

  • measurements():
    • duration :: req_start - req_end see cowboy_metrics_h
    • req_body_duration :: req_body_start - req_body_end see cowboy_metrics_h
    • resp_duration :: resp_start - resp_end see cowboy_metrics_h
    • req_body_length :: non_neg_integer()
    • resp_body_length :: non_neg_integer()
  • metadata():
    • pid, streamid, req, resp_headers, resp_status, and ref from cowboy_metrics_h:metrics()
  • cowboy_metrics_h:metrics(): Defined in cowboy_metrics_h

Note:

  • The telemetry handlers are executed from the cowboy connection process, not from the request process.

cowboy_telemetry's People

Contributors

binaryseed avatar josevalim avatar starbelly avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.