Commit Graph

71 Commits

Author SHA1 Message Date
Josh Lee b85420afed
Don't record DB statements without sanitizaiton (#166)
* Don't record DB statements without sanitizaiton

This adds an option to OpentelemetryEcto.setup/1 that allows a query
sanitization function to be provided. If it is not provided, queries
are not captured (this is the default).

* test that db.statement isnt present unless query sanitizer is configured

* rename option to `:db_statement`

* run mix format
2023-06-13 05:13:01 -06:00
Cristiano Piemontese 12532e5ff5
Post-PR opentelemetry_httpoison fixup (#178)
* Update opentelemetry_httpoison CODEOWNERS

Add Shared Services team as a CODEOWNER for opentelemetry_httpoison

* add CHANGELOG & fix license
2023-06-05 19:26:31 -06:00
Cristiano Piemontese 0cc8c760d0
Add telepoison (#148)
* add telepoison

* rename

* rename file too, duh

* rename test file

* port updates

* add standard workflow
2023-06-04 08:23:03 -06:00
Guilherme de Maio 901b571b07
[opentelemetry_tesla] Conditionally override propagator (#176)
* Optionally disable trace propagation for Tesla

While we always want spans being produced, trace progation is not
desirable in all cases - namely, when calling external parties, as that
may leak sensitive information, like one present on Baggage.

This patch introduces a new option `:propagate`, that defaults to
`true`.

Some tweaks are made to existing propagation test, fixing how options
are used. The approach here is closer to what we see in some middleware
tests of Tesla itself.

* change to propagator override

* change propagator to it uses global default

* mix format

* improve docs

---------

Co-authored-by: Andrew Rosa <dev@andrewhr.io>
2023-05-29 04:53:21 -06:00
Cedric Ziel 6a5fc4c884
Bump version to 1.1.1 (#175) 2023-05-23 05:04:01 -06:00
Cedric Ziel 8292870b66
Add db.name to ecto spans (#172)
* Add db.name to ecto spans

As per the spec, the db.name attribute is required on database spans. This changes adds it.

Ref: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md#call-level-attributes

* Add db.name attribute to tests

* Changelog update

* Update instrumentation/opentelemetry_ecto/test/opentelemetry_ecto_test.exs

* Update instrumentation/opentelemetry_ecto/test/opentelemetry_ecto_test.exs
2023-05-23 04:49:29 -06:00
Patrik Stenmark ddf0706bf1
Make exdocs settings a bit more similar between different packages (#168)
* Add source_url_pattern to be able to use the "link to source" button
* Add README.md as an "extra" where it wasn't already
* Add a `main` setting. They all have a very obvious main module. Set
  that as `main`, so a user is shown this immediately instead of a list
  of usually only this module.
2023-04-30 12:10:03 -06:00
Andrey Chernykh 1230271580
[Tesla middleware] `non_error_statuses` option (#154)
* [Tesla middleware] `non_error_statuses` option

* :mark_status_ok option instead of :non_error_statuses

---------

Co-authored-by: Tristan Sloughter <t@crashfast.com>
2023-04-21 10:07:21 -06:00
Romario López 19a44fbd68
Improve Req with OTel http spec (#163)
* Improve span_name

Use span_name if provided. Fallback to url.path if there is no
path_params.

* Add unreleased changelog

* Update examples and module description

* Change span_name and http.url to follow OTEL spec

* Remove unused function

* Improve changelog

* Fix reading span_name from request.options

* Don't use URI.path

* address changelog
2023-04-20 05:04:18 -06:00
Maarten van Vliet 1de26cce1a
Add Dataloader instrumentation library (#137)
* Add Dataloader instrumentation library

* Move call to set context to @run_start event

---------

Co-authored-by: Tristan Sloughter <t@crashfast.com>
2023-04-05 10:34:49 -06:00
Bryan Naegele de17c31194
OpentelemetryReq plugin (#160)
* OpentelemetryReq plugin

* Split span handling

* version bump

* Remove set

* Unused var

* Set parent ctx back on completion
2023-03-31 09:51:27 -06:00
Ty Bekiares a59f399155
[grpcbox] bump version (#156)
Co-authored-by: Tristan Sloughter <t@crashfast.com>
2023-03-31 05:35:27 -06:00
Damir Vandic 7db602b9d7
Relax nimble_options (#161) 2023-03-21 06:45:01 -06:00
Bryan Naegele 760ba56809
propagator v0.2.2 (#158)
* propagator v0.2.2

* update changelog

* Publish cowboy
2023-03-17 10:36:26 -06:00
Erick Dennis bc11851360
Tesla.Middleware.OpenTelemetry: handle 400 as error (#153) 2023-03-06 10:51:05 -07:00
Bryan Naegele 8897400d4e
Phoenix 1.1.0 (#145)
* Phoenix 1.1.0

* Fix docs

* Publish tesla with updated sem conventions
2023-01-13 14:38:05 -07:00
Bryan Naegele e6c8cc6289
Phoenix Plug.Cowboy adapter support (#144)
* wip

* Cowboy adapter support

* Use path deps to keep things updated

* fix doc

* Fix example project
2023-01-06 13:46:06 -07:00
Yordis Prieto 7971f2fdaa
chore: add sc to finch (#141) 2022-12-15 04:36:52 -07:00
Andrew Rosa dfed96874f
Add Nebulex instrumentation library (#83)
Add instrumentation for Nebulex, a distributed cache library. This
library provides solid telemetry support for this initial
implementation.

Caching implementation is mostly based on in-memory storage (like ETS)
and RPC calls for distribution (via OTP libraries, like :erpc). AFAICT,
there is not much specifics for how to translate into Semantic
Attributes: those caches are not quite a DB, except maybe for the one
which implements the storage; the RPC can't be reliably captured
either.

Given the above constraints, this initial implementation instruments the
library via custom attributes (namespaced as `nebulex.*`). It's not 100%
clear the behaviour of OTel for actual distributed caches - from my
tests, that may create some orphan spans. I think that's fine as first
release.

Nebulex follow the patterns of Ecto, so this instrumentation follows a
similar pattern of OpentelemetryEcto. It does include a `setup_all/1`
function for convenience, that leverages the :init events Nebulex emit
on process start.

Co-authored-by: Tristan Sloughter <t@crashfast.com>
2022-12-14 17:38:18 -07:00
Yordis Prieto 1e2ae6707c
chore: add sc to oban (#138) 2022-12-14 16:48:27 -07:00
Yordis Prieto d1ec189362
chore: add semantic conventions to phoenix (#121)
* fix: redix missing dep

* chore: add sc dep

* chore: use semantic conventions in phoenix
2022-12-12 13:51:54 -07:00
Ty Bekiares f04340aff4
[grpcbox] add grpc conventions (#130)
Co-authored-by: Tristan Sloughter <t@crashfast.com>
2022-12-01 15:37:47 -07:00
Bryan Naegele c8b760e776
publish latest updates (#127) 2022-11-16 19:07:23 -07:00
Andrew Rosa 56c6503a93
Fix two use cases of Ecto span propagation (#82)
First one is related to `OpenTelemetry.Ctx` API. I've noticed in a few
scenarios the current span of a trace may get lost after Ecto calls.

Looking at the The `attach/1` typespec, it's a Ctx -> Token, while
`dettach/1` as Token -> Ctx function. That made me assume the expected
input of dettach is the return type of attach. Indeed, after this change
we got the behavior of Ecto calls preserve the parent span untouched.

That leads to a second bug found. When ecto does simple calls within a
Task, due the special propagation code for preloads that means it will
skip the current span, if any.  The solution here is to first check the
current process.

One test was added to reproduce this bug.
2022-11-15 17:55:32 -07:00
Bryan Naegele 4d39f47b03
update elixir package deps (#126)
* update elixir package deps

* Oban test updates
2022-11-15 17:48:50 -07:00
Yordis Prieto ed49b0c4bb
chore: add semantic conventions pkg (#118)
Co-authored-by: Tristan Sloughter <t@crashfast.com>
2022-11-15 16:39:22 -07:00
Bryan Naegele 0e6a776ffb
Fix CI errors, update GHA deps, update versions (#125)
* Fix CI errors, update GHA deps, update versions

* output syntax

* remove OTP 22 tests

* set concurrency to cancel in progress

* whitespace

* incompatible vsns and failed test

* Try pulling excludes out

* Escaping

* Just drop < 1.13 until this can move to workflows

* quote
2022-11-15 16:22:28 -07:00
Yordis Prieto 24499cbae1
fix: missing deps in redix (#122) 2022-11-15 04:43:44 -07:00
Yordis Prieto 01fc804ab2
chore: add semantic conventions pgk to redix (#119) 2022-11-14 15:33:48 -07:00
Alberto Sartori a72305f574
Add server span kind to otel cowboy (#116)
* Add server span kind to otel cowboy

* Upgrade deps
2022-11-10 04:15:15 -07:00
John Mauricio Carmona E 4358c75b99
finch-instrumentation (#115)
* finch-instrumentation

* Span attributes update

* Readme update

* Readme update
2022-11-09 12:27:40 -07:00
Ricardo Paiva b10af6e987
Bump opentelemetry_tesla version (#112) 2022-10-12 15:25:08 -06:00
Guilherme de Maio c69a3c7b49
[opentelemetry-tesla] add custom span name override as middleware opt (#105)
* fix remove extra bracket in mix.exs

* use capture log for less verbose test output

* add span_name opt for overriding span name

* add moduledoc

* allow function for span_name opt
2022-10-04 16:32:36 -06:00
Damir Vandic 7a4c33ef7c
Relax dependencies for opentelemtry_tesla (#106) 2022-09-03 07:59:03 -06:00
cevado a9e6fa0c84
opentelemetry_ecto - add possibility to setup additional attributes. (#94)
* Make possible to include additional attributes to the span through setup

* Adjust code review changes
2022-09-02 13:47:34 -06:00
David White 2b5eb14cca
Fix bug in OpentelemetryOban.insert_all/4 (#103)
Co-authored-by: Tristan Sloughter <t@crashfast.com>
2022-08-28 05:45:02 -06:00
Ricardo Paiva e8d1462f46
Add otel tesla library (#90)
* Add Tesla HTTP client instrumentation library

* Update workflows configuration

* Update labeler.yml

* Update CODEOWNERS

* Add LICENSE file

Co-authored-by: Bryan Naegele <bryannaegele@users.noreply.github.com>
2022-08-25 12:47:59 -06:00
Bryan Naegele 6591b28166
Publish updates for Phoenix, Ecto, and Cowboy (#79)
* Publish 1.0 for Phoenix, Ecto, and Cowboy

* Missed version in changelog
2022-06-03 10:54:37 -06:00
Andrew Rosa 8df66285bb
Report Redix error messages through OTel status (#81)
Instead of custom attributes, leverage the status description as
described in Semantic Conventions. This approach is taken from current
`opentelemetry_ecto` implementation.

Small non-related change is a fix the license description in `mix.exs`.
2022-05-10 14:05:35 -06:00
Greg Mefford 0939fe2de8
Relax requirement on telemetry library (#77) 2022-04-13 09:57:45 -06:00
Andrew Rosa daa6a97f3e
Bump dependencies and relax opentelemetry* to 1.0 (#75) 2022-03-31 11:23:32 -06:00
Tristan Sloughter af2a659631
bump otel-elli version number (#74) 2022-03-28 10:13:13 -06:00
Tristan Sloughter 74172effcd
add grpcbox instrumentation library (#70)
* add grpcbox instrumentation library

* grpcbox: fix .app file license and deps

* lock grpcbox
2022-03-27 11:42:36 -06:00
Tristan Sloughter db5193be45
elli instrumentation library (#69)
* elli instrumentation library

* Update instrumentation/opentelemetry_elli/README.md

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>

* Update instrumentation/opentelemetry_elli/README.md

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>

* Update instrumentation/opentelemetry_elli/README.md

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>

* Update instrumentation/opentelemetry_elli/README.md

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>

* Update instrumentation/opentelemetry_elli/README.md

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>

* Update instrumentation/opentelemetry_elli/README.md

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>

* add note about how excluded URL env var is parsed

* Update instrumentation/opentelemetry_elli/src/opentelemetry_elli.app.src

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>

Co-authored-by: Fred Hebert <mononcqc@ferd.ca>
2022-03-27 11:02:44 -06:00
Damir Vandic 0f137525b5
Make Ecto spans of preloads children of the parent span (#49)
🎉
2022-03-24 14:19:24 -06:00
Andrew Rosa 3faa246d02
Remove exporter race-condition on tests (#44)
Default exporter immediately attempts on start connect to
`:otel-collector` default port. As we don't have any collector running
on our test environment, this results in a few warnings. That's not an
issue in itself, as code immediately switches to another export, but
creates a lot of noise.

This patch moves the exporter setup to `config/test.exs`, essentially
removing the need to restart opentelemetry applicationn for each test
case. The only work setup blocks do is update the exporter's target pid.

The processor was changed to simple mode, available now, which also remove
another vector of (unlikely but theoretically possible) race-conditions.
2022-03-24 11:48:59 -06:00
Kai e3f0ec8ee0
Handle binary and undefined response status and rename http.status to http.status_code in `opentelemetry-cowboy` (#48)
* Handle binary resp_status from Cowboy and rename http.status to http.status_code

* Fix test to use http.status_code as well

* Handle resp_status could be undefined but not error

- This could be due to websocket upgrade request.

* Rename Status1 and transform_status to a more concise naming

* Add test case for handling binary response code

* Fix syntax and failing tests

* Always convert cowboy status to status code

* Set otel span status as error when status code >= 500
2022-03-19 06:16:15 -06:00
Derek Kraan ddb2d3b963
Only attempt to record an exception if there is an active span. (#37)
There is an edge case, if you use `forward/4` and use Plug.ErrorHandler,
then when an exception reaches the outer router, then Plug.send_resp
will be called, triggering `[:phoenix, :endpoint, :stop]`, and the span
will be gone by the time the outer router gets the exception. This
causes this telemetry handler to crash and be detached.

Sequence of events:
- [:phoenix, :endpoint, :start]
- [:phoenix, :router_dispatch, :exception] (inner router)
- [:phoenix, :endpoint, :stop]
- [:phoenix, :router_dispatch, :exception] (outer router) ** here there is no span, crashes
2022-03-18 05:21:26 -06:00
Ho-Yon Mak a7b0c04aaf
Add idle_time measurement (#66)
Co-authored-by: Tristan Sloughter <t@crashfast.com>
2022-03-14 10:22:22 -06:00
Bryan Naegele 9446fe6a99
Otel 1.0 support (#57) 2022-01-04 18:58:06 -07:00