Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Migrate reporters to gen_event #136

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

hauleth
Copy link
Contributor

@hauleth hauleth commented Feb 10, 2019

Close #133
Close #110

src/oc_reporter_stdout.erl Outdated Show resolved Hide resolved
src/oc_trace_sup.erl Outdated Show resolved Hide resolved
@@ -0,0 +1,38 @@
-module(oc_internal_timer).

-callback ping() -> ok.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name isn't perfect, any suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using mfa() instead of callback module?

@tsloughter
Copy link
Member

I don't see what this adds. It seems more complex but without gain, removing/replacing reporters can be done just as easily in the existing code.

I also don't see reporting as events. Allowing multiple reportes is fine because of Erlang terms simple lists and list handling, but thinking of them as event handlers feels like going down the wrong path and giving the wrong impression to users.

Even though I wouldn't want to use it, preferring to do this off the node being traced, I can see benefits from a sort of pipeline to pass spans through, but it should be separate from a reporter which is just wanting to get spans out of the system.

I'll have to take a closer look later but that is my initial thoughts.

@hauleth
Copy link
Contributor Author

hauleth commented Feb 11, 2019

I understand nomenclatural difference, but my point is that currently we are duplicating work that already has been done. I can extract this to separate library though that will provide gen_sink if you prefer it. Will that be ok?

@tsloughter
Copy link
Member

gen_sink?

@hauleth
Copy link
Contributor Author

hauleth commented Feb 11, 2019 via email

@tsloughter
Copy link
Member

Right, I don't think we are duplicating work because ours is simply a function call on an interval. It shouldn't even really be a list, but it didn't really add any complexity to have it be one instead of separate sequence module for the rare case of wanting a sequence of reporters.

@hauleth
Copy link
Contributor Author

hauleth commented Feb 11, 2019

List and fact that we allow to dynamically add and remove reporters makes testing so much easier. Additionally it makes configuring reporter in runtime possible as you can do in your application setup:

oc_traces:add_handler(oc_datadog_reporter, [{api_key, os:getenv("DD_TOKEN")}])

And call it a day, with "old way" it is a little bit harder.

@hauleth
Copy link
Contributor Author

hauleth commented Feb 11, 2019

@tsloughter additional advantage is that it will provide uniform interface for configuring reporters of metrics and traces. Just this thing is worth of fixes.

And TBH I think that in the end it will make the code simpler, as almost the same modules can be reused for the metrics.

@codecov-io
Copy link

Codecov Report

Merging #136 into master will increase coverage by 1.82%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #136      +/-   ##
==========================================
+ Coverage   79.91%   81.74%   +1.82%     
==========================================
  Files          34       36       +2     
  Lines         722      701      -21     
==========================================
- Hits          577      573       -4     
+ Misses        145      128      -17
Impacted Files Coverage Δ
oc_stat_config.erl 0% <0%> (-75%) ⬇️
oc_stat.erl 75.86% <0%> (-8.76%) ⬇️
oc_trace.erl 96.92% <0%> (-3.08%) ⬇️
oc_reporter_stdout.erl 0% <0%> (ø) ⬆️
oc_span.erl 100% <0%> (ø) ⬆️
opencensus_sup.erl 100% <0%> (ø) ⬆️
oc_server.erl
oc_reporter.erl
oc_stat_exporter.erl
oc_stat_sup.erl 100% <0%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b73a12f...1d985bb. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Feb 11, 2019

Codecov Report

Merging #136 into master will increase coverage by 1.88%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #136      +/-   ##
==========================================
+ Coverage   79.97%   81.85%   +1.88%     
==========================================
  Files          37       35       -2     
  Lines         814      700     -114     
==========================================
- Hits          651      573      -78     
+ Misses        163      127      -36
Impacted Files Coverage Δ
oc_stat.erl 75.86% <0%> (-8.76%) ⬇️
oc_trace.erl 96.92% <0%> (-3.08%) ⬇️
oc_span_sweeper.erl 72.09% <0%> (ø) ⬆️
opencensus.erl 21.42% <0%> (ø) ⬆️
oc_span.erl 100% <0%> (ø) ⬆️
opencensus_sup.erl 100% <0%> (ø) ⬆️
oc_tracestate.erl
oc_stat_exporter.erl
oc_reporter_stdout.erl
oc_server.erl
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 37d708e...67221ee. Read the comment docs.

test/oc_tab_reporter.erl Outdated Show resolved Hide resolved
@hauleth hauleth changed the title WIP: Migrate reporters to gen_event Migrate reporters to gen_event Feb 11, 2019
Copy link
Member

@deadtrickster deadtrickster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's needed :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use gen_event for metrics and traces sending
5 participants