mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-21 13:47:16 +00:00
Add OpenTelemetry VCS attributes (#32904)
This commit is contained in:
parent
1c6f53e70f
commit
bcf5d30e01
1
.github/workflows/build-container-image.yml
vendored
1
.github/workflows/build-container-image.yml
vendored
|
@ -92,6 +92,7 @@ jobs:
|
|||
build-args: |
|
||||
MASTODON_VERSION_PRERELEASE=${{ inputs.version_prerelease }}
|
||||
MASTODON_VERSION_METADATA=${{ inputs.version_metadata }}
|
||||
SOURCE_COMMIT=${{ github.sha }}
|
||||
platforms: ${{ inputs.platforms }}
|
||||
provenance: false
|
||||
builder: ${{ steps.buildx.outputs.name || steps.buildx-native.outputs.name }}
|
||||
|
|
|
@ -29,6 +29,8 @@ FROM docker.io/ruby:${RUBY_VERSION}-slim-${DEBIAN_VERSION} AS ruby
|
|||
ARG MASTODON_VERSION_PRERELEASE=""
|
||||
# Append build metadata or fork information to version.rb [--build-arg MASTODON_VERSION_METADATA="pr-123456"]
|
||||
ARG MASTODON_VERSION_METADATA=""
|
||||
# Will be available as Mastodon::Version.source_commit
|
||||
ARG SOURCE_COMMIT=""
|
||||
|
||||
# Allow Ruby on Rails to serve static files
|
||||
# See: https://docs.joinmastodon.org/admin/config/#rails_serve_static_files
|
||||
|
@ -48,6 +50,7 @@ ENV \
|
|||
# Apply Mastodon version information
|
||||
MASTODON_VERSION_PRERELEASE="${MASTODON_VERSION_PRERELEASE}" \
|
||||
MASTODON_VERSION_METADATA="${MASTODON_VERSION_METADATA}" \
|
||||
SOURCE_COMMIT="${SOURCE_COMMIT}" \
|
||||
# Apply Mastodon static files and YJIT options
|
||||
RAILS_SERVE_STATIC_FILES=${RAILS_SERVE_STATIC_FILES} \
|
||||
RUBY_YJIT_ENABLE=${RUBY_YJIT_ENABLE} \
|
||||
|
|
|
@ -65,6 +65,13 @@ if ENV.keys.any? { |name| name.match?(/OTEL_.*_ENDPOINT/) }
|
|||
"#{prefix}#{separator}#{$PROGRAM_NAME.split('/').last}"
|
||||
end
|
||||
c.service_version = Mastodon::Version.to_s
|
||||
|
||||
if Mastodon::Version.source_commit.present?
|
||||
c.resource = OpenTelemetry::SDK::Resources::Resource.create(
|
||||
'vcs.repository.ref.revision' => Mastodon::Version.source_commit,
|
||||
'vcs.repository.url.full' => Mastodon::Version.source_base_url
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -70,6 +70,10 @@ module Mastodon
|
|||
end
|
||||
end
|
||||
|
||||
def source_commit
|
||||
ENV.fetch('SOURCE_COMMIT', nil)
|
||||
end
|
||||
|
||||
def user_agent
|
||||
@user_agent ||= "Mastodon/#{Version} (#{HTTP::Request::USER_AGENT}; +http#{Rails.configuration.x.use_https ? 's' : ''}://#{Rails.configuration.x.web_domain}/)"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue