Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial trace module #1

Merged
merged 5 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
26 changes: 20 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/_build
/cover
/deps
/doc
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez
*.beam
/config/*.secret.exs

# Ignore package tarball (built via "mix hex.build").
opencensus-*.tar
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# opencensus_elixir
# Opencensus

## Installation

```elixir
def deps do
[
{:opencensus_elixir, "~> 0.1.0"}
]
end
```

30 changes: 30 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the parent project. For this reason,
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.

# You can configure your application as:
#
# config :opencensus, key: :value
#
# and access this configuration in your application as:
#
# Application.get_env(:opencensus, :key)
#
# You can also configure a 3rd-party app:
#
# config :logger, level: :info
#

# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env()}.exs"
2 changes: 2 additions & 0 deletions lib/opencensus.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
defmodule Opencensus do
end
27 changes: 27 additions & 0 deletions lib/opencensus/trace.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
defmodule Opencensus.Trace do
@doc "Wraps the given block in a tracing child span with the given label/name"
defmacro with_child_span(label, do: block) do
hauleth marked this conversation as resolved.
Show resolved Hide resolved
quote do
:ocp.with_child_span(unquote(label), %{})

try do
unquote(block)
after
:ocp.finish_span()
hauleth marked this conversation as resolved.
Show resolved Hide resolved
end
end
end

@doc "Wraps the given block in a tracing child span with the given label/name and additional attributes"
defmacro with_child_span(label, attributes, do: block) do
hauleth marked this conversation as resolved.
Show resolved Hide resolved
quote do
:ocp.with_child_span(unquote(label), unquote(attributes))

try do
unquote(block)
after
:ocp.finish_span()
end
end
end
end
27 changes: 27 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
defmodule OpencensusElixir.MixProject do
use Mix.Project

def project do
[
app: :opencensus_elixir,
version: "0.1.0",
elixir: "~> 1.7",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:opencensus, "~> 0.7.0"}
]
end
end
8 changes: 8 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%{
"counters": {:hex, :counters, "0.2.1", "aa3d97e88f92573488987193d0f48efce0f3b2cd1443bf4ee760bc7f99322f0c", [:mix, :rebar3], [], "hexpm"},
"ctx": {:hex, :ctx, "0.5.0", "78e0f16712e12d707a7f34277381b8e193d7c71eaa24d37330dc02477c09eda5", [:rebar3], [], "hexpm"},
"jsx": {:hex, :jsx, "2.9.0", "d2f6e5f069c00266cad52fb15d87c428579ea4d7d73a33669e12679e203329dd", [:mix, :rebar3], [], "hexpm"},
"opencensus": {:hex, :opencensus, "0.7.0", "b4c5f6a96f2ba2154570f24bb08b65d6ee0ff5b61518acf706ca760b7696a4e1", [:rebar3], [{:counters, "~> 0.2", [hex: :counters, repo: "hexpm", optional: false]}, {:ctx, "~> 0.5", [hex: :ctx, repo: "hexpm", optional: false]}, {:jsx, "~> 2.9", [hex: :jsx, repo: "hexpm", optional: false]}, {:wts, "~> 0.3", [hex: :wts, repo: "hexpm", optional: false]}], "hexpm"},
"rfc3339": {:hex, :rfc3339, "0.9.0", "2075653dc9407541c84b1e15f8bda2abe95fb17c9694025e079583f2d19c1060", [:mix, :rebar], [], "hexpm"},
"wts": {:hex, :wts, "0.3.0", "5cdf22c775cb1ebae24c326a5db6074d753c42f4bd12a9aa47cc62d3e2c71ad1", [:rebar3], [{:rfc3339, "~>0.9.0", [hex: :rfc3339, repo: "hexpm", optional: false]}], "hexpm"},
}
8 changes: 8 additions & 0 deletions test/opencensus_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule OpencensusTest do
use ExUnit.Case
doctest Opencensus

test "do some span or something" do
assert true
end
end
1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExUnit.start()