forked from open-telemetry/opentelemetry-lambda
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,848 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,59 @@ | ||
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: | ||
types: ${SW_APM_TELEMETRY_API_SUBSCRIPTION} | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
44 changes: 44 additions & 0 deletions
44
collector/extension/solarwindsapmsettingsextension/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
67
collector/extension/solarwindsapmsettingsextension/config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" | ||
} |
Oops, something went wrong.