Skip to content

wyhaines/opentelemetry-instrumentation.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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