Skip to content

Commit

Permalink
Merge API and SDK (#99)
Browse files Browse the repository at this point in the history
* Initial commit

* api initial commit

ot_tracer: behavour that an otel tracer must implement
ot_span: behaviour an otel span must implement
otel: friendly user api on top of ot_tracer and ot_span

* ot_span: add type specs on functions

* add functions for creating records and align with latest otel protos

* update readme to describe use of api application

* updates for fred's PR review

* separate context propagation otep

* add with_value function to run function with scoped context

* add http propagation for baggage, correlation and trace

* remove callbacks from otel module that were accidentally copeid from ot_span

* fix type specs after dialyzing opentelemetry

* fix baggage and correlations to/from http propagation

* add verification checks that tracer and context implement behaviours

* add optional config value to context manager like the tracer

* add some additional type specs

* make propagator funs fully qualified

important for being able to run upgrades. without fully qualified
functions the funs will eventually become badfuns after the
third module reload.

* update span start_opts to include attributes, sampling hint and start_time (#6)

* Initial Elixir API (#3)

* start on the elixir API

* add .gitignore, address feedback

* update span start_opts to include attributes, sampling hint and start_time (#6)

* use VERSION file for application version

* read version from version file

Co-authored-by: Tristan Sloughter <t@crashfast.com>

* remove baggage. it was removed from otep-66 (#9)

* remove resource from span record (#12)

* add CODEOWNERS file (#15)

* Registering named tracers (#16)

* add tracer provider interface for named tracers

* update readme with use about named tracer

* fix register_tracer type spec

* move span record to sdk

* add additional details about what register_tracer does

* new registeration, plus add set_span/2, end_span/2 and replace otel with macros in tracer.hrl (#17)

* support registering an application's tracer

* add set_span/2, end_span/2 and replace otel with macros in tracer.hrl

* update readme to use register_application_tracer/1

* Set Erlang Approvers as CODEOWNERS (#19)

* Elixir API based on the Erlang macro api and application registered tracers (#18)

* add set_span/2, end_span/2 and replace otel with macros in tracer.hrl

* Elixir API macros to match the Erlang macros

* include erlang docs in elixir docs (#20)

* include erlang docs in elixir docs

* make erlang_docs function in mix.exs more readable

* make edocs before mix docs and add hex metadata

* make use of is_recording in ot_span and update events field to latest spec (#21)

* use is_recording to skip possibly expensive span ops

* update Event type to otel beta spec

* missed a couple of is_recording and events changes (#22)

* remove old is_recording_events callback

* fix add_events callback type spec to new events record type

* fixing up mix.lock and use of event (#23)

* update elixir opentelemetry api to replace time events with events

* update mix lock file

* expand the docs in open_telemtry.ex, the readme and add CONTRIBUTING.md (#24)

* add elixir docs to OpenTelemetry module

* add register_application_tracer function to OpenTelemetry module and elixir to readme

* add readme section about including the SDK

* add contributing doc

* add docs to span.ex and tracer.ex

* chore: cleanup Elixir code

- Macros use `:bind_quoted` where possible
- Remove needless aliases in tests

* Add create_span and new end_span/2 (#27)

* Share configuration between Rebar3 and Mix (#11)

* ft: share configuration between Rebar3 and Mix

This should reduce amount of places where the configuration mismatch can
happen. Current solution uses Rebar3 configuration as a source of truth.

TBD:

- support for Rebar3 profile sharing

* fix(docs): build pages for the Erlang files

* chore: update mix.lock

* a bit of cleanup (#29)

* remove unused context with_value function

* fix is_recording macro in tracer header

* opentelemetry metrics API (#7)

* opentelemetry metrics API

This patch includes a behaviour for implementing the Meter SDK and
API modules for calling the meter for creating and recording
measurements.

* Update src/ot_meter.erl

Co-Authored-By: Arkadiusz Gil <arkgil@users.noreply.github.com>

* cleanup of metrics api based on comments on PR

* add Meter Provider

* remove gauge

* add meter macros and registration

* add elixir meter api module

* add register_application_* functions to OpenTelemetry module

* add observer api

* add elixir modules for counter, measure and observer api

* add meter to bound instrument return to simplify api

* updates to observer api

* remove label set function

* more simplification and some docs

* fix meter lookup

* add counter and measure specific macros

* fix get_meter typespec and add miissing callbacks to noop meter

* fix provider return values to booleans for registering traer/meter

Co-authored-by: Arkadiusz Gil <arkgil@users.noreply.github.com>

* take default argument in ot_ctx:ctx and some simple bug fixes (#38)

* Add callbacks for getting the Resource from a tracer provider (#40)

* handle codechange in ot_tracer_provider

* add callback to get resource from tracer provider

* fix spec for provider resource fetching as resource is defined in the SDK

* bump VERSION file to 0.3.0 (#41)

* add include dir to files published to hex (#42)

* removing wts dependency (#43)

* add hex metadata

* remove use of wts. get time_offset at export instead of at creation

* use system time in nano seconds for an event time

* version bump to 0.3.1 (#44)

* add otel exporter to list and add lists for integrations (#45)

* update readme to use set_attribute not the old add_attribute (#50)

* drop attributes and events that aren't a list (#51)

* Repair typespec (#46)

I'm pretty sure you didn't intend to document
[`register_application_tracer/1`][rat1] as:

> Current time in UNIX Epoch time, nanoseconds since 00:00:00 UTC on
> 1 January 1970.

... but that's how it turned out, perhaps due to a slip-up in 54ce3ad.

[rat1]: https://hexdocs.pm/opentelemetry_api/0.3.1/OpenTelemetry.html#register_application_tracer/1

Co-authored-by: Tristan Sloughter <t@crashfast.com>

* fix bug where there is no current span ctx and update_name is called (#52)

* replace create_span with start_inactive_span (#53)

* Add accessors to deconstruct Span (#54)

* Add accessors to deconstruct Span

When trying to link traces across separate systems (either linked via
HTTP calls or a message queue), having direct access to the TraceID and the
SpanID make it easier to serialize this properly and recreate a Link on
the receiving end.

This PR adds support for deconstructing a Span Context to get access to
these values.

I've added a couple of tests but they aren't all passing, so could use a
hand getting the test for establishing links to parent trace in shape.

* Rework CT test

* Use the right type on type specs

* Removed test that should be part of an SDK instead

* Fix issues/48 (#56)

- OpenTelemetry removing `/"` and  replacing this with
`"` as it creates confusion.
- Updated the example doc for the new API updates.

Modified `OpenTelemetry.Span`
Following changes were done.

- Changes related to documentation example `add_event`
- Updated `add_event/1` to `add_event/2` to accept
`event_name` and `event_attributes`.

* Update readme (#59)

* version bump to 0.3.2 (#55)

* Fixing the string formatting acrosst the project. (#62)

Changes to be committed:
	modified:   lib/open_telemetry/measure.ex
	modified:   lib/open_telemetry/meter.ex
	modified:   lib/open_telemetry/observer.ex
	modified:   lib/open_telemetry/tracer.ex

* Update span add_event docs variable name (#64)

Seems like the variables on lines 9,10 (`ecto_attributes`, and `ecto_event`) are the same variable, but named differently?

* Unspecified is not a valid span kind (#67)

* move context implementation to api app (#66)

* moving to github actions to use the same as the rest of OpenTelemetry org (#68)

* fix sampler typespec to term() since sampler is in SDK app

* move to github actions for CI

* support passing just a span_ctx to link functions (#69)

* support passing just a span_ctx to link functions

* use covertool and codecov instead of coveralls

* fix elixir otp version in main.yml

* fix link/2 to take undefined atom and fix typespecs

* correct docs for timestamp functions (#70)

* Add http status helper (#78)

* Add http status helper

* Update module doc

* Fix message fallback

* Use macro

* Update headers typing (#79)

Co-authored-by: Tristan Sloughter <t@crashfast.com>

* Add atom support (#80)

* Remove CircleCI (#81)

Github actions appears to be the CI system now

* Metrics api 0.4.0 (#71)

* remove uses of 'labelset' which was removed from the spec

* initial work on updated metrics api 0.4.0

* rename instrument function to definition and add elixir api

* prefix meter macros with ot_

* Update lib/open_telemetry/sum_observer.ex

Co-authored-by: Tino Breddin <tolbrino@users.noreply.github.com>

* Update lib/open_telemetry/updown_sum_observer.ex

Co-authored-by: Tino Breddin <tolbrino@users.noreply.github.com>

* add some docs to ot_instrument

Co-authored-by: Tino Breddin <tolbrino@users.noreply.github.com>

* ctx api update and add optional explicit ctx argument to start span functions (#83)

* rename correlations to baggage

* update context api

* make context to an optional explicit argument to start_span

* rename ot_ctx:ctx() type to ot_ctx:t() to be consistent

* feat: move opentelemetry app under apps

* fix: remove CircleCI configuration

* fix(cover): upload coverage report for API

* fix: run CT in CI as well as EUnit

* chore(cover): properly mark each coverage report

This should result with better reports as soon as coverage reports start
to parse.

Co-authored-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
Co-authored-by: Tristan Sloughter <t@crashfast.com>
Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
Co-authored-by: Greg Mefford <greg@gregmefford.com>
Co-authored-by: Arkadiusz Gil <arkgil@users.noreply.github.com>
Co-authored-by: Garth Kidd <garth@garthk.com>
Co-authored-by: Leandro Ostera <leandro@ostera.io>
Co-authored-by: Yatender Singh <yatender.nitk@gmail.com>
Co-authored-by: Marc Delagrammatikas <delagrammatikas@gmail.com>
Co-authored-by: Bryan Naegele <bryannaegele@users.noreply.github.com>
Co-authored-by: Dave Lucia <davelucianyc@gmail.com>
Co-authored-by: Tino Breddin <tolbrino@users.noreply.github.com>
  • Loading branch information
13 people committed Sep 23, 2020
1 parent 48f1769 commit c25ac35
Show file tree
Hide file tree
Showing 102 changed files with 3,870 additions and 23 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/main.yml
Expand Up @@ -18,6 +18,9 @@ jobs:
otp_version: ['23.0.2', '22.3.4.2', '21.3.8.16']
os: [ubuntu-latest]

env:
OTP_VERSION: ${{ matrix.otp_version }}

steps:
- uses: actions/checkout@v2
- uses: gleam-lang/setup-erlang@v1.0.0
Expand All @@ -27,7 +30,9 @@ jobs:
- name: Compile
run: rebar3 compile
- name: EUnit tests
run: rebar3 eunit
run: rebar3 eunit --cover
- name: Common Test tests
run: rebar3 ct --cover
- name: Dialyzer
run: rebar3 dialyzer
- name: XRef
Expand All @@ -37,3 +42,10 @@ jobs:
- uses: codecov/codecov-action@v1
with:
file: _build/test/covertool/opentelemetry.covertool.xml
env_vars: OTP_VERSION
flags: sdk
- uses: codecov/codecov-action@v1
with:
file: _build/test/covertool/opentelemetry_api.covertool.xml
env_vars: OTP_VERSION
flags: api
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions apps/opentelemetry/rebar.config
@@ -0,0 +1,2 @@
{erl_opts, [debug_info]}.
{deps, []}.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions apps/opentelemetry_api/.github/workflows/main.yml
@@ -0,0 +1,55 @@
name: Common Test

on:
pull_request:
branches:
- 'master'
push:
branches:
- 'master'

jobs:
erlang_tests:
name: OTP ${{ matrix.otp_version }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
otp_version: ['23.0.2', '22.3.4.2', '21.3.8.16']
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- uses: gleam-lang/setup-erlang@v1.0.0
with:
otp-version: ${{ matrix.otp_version }}

- name: Compile
run: rebar3 compile
- name: EUnit tests
run: rebar3 eunit
- name: Dialyzer
run: rebar3 dialyzer
- name: XRef
run: rebar3 xref
- name: Covertool
run: rebar3 covertool generate
- uses: codecov/codecov-action@v1
with:
file: _build/test/covertool/opentelemetry.covertool.xml

elixir_tests:
runs-on: ubuntu-latest
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp_version: ['23.0.2', '22.3.4.2', '21.3.8.16']
elixir: ['1.9.4']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-elixir@v1
with:
otp-version: ${{matrix.otp_version}}
elixir-version: ${{matrix.elixir}}
- run: mix deps.get
- run: mix test
32 changes: 32 additions & 0 deletions apps/opentelemetry_api/.gitignore
@@ -0,0 +1,32 @@
edoc
.rebar3
_*
.eunit
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
logs
_build
.idea
*.iml
rebar3.crashdump
*~

/_build
/cover
/deps
/doc
/.fetch
erl_crash.dump
*.ez
*.beam
/config/*.secret.exs
.elixir_ls/

15 changes: 15 additions & 0 deletions apps/opentelemetry_api/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,15 @@
#####################################################
#
# List of approvers for OpenTelemetry Erlang API repository
#
#####################################################
#
# Learn about membership in OpenTelemetry community:
# https://github.com/open-telemetry/community/blob/master/community-membership.md
#
#
# Learn about CODEOWNERS file format:
# https://help.github.com/en/articles/about-code-owners
#

* @open-telemetry/erlang-approvers
118 changes: 118 additions & 0 deletions apps/opentelemetry_api/CONTRIBUTING.md
@@ -0,0 +1,118 @@
# Contributing to opentelemetry-erlang-api

The Erlang/Elixir special interest group (SIG) meets as part of the
[Erlang Ecosystem Foundation](https://erlef.org/wg/observability). See the
OpenTelemetry [community](https://github.com/open-telemetry/community#erlangelixir-sdk)
repo for information on this and other language SIGs.


## Pull Requests

### How to Send Pull Requests

Everyone is welcome to contribute code to `opentelemetry-erlang-api` via
GitHub pull requests (PRs).

To create a new PR, fork the project in GitHub and clone the upstream
repo:

```sh
$ git clone https://github.com/open-telemetry/opentelemetry-erlang-api/
```

This would put the project in the `opentelemetry-erlang-api` directory in
current working directory.

Enter the newly created directory and add your fork as a new remote:

```sh
$ git remote add <YOUR_FORK> git@github.com:<YOUR_GITHUB_USERNAME>/opentelemetry-erlang-api
```

Check out a new branch, make modifications, run tests, and
push the branch to your fork:

```sh
$ git checkout -b <YOUR_BRANCH_NAME>
# edit files
$ rebar3 ct
$ mix test
$ git add -p
$ git commit
$ git push <YOUR_FORK> <YOUR_BRANCH_NAME>
```

Open a pull request against the main `opentelemetry-erlang-api` repo.

### How to Receive Comments

* If the PR is not ready for review, please put `[WIP]` in the title,
tag it as `work-in-progress`, or mark it as
[`draft`](https://github.blog/2019-02-14-introducing-draft-pull-requests/).
* Make sure CLA is signed and CI is clear.

### How to Get PRs Merged

A PR is considered to be **ready to merge** when:

* It has received two approvals from Collaborators/Maintainers (at
different companies).
* Major feedbacks are resolved.
* It has been open for review for at least one working day. This gives
people reasonable time to review.
* Trivial change (typo, cosmetic, doc, etc.) doesn't have to wait for
one day.
* Urgent fix can take exception as long as it has been actively
communicated.

Any Collaborator/Maintainer can merge the PR once it is **ready to
merge**.

## Design Choices

As with other OpenTelemetry clients, opentelemetry-erlang-api follows the
[opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification).

It's especially valuable to read through the [library
guidelines](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/library-guidelines.md).

### Focus on Capabilities, Not Structure Compliance

OpenTelemetry is an evolving specification, one where the desires and
use cases are clear, but the method to satisfy those uses cases are
not.

As such, Contributions should provide functionality and behavior that
conforms to the specification, but the interface and structure is
flexible.

It is preferable to have contributions follow the idioms of the
language rather than conform to specific API names or argument
patterns in the spec.

For a deeper discussion, see:
https://github.com/open-telemetry/opentelemetry-specification/issues/165

## Style Guide

* Make sure to run `make precommit` - this will find and fix the code
formatting.

## Approvers and Maintainers

Approvers:

- [Fred Hebert](https://github.com/ferd), Postmates
- [Greg Mefford](https://github.com/gregmefford), Bleacher Report
- [Zach Daniel](https://github.com/zachdaniel), Variance

Maintainers:

- [Tristan Sloughter](https://github.com/tsloughter), Postmates
- [Ilya Khaprov](https://github.com/deadtrickster), Kobil Systems GmbH
- [Łukasz Jan Niemier](https://github.com/hauleth), Kobil Systems GmbH

### Become an Approver or a Maintainer

See the [community membership document in OpenTelemetry community
repo](https://github.com/open-telemetry/community/blob/master/community-membership.md).

0 comments on commit c25ac35

Please sign in to comment.