Class: Datadog::SymbolDatabase::ServiceVersion Private

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/symbol_database/service_version.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Top-level container wrapping scopes for upload to the agent.

ServiceVersion is the root object serialized to JSON for symbol database uploads. Contains service metadata (name, env, version) and all extracted scopes. The language field identifies the tracer.

Created by: Uploader (wraps scopes array before serialization) Contains: Array of top-level Scope objects (FILE scopes) Serialized to: JSON via to_json, then GZIP compressed for upload

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service:, env:, version:, scopes:, upload_id: nil, batch_num: nil, final: nil) ⇒ ServiceVersion

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new ServiceVersion

Parameters:

  • service (String) —

    Service name (required, from DD_SERVICE)

  • env (String, nil) —

    Environment (from DD_ENV, passed through unchanged)

  • version (String, nil) —

    Version (from DD_VERSION, passed through unchanged)

  • scopes (Array<Scope>) —

    Top-level scopes (required)

  • upload_id (String, nil) (defaults to: nil) —

    UUID identifying the logical upload (shared by all batches)

  • batch_num (Integer, nil) (defaults to: nil) —

    1-indexed batch number within the upload

  • final (Boolean, nil) (defaults to: nil) —

    true if this is the last batch of the upload

Raises:

  • (ArgumentError) —

    if service empty or scopes not an array



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/datadog/symbol_database/service_version.rb', line 30

def initialize(service:, env:, version:, scopes:, upload_id: nil, batch_num: nil, final: nil)
  raise ArgumentError, "service is required" if service.nil? || service.empty?
  raise ArgumentError, "scopes must be an array" unless scopes.is_a?(Array)

  @service = service
  @env = env
  @version = version
  @language = "ruby"
  @scopes = scopes
  @upload_id = upload_id
  @batch_num = batch_num
  @final = final
end

Instance Attribute Details

#batch_num ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def batch_num
  @batch_num
end

#env ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def env
  @env
end

#final ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def final
  @final
end

#language ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def language
  @language
end

#scopes ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def scopes
  @scopes
end

#service ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def service
  @service
end

#upload_id ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def upload_id
  @upload_id
end

#version ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/datadog/symbol_database/service_version.rb', line 19

def version
  @version
end

Instance Method Details

#to_h ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert service version to Hash for JSON serialization.

Returns:

  • (Hash) —

    ServiceVersion as hash with symbol keys



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/datadog/symbol_database/service_version.rb', line 46

def to_h
  {
    service: service,
    env: env,
    version: version,
    language: language,
    scopes: scopes.map(&:to_h),
    upload_id: upload_id,
    batch_num: batch_num,
    final: final,
  }
end

#to_json(_state = nil) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Serialize service version to JSON.

Returns:

  • (String) —

    JSON string representation



61
62
63
# File 'lib/datadog/symbol_database/service_version.rb', line 61

def to_json(_state = nil)
  JSON.generate(to_h)
end