Module: Libdatadog

Defined in:
lib/libdatadog.rb,
lib/libdatadog/version.rb

Constant Summary collapse

LIB_VERSION =

Current libdatadog version

"14.1.0"
VERSION =

The gem version scheme is lib_version.gem_major.gem_minor. This allows a version constraint such as ~> 0.2.0.1.0 in the consumer (ddtrace), in essence pinning libdatadog to a specific version like = 0.2.0, but still allow a) introduction of a gem-level breaking change by bumping gem_major and b) allow to push automatically picked up bugfixes by bumping gem_minor.

"#{LIB_VERSION}.#{GEM_MAJOR_VERSION}.#{GEM_MINOR_VERSION}#{GEM_PRERELEASE_VERSION}"

Class Method Summary collapse

Class Method Details

.available_binariesObject

This should only be used for debugging/logging



7
8
9
# File 'lib/libdatadog.rb', line 7

def self.available_binaries
  File.directory?(vendor_directory) ? (Dir.entries(vendor_directory) - [".", ".."]) : []
end

.current_platformObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/libdatadog.rb', line 27

def self.current_platform
  platform = Gem::Platform.local.to_s

  if platform.end_with?("-gnu")
    # In some cases on Linux with glibc the platform includes a -gnu suffix. We normalize it to not have the suffix.
    #
    # Note: This should be platform = platform.delete_suffix("-gnu") but it doesn't work on legacy Rubies; once
    # dd-trace-rb 2.0 is out we can simplify this.
    #
    platform = platform[0..-5]
  end

  if RbConfig::CONFIG["arch"].include?("-musl") && !platform.include?("-musl")
    # Fix/workaround for https://github.com/datadog/dd-trace-rb/issues/2222
    #
    # Old versions of rubygems (for instance 3.0.3) don't properly detect alternative libc implementations on Linux;
    # in particular for our case, they don't detect musl. (For reference, Rubies older than 2.7 may have shipped with
    # an affected version of rubygems).
    # In such cases, we fall back to use RbConfig::CONFIG['arch'] instead.
    #
    # Why not use RbConfig::CONFIG['arch'] always? Because Gem::Platform.local.to_s does some normalization that seemed
    # useful in the past, although part of it got removed in https://github.com/rubygems/rubygems/pull/5852.
    # For now we only add this workaround in a specific situation where we actually know it is wrong, but in the
    # future it may be worth re-evaluating if we should move away from `Gem::Platform` altogether.
    #
    # See also https://github.com/rubygems/rubygems/pull/2922 and https://github.com/rubygems/rubygems/pull/4082

    RbConfig::CONFIG["arch"]
  else
    platform
  end
end

.ld_library_pathObject



68
69
70
71
72
73
74
# File 'lib/libdatadog.rb', line 68

def self.ld_library_path
  pkgconfig_folder = self.pkgconfig_folder

  return unless pkgconfig_folder

  File.absolute_path("#{pkgconfig_folder}/../")
end

.path_to_crashtracking_receiver_binaryObject



60
61
62
63
64
65
66
# File 'lib/libdatadog.rb', line 60

def self.path_to_crashtracking_receiver_binary
  pkgconfig_folder = self.pkgconfig_folder

  return unless pkgconfig_folder

  File.absolute_path("#{pkgconfig_folder}/../../bin/libdatadog-crashtracking-receiver")
end

.pkgconfig_folder(pkgconfig_file_name = "datadog_profiling_with_rpath.pc") ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/libdatadog.rb', line 11

def self.pkgconfig_folder(pkgconfig_file_name = "datadog_profiling_with_rpath.pc")
  current_platform = self.current_platform

  return unless available_binaries.include?(current_platform)

  pkgconfig_file = Dir.glob("#{vendor_directory}/#{current_platform}/**/#{pkgconfig_file_name}").first

  return unless pkgconfig_file

  File.absolute_path(File.dirname(pkgconfig_file))
end