Skip to content

Commit

Permalink
Merge branch 'main' into tail-based-sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
yurishkuro authored Aug 31, 2024
2 parents 9fa0de4 + 9a2921a commit 44eb90e
Show file tree
Hide file tree
Showing 60 changed files with 726 additions and 381 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-lint-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
with:
go-version: 1.23.x

- name: Print Jaeger version
run: make echo-version
- name: Print Jaeger version for no reason
run: make echo-v1 echo-v2

- name: Install tools
run: make install-test-tools
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci-lint-dependabot-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
paths:
- '.github/dependabot.yml'
- '.github/workflows/validate-dependabot-config.yml'

# See https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
permissions:
contents: read

jobs:
validate:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ jobs:
# Many scripts depend on BRANCH variable. We do not want to
# use ./.github/actions/setup-branch here because it may set
# BRANCH=main when the workflow is triggered manually.
#
# TODO this currently utilizes 1.x version tag
run: |
BRANCH=$(make echo-version)
BRANCH=$(make echo-v1)
echo "BRANCH=${BRANCH}" >> ${GITHUB_ENV}
echo Validate that the latest tag ${BRANCH} is in semver format
echo ${BRANCH} | grep -E '^v[0-9]+.[0-9]+.[0-9]+$'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11
uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5
with:
sarif_file: results.sarif
111 changes: 21 additions & 90 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,37 +76,27 @@ FMT_LOG=.fmt.log
IMPORT_LOG=.import.log
COLORIZE ?= | $(SED) 's/PASS/✅ PASS/g' | $(SED) 's/FAIL/❌ FAIL/g' | $(SED) 's/SKIP/🔕 SKIP/g'

