opentelemetry-instrumentation.cr v0.5.3

Bundled integrations for opentelemetry-api.cr (https://github.com/wyhaines/opentelemetry-api.cr).

OpenTelemetry CI GitHub release GitHub commits since latest release (by SemVer)

opentelemetry-instrumentation

This package provides both the base functionality needed to build instrumentation for arbitrary classes/libraries, but also ready-made instrumentation for commonly used Crystal libraries.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      opentelemetry-instrumentation:
        github: wyhaines/opentelemetry-instrumentation.cr
    
  2. Run shards install

Usage

require "opentelemetry-instrumentation.cr"

Requiring the top level library will attempt to instrument, via a macro finished block, every component within your project for which there exists instrumentation. Each instrumentation package attempts to determine whether it is safe to install before doing so, by validating that required components are installed, and that their versions are compatible.

The reason for running the autoinstrumentation within a finished block is to ensure that all other classes have been loaded prior to loading the instrumentation. However, the structure of some softare and frameworks (such as https://luckyframework.org/) prevent this from working properly. If it appears that instrumentation has not been installed, you can check what instruments have been installed by examining the data returned from OpenTelemetry::Instrumentation::Registry.instruments. It may look like this:

[OpenTelemetry::Instrumentation::CrystalDB,
OpenTelemetry::Instrumentation::CrystalHttpServer,
OpenTelemetry::Instrumentation::CrystalLog]

If the array is empty, then no instrumentation was installed. You can require instrumentation manually by requiring the relevant file. For instance, to manually install the DB instrumentation (assuming that DB has been previously required):

require "opentelemetry-instrumentation/src/instrumentation/crystal/db"

Documentation

The generated docs can all be found here:

https://wyhaines.github.io/opentelemetry-instrumentation.cr/

Contributing

  1. Fork it (https://github.com/wyhaines/opentelemetry-instrumentation.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

GitHub code size in bytes GitHub issues

Repository

opentelemetry-instrumentation.cr

Owner
Statistic
  • 16
  • 4
  • 5
  • 3
  • 6
  • 6 months ago
  • March 13, 2022
License

Apache License 2.0

Links
Synced at

Wed, 24 Apr 2024 17:37:55 GMT

Languages