Module: Tracekit

Defined in:
lib/tracekit.rb,
lib/tracekit/sdk.rb,
lib/tracekit/config.rb,
lib/tracekit/railtie.rb,
lib/tracekit/version.rb,
lib/tracekit/evaluator.rb,
lib/tracekit/llm/common.rb,
lib/tracekit/middleware.rb,
lib/tracekit/metrics/gauge.rb,
lib/tracekit/metrics/counter.rb,
lib/tracekit/metrics/exporter.rb,
lib/tracekit/metrics/registry.rb,
lib/tracekit/snapshots/client.rb,
lib/tracekit/snapshots/models.rb,
lib/tracekit/endpoint_resolver.rb,
lib/tracekit/local_ui/detector.rb,
lib/tracekit/local_ui_detector.rb,
lib/tracekit/metrics/histogram.rb,
lib/tracekit/security/detector.rb,
lib/tracekit/security/patterns.rb,
lib/tracekit/metrics/metric_data_point.rb,
lib/tracekit/llm/openai_instrumentation.rb,
lib/tracekit/llm/anthropic_instrumentation.rb

Overview

TraceKit Ruby SDK OpenTelemetry-based APM for Ruby and Rails applications

Defined Under Namespace

Modules: Evaluator, LLM, LocalUI, Metrics, Security, Snapshots Classes: Config, EndpointResolver, Error, LocalUIDetector, Middleware, Railtie, SDK

Constant Summary collapse

VERSION =
"0.2.4"

Class Method Summary collapse

Class Method Details

.capture_snapshot(label, variables) ⇒ Object

Captures a snapshot

Parameters:

  • label (String)

    Snapshot label

  • variables (Hash)

    Variables to capture



96
97
98
# File 'lib/tracekit.rb', line 96

def self.capture_snapshot(label, variables)
  sdk&.capture_snapshot(label, variables)
end

.configure {|Config::Builder| ... } ⇒ SDK

Configures and initializes the TraceKit SDK

Examples:

Tracekit.configure do |config|
  config.api_key = ENV["TRACEKIT_API_KEY"]
  config.service_name = "my-app"
  config.environment = "production"
end

Yields:

Returns:

  • (SDK)

    Configured SDK instance



58
59
60
61
# File 'lib/tracekit.rb', line 58

def self.configure
  config = Config.build { |c| yield(c) }
  SDK.configure(config)
end

.counter(name, tags = {}) ⇒ Metrics::Counter

Creates a counter metric

Parameters:

  • name (String)

    Metric name

  • tags (Hash) (defaults to: {})

    Optional tags

Returns:



73
74
75
# File 'lib/tracekit.rb', line 73

def self.counter(name, tags = {})
  sdk&.counter(name, tags)
end

.gauge(name, tags = {}) ⇒ Metrics::Gauge

Creates a gauge metric

Parameters:

  • name (String)

    Metric name

  • tags (Hash) (defaults to: {})

    Optional tags

Returns:



81
82
83
# File 'lib/tracekit.rb', line 81

def self.gauge(name, tags = {})
  sdk&.gauge(name, tags)
end

.histogram(name, tags = {}) ⇒ Metrics::Histogram

Creates a histogram metric

Parameters:

  • name (String)

    Metric name

  • tags (Hash) (defaults to: {})

    Optional tags

Returns:



89
90
91
# File 'lib/tracekit.rb', line 89

def self.histogram(name, tags = {})
  sdk&.histogram(name, tags)
end

.sdkSDK?

Returns the current SDK instance

Returns:



65
66
67
# File 'lib/tracekit.rb', line 65

def self.sdk
  SDK.current
end