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

Diff between main and swo #2

Closed
wants to merge 82 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
86b9b1e
Used the collector-contrib component
jerrytfleung Nov 3, 2023
85bc31f
Sync dependencies
jerrytfleung Nov 3, 2023
4a07d4c
Added back resourcedetectionprocessor
jerrytfleung Nov 3, 2023
8a86ca8
Updated
jerrytfleung Nov 3, 2023
d666685
Added compatibile-runtimes in Makefile
jerrytfleung Nov 28, 2023
922a479
Updated go package
jerrytfleung Nov 29, 2023
00a8912
Revert
jerrytfleung Nov 29, 2023
8dbf0e5
Revert
jerrytfleung Nov 29, 2023
6258c3f
Updated
jerrytfleung Nov 29, 2023
bd42fcd
Updated Makefile
jerrytfleung Nov 30, 2023
48a48cc
Updated
jerrytfleung Dec 13, 2023
8e96926
Updated dependency
jerrytfleung Dec 13, 2023
3ef830a
Updated Makefile
jerrytfleung Dec 14, 2023
9c6f6a5
Updated default config
jerrytfleung Jan 9, 2024
7802378
After go mod tidy
jerrytfleung Jan 9, 2024
03e379d
go mod tidy
jerrytfleung Jan 9, 2024
f007eab
Not exposing interval environment variables
jerrytfleung Jan 18, 2024
6133039
Updated collector
jerrytfleung Jan 22, 2024
98263bc
Added resourceprocessor config
jerrytfleung Jan 22, 2024
ceeb4b4
Removed Batch and decouple
jerrytfleung Jan 22, 2024
47a623e
Updated config.yaml
jerrytfleung Jan 22, 2024
d7e6b93
Changed timeout
jerrytfleung Jan 22, 2024
dad0163
go mod tidy
jerrytfleung Jan 23, 2024
18c70a6
Revert decouple
jerrytfleung Jan 23, 2024
369d608
Took out batch processor
jerrytfleung Jan 26, 2024
614bebb
Upgrade solarwindsapmsettingsextension
jerrytfleung Jan 26, 2024
56192d8
Merge branch 'main' into swo
jerrytfleung Jan 27, 2024
f3c4e89
Sync to main
jerrytfleung Jan 27, 2024
5b9ab77
Re-enabled resourcedetectionprocessor
jerrytfleung Jan 27, 2024
f83d11f
opentelemetry-lambda doesn't work with the recent change of collector…
jerrytfleung Jan 27, 2024
1b05511
Updated
jerrytfleung Jan 27, 2024
dabf87a
Updated
jerrytfleung Jan 27, 2024
4dcf58f
Updated
jerrytfleung Jan 27, 2024
6dde583
Do refresh in start
jerrytfleung Jan 27, 2024
4af28c6
Updated
jerrytfleung Jan 29, 2024
248d562
Adjusted context deadline
jerrytfleung Jan 29, 2024
2df7246
Updated
jerrytfleung Jan 29, 2024
1b3b854
Trigger action
jerrytfleung Feb 1, 2024
690ee9c
Tried
jerrytfleung Feb 5, 2024
a1b187a
Merge branch 'solarwinds:swo' into swo
jerrytfleung Feb 5, 2024
33add6c
Revert
jerrytfleung Feb 6, 2024
db087ef
Added github actions
jerrytfleung Feb 6, 2024
6953838
Merge branch 'solarwinds:swo' into swo
jerrytfleung Feb 6, 2024
c654521
Revert
jerrytfleung Feb 6, 2024
e4637f8
Merge pull request #4 from jerrytfleung/swo
jerrytfleung Feb 6, 2024
79675a2
Merge branch 'main' into swo
jerrytfleung Feb 14, 2024
a84c2e3
Change default log level and change verbosity to an env variable
jerrytfleung Feb 14, 2024
dbde37f
Merge pull request #5 from solarwinds/NH-72987
jerrytfleung Feb 15, 2024
20d9384
Remove logging from pipeleine
jerrytfleung Feb 15, 2024
8a6c598
Merge pull request #6 from solarwinds/NH-72987-path1
jerrytfleung Feb 15, 2024
2d2728e
lambda
jerrytfleung Feb 21, 2024
b855ba2
Merge pull request #7 from solarwinds/lambda
jerrytfleung Feb 21, 2024
d39d7c5
Fixed the zap logger always use info as default
jerrytfleung Feb 22, 2024
b42394b
nits
jerrytfleung Feb 22, 2024
77ce861
Merge pull request #8 from solarwinds/zap_logger_default
jerrytfleung Feb 22, 2024
bf29b36
Updated
jerrytfleung Mar 1, 2024
4e42234
Merge pull request #9 from solarwinds/NH-73899
jerrytfleung Mar 1, 2024
d67dd3d
Added logging
jerrytfleung Mar 4, 2024
000b116
Merge pull request #10 from solarwinds/logging_exporter
jerrytfleung Mar 4, 2024
16ec1d2
Renaming amd64 to x86_64
jerrytfleung Mar 5, 2024
b6800ac
Merge pull request #11 from solarwinds/renaming_amd64_to_x86_64
jerrytfleung Mar 5, 2024
813a420
Need to rename the artifact from amd64 to x86_64 to meet GHA workflow…
jerrytfleung Mar 6, 2024
629f8aa
Merge pull request #12 from solarwinds/NH-74565
jerrytfleung Mar 6, 2024
7bd1ade
Revert "Change to sw.cloud.aws.resource.type"
cheempz Mar 13, 2024
ae3544e
Merge pull request #13 from solarwinds/revert-7-lambda
cheempz Mar 13, 2024
69c7932
Merge branch 'swo' into prepare_to_merge
jerrytfleung May 13, 2024
5fa3909
Merge pull request #15 from solarwinds/prepare_to_merge
jerrytfleung May 13, 2024
16e0968
Fixed go modules
jerrytfleung May 13, 2024
957f709
go mod tidy
jerrytfleung May 13, 2024
e638397
Regenerate doc.go
jerrytfleung May 13, 2024
86bfc3f
Merge pull request #16 from solarwinds/swo-after-merge-fix
jerrytfleung May 13, 2024
7f1c996
updated
jerrytfleung May 13, 2024
645a491
nits
jerrytfleung May 13, 2024
9546947
shadow declaration
jerrytfleung May 14, 2024
35650ed
Merge pull request #17 from solarwinds/swo-applied-PR-comment-from-co…
jerrytfleung May 14, 2024
bf40974
NH-76996 Otelcol: collecting Lambda function logs (#18)
jerrytfleung May 16, 2024
f61490b
NH-80074 Otelcol: Add lambda distro version to resource attribute (#19)
jerrytfleung May 17, 2024
b2522af
Fixed the single quote issue (#20)
jerrytfleung May 17, 2024
7ce6cae
Removed support of raw file (#22)
jerrytfleung May 23, 2024
15390d0
NH-76996 Otelcol: collecting Lambda function logs (code refactoring) …
jerrytfleung May 29, 2024
00cd03b
NH-76996 - Disabled platform events log processing (#25)
jerrytfleung Jun 5, 2024
81a6178
Merge branch 'main' into swo
jerrytfleung Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/layer-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:

- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.PROD_LAMBDA_ROLE_ARN }}
role-to-assume: ${{ inputs.release-group == 'prod' && secrets.PROD_LAMBDA_ROLE_ARN || secrets.STAGING_LAMBDA_ROLE_ARN }}
role-duration-seconds: 1200
aws-region: ${{ inputs.aws_region }}
mask-aws-account-id: false
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/release-layer-collector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
architecture:
- amd64
- x86_64
- arm64
outputs:
COLLECTOR_VERSION: ${{ steps.save-collector-version.outputs.COLLECTOR_VERSION }}
Expand All @@ -25,14 +25,20 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: '^1.21.9'
- name: set version to the default config.yaml
run: |
version=$(echo ${{ github.ref_name }} | awk -F'/' {'print $2'})
sed -i "s/0.0.0-dev/$version/g" collector/config.yaml
- name: cat collector/config.yaml
run: cat collector/config.yaml
- name: build
run: make -C collector package GOARCH=${{ matrix.architecture }}
run: make -C collector package GOARCH=${{ matrix.architecture == 'x86_64' && 'amd64' || 'arm64' }}
- uses: actions/upload-artifact@v4
with:
name: opentelemetry-collector-layer-${{ matrix.architecture }}.zip
path: ${{ github.workspace }}/collector/build/opentelemetry-collector-layer-${{ matrix.architecture }}.zip
- name: Save Collector Version
if: ${{ matrix.architecture == 'amd64' }}
if: ${{ matrix.architecture == 'x86_64' }}
id: save-collector-version
shell: bash
# `./collector -v` output is in the form `v0.75.0`
Expand All @@ -46,7 +52,7 @@ jobs:
strategy:
matrix:
architecture:
- amd64
- x86_64
- arm64
aws_region:
- ap-northeast-1
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/release-layer-staging-collector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: "Release Staging Collector Lambda layer"

on:
# (Using tag push instead of release to allow filtering by tag prefix.)
push:
tags:
- layer-staging-collector/**

permissions:
id-token: write
contents: read

jobs:
build-layer:
runs-on: ubuntu-latest
strategy:
matrix:
architecture:
- x86_64
- arm64
outputs:
COLLECTOR_VERSION: ${{ steps.save-collector-version.outputs.COLLECTOR_VERSION }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '^1.21.9'
- name: set version to the default config.yaml
run: |
version=$(echo ${{ github.ref_name }} | awk -F'/' {'print $2'})
sed -i "s/0.0.0-dev/$version/g" collector/config.yaml
- name: cat collector/config.yaml
run: cat collector/config.yaml
- name: build
run: make -C collector package GOARCH=${{ matrix.architecture == 'x86_64' && 'amd64' || 'arm64' }}
- uses: actions/upload-artifact@v4
with:
name: opentelemetry-collector-layer-${{ matrix.architecture }}.zip
path: ${{ github.workspace }}/collector/build/opentelemetry-collector-layer-${{ matrix.architecture }}.zip
- name: Save Collector Version
if: ${{ matrix.architecture == 'x86_64' }}
id: save-collector-version
shell: bash
# `./collector -v` output is in the form `v0.75.0`
run: |
COLLECTOR_VERSION=$( ${{ github.workspace }}/collector/build/extensions/collector -v)
echo "COLLECTOR_VERSION=$COLLECTOR_VERSION" >> $GITHUB_OUTPUT

publish-layer:
uses: ./.github/workflows/layer-publish.yml
needs: build-layer
strategy:
matrix:
architecture:
- x86_64
- arm64
aws_region:
- ap-northeast-1
- ap-northeast-2
- ap-south-1
- ap-southeast-1
- ap-southeast-2
- ca-central-1
- eu-central-1
- eu-north-1
- eu-west-1
- eu-west-2
- eu-west-3
- sa-east-1
- us-east-1
- us-east-2
- us-west-1
- us-west-2
with:
artifact-name: opentelemetry-collector-layer-${{ matrix.architecture }}.zip
layer-name: opentelemetry-collector
component-version: ${{needs.build-layer.outputs.COLLECTOR_VERSION}}
architecture: ${{ matrix.architecture }}
release-group: staging
aws_region: ${{ matrix.aws_region }}
secrets: inherit
13 changes: 10 additions & 3 deletions collector/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ LAYER_NAME:=otel-collector
VERSION=$(shell cat VERSION)
GIT_SHA=$(shell git rev-parse HEAD)
GOARCH ?= amd64

ifeq ($(GOARCH), amd64)
ARCH=x86_64
else
ARCH=$(GOARCH)
endif

GOBUILD=GO111MODULE=on CGO_ENABLED=0 installsuffix=cgo go build -trimpath
BUILD_INFO_IMPORT_PATH=main

Expand Down Expand Up @@ -44,16 +51,16 @@ package: build
@echo Package zip file for collector extension layer
mkdir -p $(BUILD_SPACE)/collector-config
cp config* $(BUILD_SPACE)/collector-config
cd $(BUILD_SPACE) && zip -r opentelemetry-collector-layer-$(GOARCH).zip collector-config extensions
cd $(BUILD_SPACE) && zip -r opentelemetry-collector-layer-$(ARCH).zip collector-config extensions

.PHONY: publish
publish:
aws lambda publish-layer-version --layer-name $(LAYER_NAME) --zip-file fileb://$(BUILD_SPACE)/opentelemetry-collector-layer-$(GOARCH).zip --compatible-runtimes nodejs14.x nodejs16.x nodejs18.x java11 python3.8 python3.9 python3.10 python3.11 --query 'LayerVersionArn' --output text
aws lambda publish-layer-version --layer-name $(LAYER_NAME) --zip-file fileb://$(BUILD_SPACE)/opentelemetry-collector-layer-$(ARCH).zip --compatible-runtimes nodejs14.x nodejs16.x nodejs18.x java11 python3.8 python3.9 python3.10 python3.11 --compatible-architectures $(ARCH) --query 'LayerVersionArn' --output text

.PHONY: publish-layer
publish-layer: package
@echo Publishing collector extension layer...
aws lambda publish-layer-version --layer-name $(LAYER_NAME) --zip-file fileb://$(BUILD_SPACE)/opentelemetry-collector-layer-$(GOARCH).zip --compatible-runtimes nodejs14.x nodejs16.x nodejs18.x java11 python3.8 python3.9 python3.10 python3.11 --query 'LayerVersionArn' --output text
aws lambda publish-layer-version --layer-name $(LAYER_NAME) --zip-file fileb://$(BUILD_SPACE)/opentelemetry-collector-layer-$(ARCH).zip --compatible-runtimes nodejs14.x nodejs16.x nodejs18.x java11 python3.8 python3.9 python3.10 python3.11 --compatible-architectures $(ARCH) --query 'LayerVersionArn' --output text
@echo OpenTelemetry Collector layer published.

.PHONY: gotidy
Expand Down
41 changes: 38 additions & 3 deletions collector/config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
extensions:
solarwindsapmsettings:
endpoint: "apm.collector.${SW_APM_DATA_CENTER}.cloud.solarwinds.com:443"
key: "${SW_APM_API_TOKEN}:${OTEL_SERVICE_NAME}"

receivers:
otlp:
protocols:
grpc:
endpoint: "localhost:4317"
http:
endpoint: "localhost:4318"
telemetryapi:

processors:
decouple:
resourcedetection:
detectors: [env, system, lambda]
timeout: 0.2s
override: false
resource:
attributes:
- key: sw.cloud.aws.resource.type
value: "Lambda"
action: upsert
- key: sw.apm.otelcol.version
value: "0.0.0-dev"
action: upsert
- key: sw.data.module
value: "apm"
action: upsert

exporters:
logging:
loglevel: debug
verbosity: detailed
otlp:
endpoint: "https://otel.collector.${SW_APM_DATA_CENTER}.cloud.solarwinds.com:443"
headers:
Authorization: "Bearer ${SW_APM_API_TOKEN}"

service:
extensions: [solarwindsapmsettings]
pipelines:
traces:
receivers: [otlp]
exporters: [logging]
processors: [resource,resourcedetection,decouple]
exporters: [otlp,logging]
metrics:
receivers: [otlp]
exporters: [logging]
processors: [resource,resourcedetection,decouple]
exporters: [otlp,logging]
# logs:
# receivers: [otlp,telemetryapi]
# processors: [resource,resourcedetection,decouple]
# exporters: [otlp,logging]
telemetry:
metrics:
address: localhost:8888
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
44 changes: 44 additions & 0 deletions collector/extension/solarwindsapmsettingsextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Solarwinds APM Settings extension

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [development] |
| Distributions | [] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aextension%2Fsolarwindsapmsettings%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aextension%2Fsolarwindsapmsettings) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aextension%2Fsolarwindsapmsettings%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aextension%2Fsolarwindsapmsettings) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@jerrytfleung](https://www.github.com/jerrytfleung), [@cheempz](https://www.github.com/cheempz) |

[development]: https://github.com/open-telemetry/opentelemetry-collector#development
<!-- end autogenerated section -->

## Overview
The Solarwinds APM Settings extension gets Solarwinds APM specific settings from Solarwinds APM collector and `/tmp/solarwinds-apm-settings.json` periodically.

## Configuration

Example:

```yaml
extensions:
solarwindsapmsettings:
endpoint: "<endpoint>"
key: "<token>:<name>"
interval: 10s
```

### endpoint (Required)
The APM collector endpoint which this extension calls `getSettings`. See [here](https://documentation.solarwinds.com/en/success_center/observability/content/system_requirements/endpoints.htm) for our APM collector endpoints. The endpoint is in format `<host>:<port>`.

### key (Required)
The service key in format `<token>:<name>` for `getSettings` from Solarwinds APM collector. See [here](https://documentation.solarwinds.com/en/success_center/observability/content/configure/configure-services.htm) for configuring a service key.

### interval (Optional)
Periodic interval to get Solarwinds APM specific settings from Solarwinds APM collector.

Minimum value: `5s`

Maximum value: `60s`

Value that is outside the boundary will be bounded to either the minimum or maximum value.

Default: `10s`
67 changes: 67 additions & 0 deletions collector/extension/solarwindsapmsettingsextension/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package solarwindsapmsettingsextension

import (
"os"
"regexp"
"strings"
"time"

"go.opentelemetry.io/collector/component"
)

type Config struct {
Endpoint string `mapstructure:"endpoint"`
Key string `mapstructure:"key"`
Interval time.Duration `mapstructure:"interval"`
}

const (
DefaultEndpoint = "apm.collector.na-01.cloud.solarwinds.com:443"
DefaultInterval = time.Duration(10) * time.Second
MinimumInterval = time.Duration(5) * time.Second
MaximumInterval = time.Duration(60) * time.Second
)

func createDefaultConfig() component.Config {
return &Config{
Endpoint: DefaultEndpoint,
Interval: DefaultInterval,
}
}

func (cfg *Config) Validate() error {
// Endpoint
matched, _ := regexp.MatchString(`apm.collector.[a-z]{2,3}-[0-9]{2}.[a-z\-]*.solarwinds.com:443`, cfg.Endpoint)
if !matched {
// Replaced by the default
cfg.Endpoint = DefaultEndpoint
}
// Key
keyArr := strings.Split(cfg.Key, ":")
if len(keyArr) == 2 && len(keyArr[1]) == 0 {
/**
* Service name is empty. We are trying our best effort to resolve the service name
*/
serviceName := resolveServiceNameBestEffort()
if len(serviceName) > 0 {
cfg.Key = keyArr[0] + ":" + serviceName
}
}
// Interval
if cfg.Interval.Seconds() < MinimumInterval.Seconds() {
cfg.Interval = MinimumInterval
}
if cfg.Interval.Seconds() > MaximumInterval.Seconds() {
cfg.Interval = MaximumInterval
}
return nil
}

func resolveServiceNameBestEffort() string {
if name, ok := os.LookupEnv("OTEL_SERVICE_NAME"); ok && len(name) > 0 {
return name
} else if name, ok := os.LookupEnv("AWS_LAMBDA_FUNCTION_NAME"); ok && len(name) > 0 {
return name
}
return ""
}
Loading