Skip to content

Provides information about a service (name, version and git commit) that is currently running in the container

License

Notifications You must be signed in to change notification settings

dentech-floss/revision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

revision

Provides information about the service (name, version and git commit) that is currently running in the container. This is based on these three env vars that shall be set in the Dockerfile:

ARG SERVICE_NAME
ENV SERVICE_NAME=$SERVICE_NAME
ARG SERVICE_VERSION
ENV SERVICE_VERSION=$SERVICE_VERSION
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT

So ensure that they are provided as build args in the build pipeline, for example:

env:
  DEPLOYMENT_NAME: appointment-service

...

docker build \
--tag "gcr.io/$PROJECT_ID/$IMAGE:${GITHUB_REF:10}" \
--build-arg SERVICE_NAME="$DEPLOYMENT_NAME" \
--build-arg SERVICE_VERSION="${GITHUB_REF:10}" \
--build-arg GIT_COMMIT="$GITHUB_SHA" \
--file=docker/Dockerfile \
.

Install

go get github.com/dentech-floss/[email protected]

Usage

package example

import (
    "github.com/dentech-floss/metadata/pkg/metadata"
    "github.com/dentech-floss/revision/pkg/revision"
    "github.com/dentech-floss/telemetry/pkg/telemetry"
)

func main() {

    metadata := metadata.NewMetadata()

    shutdownTracing := telemetry.SetupTracing(
        ctx,
        &telemetry.TracingConfig{
            ServiceName:           revision.ServiceName,
            ServiceVersion:        revision.ServiceVersion,
            DeploymentEnvironment: metadata.ProjectID,
            OtlpExporterEnabled:   metadata.OnGCP,
        },
    )
    defer shutdownTracing()
}

About

Provides information about a service (name, version and git commit) that is currently running in the container

Topics

Resources

License

Stars

Watchers

Forks