GIT_SHA=$(shell git rev-parse HEAD)
GIT_SHALLOW_CLONE := $(shell git rev-parse --is-shallow-repository)
# Some of GitHub Actions workflows do a shallow checkout without tags. This avoids logging warnings from git.
GIT_CLOSEST_TAG=$(shell if [ "$(GIT_SHALLOW_CLONE)" = "false" ]; then git describe --abbrev=0 --tags; else echo 0.0.0; fi)
ifneq ($(GIT_CLOSEST_TAG),$(shell echo ${GIT_CLOSEST_TAG} | grep -E "$(semver_regex)"))
$(warning GIT_CLOSEST_TAG=$(GIT_CLOSEST_TAG) is not in the semver format $(semver_regex))
endif
GIT_CLOSEST_TAG_MAJOR := $(shell echo $(GIT_CLOSEST_TAG) | $(SED) -n 's/v\([0-9]*\)\.[0-9]*\.[0-9]/\1/p')
GIT_CLOSEST_TAG_MINOR := $(shell echo $(GIT_CLOSEST_TAG) | $(SED) -n 's/v[0-9]*\.\([0-9]*\)\.[0-9]/\1/p')
GIT_CLOSEST_TAG_PATCH := $(shell echo $(GIT_CLOSEST_TAG) | $(SED) -n 's/v[0-9]*\.[0-9]*\.\([0-9]\)/\1/p')
DATE=$(shell TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%dT%H:%M:%SZ' --format="%cd")
BUILD_INFO_IMPORT_PATH=$(JAEGER_IMPORT_PATH)/pkg/version
BUILD_INFO=-ldflags "-X $(BUILD_INFO_IMPORT_PATH).commitSHA=$(GIT_SHA) -X $(BUILD_INFO_IMPORT_PATH).latestVersion=$(GIT_CLOSEST_TAG) -X $(BUILD_INFO_IMPORT_PATH).date=$(DATE)"

SYSOFILE=resource.syso

# import other Makefiles after the variables are defined
include Makefile.Tools.mk
include docker/Makefile
include Makefile.BuildInfo.mk
include Makefile.Crossdock.mk
include Makefile.Protobuf.mk
include Makefile.Thrift.mk
include Makefile.Crossdock.mk
include Makefile.Tools.mk
include Makefile.Windows.mk

.DEFAULT_GOAL := test-and-lint

.PHONY: test-and-lint
test-and-lint: test fmt lint

.PHONY: echo-version
echo-version:
@echo "$(GIT_CLOSEST_TAG)"
.PHONY: echo-v1
echo-v1:
@echo "$(GIT_CLOSEST_TAG_V1)"

.PHONY: echo-v2
echo-v2:
@echo "$(GIT_CLOSEST_TAG_V2)"

.PHONY: echo-all-pkgs
echo-all-pkgs:
Expand Down Expand Up @@ -237,23 +227,23 @@ build-tracegen:

.PHONY: build-anonymizer
build-anonymizer:
$(GOBUILD) $(BUILD_INFO) -o ./cmd/anonymizer/anonymizer-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/anonymizer/
$(GOBUILD) $(BUILD_INFO) -o ./cmd/anonymizer/anonymizer-$(GOOS)-$(GOARCH) ./cmd/anonymizer/

.PHONY: build-esmapping-generator
build-esmapping-generator:
$(GOBUILD) -o ./plugin/storage/es/esmapping-generator-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/esmapping-generator/
$(GOBUILD) $(BUILD_INFO) -o ./plugin/storage/es/esmapping-generator-$(GOOS)-$(GOARCH) ./cmd/esmapping-generator/

.PHONY: build-esmapping-generator-linux
build-esmapping-generator-linux:
GOOS=linux GOARCH=amd64 $(GOBUILD) -o ./plugin/storage/es/esmapping-generator $(BUILD_INFO) ./cmd/esmapping-generator/
GOOS=linux $(BUILD_INFO) GOARCH=amd64 $(GOBUILD) -o ./plugin/storage/es/esmapping-generator ./cmd/esmapping-generator/

.PHONY: build-es-index-cleaner
build-es-index-cleaner:
$(GOBUILD) -o ./cmd/es-index-cleaner/es-index-cleaner-$(GOOS)-$(GOARCH) ./cmd/es-index-cleaner/
$(GOBUILD) $(BUILD_INFO) -o ./cmd/es-index-cleaner/es-index-cleaner-$(GOOS)-$(GOARCH) ./cmd/es-index-cleaner/

.PHONY: build-es-rollover
build-es-rollover:
$(GOBUILD) -o ./cmd/es-rollover/es-rollover-$(GOOS)-$(GOARCH) ./cmd/es-rollover/
$(GOBUILD) $(BUILD_INFO) -o ./cmd/es-rollover/es-rollover-$(GOOS)-$(GOARCH) ./cmd/es-rollover/

.PHONY: docker-hotrod
docker-hotrod:
Expand Down Expand Up @@ -298,6 +288,7 @@ _build-a-binary-%:
.PHONY: build-jaeger
build-jaeger: BIN_NAME = jaeger
build-jaeger: GO_TAGS = -tags ui
build-jaeger: BUILD_INFO = $(BUILD_INFO_V2)
build-jaeger: build-ui _build-a-binary-jaeger$(SUFFIX)-$(GOOS)-$(GOARCH)

.PHONY: build-all-in-one
Expand Down Expand Up @@ -326,79 +317,19 @@ build-ingester: _build-a-binary-ingester$(SUFFIX)-$(GOOS)-$(GOARCH)
build-remote-storage: BIN_NAME = remote-storage
build-remote-storage: _build-a-binary-remote-storage$(SUFFIX)-$(GOOS)-$(GOARCH)

# Magic values:
# - LangID "0409" is "US-English".
# - CharsetID "04B0" translates to decimal 1200 for "Unicode".
# - FileOS "040004" defines the Windows kernel "Windows NT".
# - FileType "01" is "Application".
define VERSIONINFO
{
"FixedFileInfo": {
"FileVersion": {
"Major": $(GIT_CLOSEST_TAG_MAJOR),
"Minor": $(GIT_CLOSEST_TAG_MINOR),
"Patch": $(GIT_CLOSEST_TAG_PATCH),
"Build": 0
},
"ProductVersion": {
"Major": $(GIT_CLOSEST_TAG_MAJOR),
"Minor": $(GIT_CLOSEST_TAG_MINOR),
"Patch": $(GIT_CLOSEST_TAG_PATCH),
"Build": 0
},
"FileFlagsMask": "3f",
"FileFlags ": "00",
"FileOS": "040004",
"FileType": "01",
"FileSubType": "00"
},
"StringFileInfo": {
"FileDescription": "$(NAME)",
"FileVersion": "$(GIT_CLOSEST_TAG_MAJOR).$(GIT_CLOSEST_TAG_MINOR).$(GIT_CLOSEST_TAG_PATCH).0",
"LegalCopyright": "2015-2023 The Jaeger Project Authors",
"ProductName": "$(NAME)",
"ProductVersion": "$(GIT_CLOSEST_TAG_MAJOR).$(GIT_CLOSEST_TAG_MINOR).$(GIT_CLOSEST_TAG_PATCH).0"
},
"VarFileInfo": {
"Translation": {
"LangID": "0409",
"CharsetID": "04B0"
}
}
}
endef

export VERSIONINFO

.PHONY: _prepare-winres
_prepare-winres:
$(MAKE) _prepare-winres-helper NAME="Jaeger Agent" PKGPATH="cmd/agent"
$(MAKE) _prepare-winres-helper NAME="Jaeger Collector" PKGPATH="cmd/collector"
$(MAKE) _prepare-winres-helper NAME="Jaeger Query" PKGPATH="cmd/query"
$(MAKE) _prepare-winres-helper NAME="Jaeger Ingester" PKGPATH="cmd/ingester"
$(MAKE) _prepare-winres-helper NAME="Jaeger Remote Storage" PKGPATH="cmd/remote-storage"
$(MAKE) _prepare-winres-helper NAME="Jaeger All-In-One" PKGPATH="cmd/all-in-one"
$(MAKE) _prepare-winres-helper NAME="Jaeger V2" PKGPATH="cmd/jaeger"
$(MAKE) _prepare-winres-helper NAME="Jaeger Tracegen" PKGPATH="cmd/tracegen"
$(MAKE) _prepare-winres-helper NAME="Jaeger Anonymizer" PKGPATH="cmd/anonymizer"
$(MAKE) _prepare-winres-helper NAME="Jaeger ES-Index-Cleaner" PKGPATH="cmd/es-index-cleaner"
$(MAKE) _prepare-winres-helper NAME="Jaeger ES-Rollover" PKGPATH="cmd/es-rollover"

.PHONY: _prepare-winres-helper
_prepare-winres-helper:
echo $$VERSIONINFO | $(GOVERSIONINFO) -o="$(PKGPATH)/$(SYSOFILE)" -

.PHONY: build-binaries-linux
build-binaries-linux: build-binaries-amd64

.PHONY: build-binaries-amd64
build-binaries-amd64:
GOOS=linux GOARCH=amd64 $(MAKE) _build-platform-binaries

# helper targets defined in Makefile.Windows.mk
.PHONY: build-binaries-windows
build-binaries-windows: _prepare-winres
build-binaries-windows:
$(MAKE) _build-syso
GOOS=windows GOARCH=amd64 $(MAKE) _build-platform-binaries
rm ./cmd/*/$(SYSOFILE)
$(MAKE) _clean-syso

.PHONY: build-binaries-darwin
build-binaries-darwin:
Expand Down
20 changes: 20 additions & 0 deletions Makefile.BuildInfo.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2023 The Jaeger Authors.
# SPDX-License-Identifier: Apache-2.0

GIT_SHA=$(shell git rev-parse HEAD)
DATE=$(shell TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%dT%H:%M:%SZ' --format="%cd")
# Defer evaluation of semver tags until actually needed, using trick from StackOverflow:
# https://stackoverflow.com/questions/44114466/how-to-declare-a-deferred-variable-that-is-computed-only-once-for-all
GIT_CLOSEST_TAG_V1 = $(eval GIT_CLOSEST_TAG_V1 := $(shell scripts/compute-version.sh v1))$(GIT_CLOSEST_TAG_V1)
GIT_CLOSEST_TAG_V2 = $(eval GIT_CLOSEST_TAG_V2 := $(shell scripts/compute-version.sh v2))$(GIT_CLOSEST_TAG_V2)

# args: (1) - name, (2) - value
define buildinfo
$(JAEGER_IMPORT_PATH)/pkg/version.$(1)=$(2)
endef
# args (1) - V1|V2
define buildinfoflags
-ldflags "-X $(call buildinfo,commitSHA,$(GIT_SHA)) -X $(call buildinfo,latestVersion,$(GIT_CLOSEST_TAG_$(1))) -X $(call buildinfo,date,$(DATE))"
endef
BUILD_INFO=$(call buildinfoflags,V1)
BUILD_INFO_V2=$(call buildinfoflags,V2)
7 changes: 2 additions & 5 deletions Makefile.Tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ install-tools: $(TOOLS_BIN_NAMES)
.PHONY: install-test-tools
install-test-tools: $(LINT) $(GOFUMPT)

.PHONY: install-build-tools
install-build-tools: $(GOVERSIONINFO)

.PHONY: install-ci
install-ci: install-test-tools install-build-tools
install-ci: install-test-tools

list-internal-tools:
@echo Third party tool modules:
Expand All @@ -35,5 +32,5 @@ list-internal-tools:
$(TOOLS_BIN_DIR):
mkdir -p $@

$(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
$(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum
cd $(TOOLS_MOD_DIR) && $(GO) build -o $@ -trimpath $(shell echo $(TOOLS_PKG_NAMES) | tr ' ' '\n' | grep $(notdir $@))
82 changes: 82 additions & 0 deletions Makefile.Windows.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright (c) 2024 The Jaeger Authors.
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

SYSOFILE=resource.syso

# Magic values:
# - LangID "0409" is "US-English".
# - CharsetID "04B0" translates to decimal 1200 for "Unicode".
# - FileOS "040004" defines the Windows kernel "Windows NT".
# - FileType "01" is "Application".
# https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
define VERSIONINFO
{
"FixedFileInfo": {
"FileVersion": {
"Major": $(SEMVER_MAJOR),
"Minor": $(SEMVER_MINOR),
"Patch": $(SEMVER_PATCH),
"Build": 0
},
"ProductVersion": {
"Major": $(SEMVER_MAJOR),
"Minor": $(SEMVER_MINOR),
"Patch": $(SEMVER_PATCH),
"Build": 0
},
"FileFlagsMask": "3f",
"FileFlags ": "00",
"FileOS": "040004",
"FileType": "01",
"FileSubType": "00"
},
"StringFileInfo": {
"FileDescription": "$(NAME)",
"FileVersion": "$(SEMVER_MAJOR).$(SEMVER_MINOR).$(SEMVER_PATCH).0",
"LegalCopyright": "2015-2024 The Jaeger Project Authors",
"ProductName": "$(NAME)",
"ProductVersion": "$(SEMVER_MAJOR).$(SEMVER_MINOR).$(SEMVER_PATCH).0"
},
"VarFileInfo": {
"Translation": {
"LangID": "0409",
"CharsetID": "04B0"
}
}
}
endef

export VERSIONINFO

.PHONY: _build_syso_once
_build_syso_once:
echo $$VERSIONINFO
echo $$VERSIONINFO | $(GOVERSIONINFO) -o="$(PKGPATH)/$(SYSOFILE)" -

define _build_syso_macro
$(MAKE) _build_syso_once NAME="$(1)" PKGPATH="$(2)" SEMVER_MAJOR=$(SEMVER_MAJOR) SEMVER_MINOR=$(SEMVER_MINOR) SEMVER_PATCH=$(SEMVER_PATCH)
endef

.PHONY: _build-syso
_build-syso: $(GOVERSIONINFO)
$(eval SEMVER_ALL := $(shell scripts/compute-version.sh -s v1))
$(eval SEMVER_MAJOR := $(word 2, $(SEMVER_ALL)))
$(eval SEMVER_MINOR := $(word 3, $(SEMVER_ALL)))
$(eval SEMVER_PATCH := $(word 4, $(SEMVER_ALL)))
$(call _build_syso_macro,Jaeger Agent,cmd/agent)
$(call _build_syso_macro,Jaeger Collector,cmd/collector)
$(call _build_syso_macro,Jaeger Query,cmd/query)
$(call _build_syso_macro,Jaeger Ingester,cmd/ingester)
$(call _build_syso_macro,Jaeger Remote Storage,cmd/remote-storage)
$(call _build_syso_macro,Jaeger All-In-One,cmd/all-in-one)
$(call _build_syso_macro,Jaeger Tracegen,cmd/tracegen)
$(call _build_syso_macro,Jaeger Anonymizer,cmd/anonymizer)
$(call _build_syso_macro,Jaeger ES-Index-Cleaner,cmd/es-index-cleaner)
$(call _build_syso_macro,Jaeger ES-Rollover,cmd/es-rollover)
# TODO in the future this should be in v2
$(call _build_syso_macro,Jaeger V2,cmd/jaeger)

.PHONY: _clean-syso
_clean-syso:
rm ./cmd/*/$(SYSOFILE)
14 changes: 11 additions & 3 deletions cmd/collector/app/handler/otlp_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

otlp2jaeger "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componentstatus"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/configtls"
Expand Down Expand Up @@ -61,7 +62,7 @@ func startOTLPReceiver(
otlpReceiverConfig := otlpFactory.CreateDefaultConfig().(*otlpreceiver.Config)
applyGRPCSettings(otlpReceiverConfig.GRPC, &options.OTLP.GRPC)
applyHTTPSettings(otlpReceiverConfig.HTTP.ServerConfig, &options.OTLP.HTTP)
statusReporter := func(ev *component.StatusEvent) {
statusReporter := func(ev *componentstatus.Event) {
// TODO this could be wired into changing healthcheck.HealthCheck
logger.Info("OTLP receiver status change", zap.Stringer("status", ev.Status()))
}
Expand All @@ -70,7 +71,6 @@ func startOTLPReceiver(
Logger: logger,
TracerProvider: nooptrace.NewTracerProvider(),
MeterProvider: noopmetric.NewMeterProvider(), // TODO wire this with jaegerlib metrics?
ReportStatus: statusReporter,
},
}

Expand All @@ -89,7 +89,7 @@ func startOTLPReceiver(
if err != nil {
return nil, fmt.Errorf("could not create the OTLP receiver: %w", err)
}
if err := otlpReceiver.Start(context.Background(), &otelHost{logger: logger}); err != nil {
if err := otlpReceiver.Start(context.Background(), &otelHost{logger: logger, reportFunc: statusReporter}); err != nil {
return nil, fmt.Errorf("could not start the OTLP receiver: %w", err)
}
return otlpReceiver, nil
Expand Down Expand Up @@ -173,9 +173,13 @@ func (c *consumerDelegate) consume(ctx context.Context, td ptrace.Traces) error
return nil
}

var _ componentstatus.Reporter = (*otelHost)(nil)

// otelHost is a mostly no-op implementation of OTEL component.Host
type otelHost struct {
logger *zap.Logger

reportFunc func(event *componentstatus.Event)
}

func (h *otelHost) ReportFatalError(err error) {
Expand All @@ -193,3 +197,7 @@ func (*otelHost) GetExtensions() map[component.ID]extension.Extension {
func (*otelHost) GetExporters() map[component.DataType]map[component.ID]component.Component {
return nil
}

func (h *otelHost) Report(event *componentstatus.Event) {
h.reportFunc(event)
}
Loading

0 comments on commit 44eb90e

Please sign in to comment.