Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[META 839] Implement /etc/hostname heuristic for host name capture #1426

Closed
elastic-apm-tech opened this issue Nov 28, 2023 · 1 comment
Closed

Comments

@elastic-apm-tech
Copy link

See meta issue for the description and details:

@picandocodigo
Copy link
Member

The Ruby agent uses Socket.gethostname which is not dependent on /etc/hostname.

A small test with distroless:

# Dockerfile
FROM ruby:3.0.0-buster as ruby

ADD https://github.com/coord-e/magicpak/releases/latest/download/magicpak-x86_64-unknown-linux-musl /usr/bin/magicpak
RUN chmod +x /usr/bin/magicpak
RUN /usr/bin/magicpak -v $(which ruby) /bundle

WORKDIR /ruby/src
ADD . /ruby/src

FROM gcr.io/distroless/base-debian11
COPY --from=ruby /bundle /.
COPY --from=ruby /usr/lib/x86_64-linux-gnu/libyaml* /usr/lib/x86_64-linux-gnu/
COPY --from=ruby /usr/local/bin/ /usr/local/bin
COPY --from=ruby /usr/local/lib/ruby/ /usr/local/lib/ruby
COPY --from=ruby /ruby/src /

CMD ["/usr/local/bin/ruby", "-v"]
CMD ["/usr/local/bin/ruby", "app.rb"]
# app.rb
require 'socket'
puts "HOSTNAME: #{Socket.gethostname}"
$ docker run -t myapp
HOSTNAME: 0213f75455a2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants