# frozen_string_literal: true # Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 def with_env(new_env) env_to_reset = ENV.select { |k, _| new_env.key?(k) } keys_to_delete = new_env.keys - ENV.keys new_env.each_pair { |k, v| ENV[k] = v } yield ensure env_to_reset.each_pair { |k, v| ENV[k] = v } keys_to_delete.each { |k| ENV.delete(k) } end def exportable_timestamp(time = Time.now) (time.to_r * 1_000_000_000).to_i end