GithubHelp home page GithubHelp logo

classicvalues / opencensus_honeycomb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codesandbox/opencensus_honeycomb

0.0 0.0 0.0 47 KB

Opencensus integration with Honeycomb

License: Apache License 2.0

Elixir 100.00%

opencensus_honeycomb's Introduction

Opencensus.Honeycomb

CircleCI Hex version badge

Posts OpenCensus spans to Honeycomb.

Installation

  • Take the dependency
  • Configure it
  • Check its all working

Dependency

Add opencensus_honeycomb to your deps in mix.exs:

{:opencensus_honeycomb, "~> 0.1"}

Then, mix deps.get and mix deps.compile as usual.

Configuration

In your config/config.exs, configure :opencensus and :opencensus_honeycomb:

config :opencensus,
  reporters: [{Opencensus.Honeycomb.Reporter, []}],
  send_interval_ms: 1000

config :opencensus_honeycomb,
  dataset: "opencensus",
  service_name: "your_app",
  write_key: System.get_env("HONEYCOMB_WRITEKEY")

Verification

iex -S mix, then:

iex> Application.get_env(:opencensus, :reporters)
[{Opencensus.Honeycomb.Reporter, []}]

iex> Application.get_all_env(:opencensus_honeycomb)
[write_key: "...", service_name: "...", dataset: "..."]

iex> :ocp.with_child_span("test")
:undefined

iex> :ocp.current_span_ctx()
{:span_ctx, 33234766236774033950150561980069751240,
 12010566695198730064, 1, :undefined}

iex> :ocp.finish_span()
true

If you don't notice any sending, check the registration in case the config format changed again. Register manually, then try again:

iex> :oc_reporter.register(Opencensus.Honeycomb.Reporter, [])
:ok

Once you've seen some spans, try a stack of ten:

iex> 1..10 |> Enum.map(&to_string/1) |> Enum.map(&:ocp.with_child_span/1)
[
  :undefined,
  {:span_ctx, 322560190005584483565962561333424343439,
   7924041616779114111, 1, :undefined},
   ...
  {:span_ctx, 322560190005584483565962561333424343439,
   14682319351797855820, 1, :undefined},
]

iex>  1..10 |> Enum.map(fn _ -> :ocp.finish_span() end)
[true, true, true, true, true, true, true, true, true, true]

Telemetry

Opencensus.Honeycomb calls :telemetry.execute/2 before and after sending. To get an idea without reading the in-code documentation, run the following at the iex -S mix prompt:

alias Opencensus.Honeycomb.{Config,Event,Sender}
Config.put(%{write_key: nil})
handle_event = fn n, measure, meta, _ -> IO.inspect({n, measure, meta}) end
:telemetry.attach_many("test", Sender.telemetry_events(), handle_event, nil)
[%Event{time: Event.now(), data: %{name: "hello"}}] |> Sender.send_batch()

You should see two events inspected:

{[:opencensus, :honeycomb, :start], %{count: 1},
 %{
   events: [
     # ...
   ]
 }}

{[:opencensus, :honeycomb, :stop, :success], %{count: 1, ms: 5.535},
 %{
   events: [
     # ...
   ],
   payload: "..."
 }}

Want to see that against the production API?

Config.put(%{
  write_key: System.get_env("HONEYCOMB_WRITEKEY"),
  dataset: "smoketest"
})
[%Event{time: Event.now(), data: %{name: "hello"}}] |> Sender.send_batch()

Development

Dependency management:

  • mix deps.get to get your dependencies
  • mix deps.compile to compile them
  • mix licenses to check their license declarations, recursively

Finding problems:

  • mix compile to compile your code
  • mix credo to suggest more idiomatic style for it
  • mix dialyzer to find problems static typing might spot... slowly
  • mix test to run unit tests
  • mix test.watch to run the tests again whenever you change something
  • mix coveralls to check test coverage

Documentation:

  • mix docs to generate documentation for this project
  • mix help to find out what else you can do with mix

opencensus_honeycomb's People

Contributors

bjornrud avatar derekkraan 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.