Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/ci-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 18
node-version-file: 'nodejs/.nvmrc'
Comment thread
8naama marked this conversation as resolved.
Resolved
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
node-version-file: 'nodejs/.nvmrc'

- name: Build combined Node.js layer (amd64)
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-combined-layer-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 22
node-version-file: 'nodejs/.nvmrc'

- uses: actions/setup-go@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-layer-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 18
node-version-file: 'nodejs/.nvmrc'

- name: Build
run: |
Expand Down
10 changes: 10 additions & 0 deletions README.combined-layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ Most combined layers support these common environment variables:
- **Agent and wrapper variants:** Both Java agent and wrapper approaches are available in the combined layer

#### Node.js Combined Layer
- **Based on OpenTelemetry Node.js layer 0.24.0.** Produces AWS SDK spans (`DynamoDB.PutItem`, `SQS.SendMessage`, `EventBridge.PutEvents`, ...) with `rpc.*`, `db.system.name` and `messaging.*` attributes, including SDK v3 releases that moved to `@smithy/core`.
- **Logz.io hooks** (`/opt/nodejs/logzio-otel-hooks.cjs`, loaded automatically by `/opt/otel-handler`):
- API Gateway spans are named by route (`GET /orders/{id}`) and get `http.route`, `http.request.method`, `faas.trigger` and the response status code (both current and legacy attribute names).
- Cold starts appear inside the first request's trace: a `cold start` child span (process start to handler call) and `faas.init_duration_ms` on the invocation span. Skipped for provisioned concurrency.
- Invocations triggered by Kinesis, SQS, SNS or DynamoDB Streams get `messaging.system` and `messaging.destination.name`, so APM shows the stream, queue or topic as a dependency.
- Console output during an invocation is also sent as OpenTelemetry logs carrying the trace and span IDs, flushed with the spans at the end of the invocation.
- Trace context crosses services AWS does not propagate: a `_logzio_trace` field is added to JSON payloads sent with EventBridge `PutEvents`, Kinesis `PutRecord`/`PutRecords` and IoT `Publish` (non-JSON payloads are left untouched). The receiving function continues that trace, and links every record of a Kinesis/SQS batch. Set `LOGZIO_PROPAGATION=off` to disable.
- **Defaults set by the wrapper:** `OTEL_NODE_ENABLED_INSTRUMENTATIONS` includes `undici` (Node's built-in `fetch`); traces and logs exporters are `otlp`, the SDK metrics exporter is off. In gateway mode the collector drops Telemetry API copies of lines written inside an invocation (they arrive over OTLP with trace IDs) drops Lambda's per-invocation START/END lines, and keeps other platform records and output written outside an invocation. For traces only (logs shipped another way), use `/opt/collector-config/config.gateway-traces.yaml` and set `OTEL_LOGS_EXPORTER=none`.
- The invocation span carries `faas.timeout_ms` (configured timeout) and `faas.memory_used_mb` (peak memory of the instance so far); configured memory is the resource attribute `faas.max_memory`.
- **Gateway mode (APM service pages):** set `OPENTELEMETRY_COLLECTOR_CONFIG_URI=/opt/collector-config/config.gateway.yaml`, `LOGZIO_GATEWAY_ENDPOINT` and `LOGZIO_GATEWAY_TOKEN`. Traces and logs go to a Logz.io gateway collector, which computes APM span metrics and forwards to Logz.io.
- **ESM and CommonJS support:** Works with both module systems
- **Instrumentation control:**
- `OTEL_NODE_ENABLED_INSTRUMENTATIONS` - comma-separated list to enable only specific instrumentations
Expand Down
26 changes: 26 additions & 0 deletions collector/config.gateway-traces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logz.io gateway mode, traces only: set OPENTELEMETRY_COLLECTOR_CONFIG_URI=/opt/collector-config/config.gateway-traces.yaml
# For functions whose logs already reach Logz.io another way. Sends traces to the Logz.io gateway collector,
# which adds APM metrics and forwards to Logz.io. Set OTEL_LOGS_EXPORTER=none so the SDK sends no logs either.
receivers:
otlp:
protocols:
grpc:
endpoint: "localhost:4317"
http:
endpoint: "localhost:4318"

processors:
batch:

exporters:
otlphttp:
endpoint: "${env:LOGZIO_GATEWAY_ENDPOINT}"
headers:
Authorization: "Bearer ${env:LOGZIO_GATEWAY_TOKEN}"

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp]
49 changes: 49 additions & 0 deletions collector/config.gateway.yaml
Comment thread
8naama marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Logz.io gateway mode: set OPENTELEMETRY_COLLECTOR_CONFIG_URI=/opt/collector-config/config.gateway.yaml
# Sends traces and logs to the Logz.io gateway collector, which adds APM metrics and forwards to Logz.io.
# Cold starts are recorded by the Logz.io hooks inside the first invocation's trace.
# Logs: console output during an invocation arrives over OTLP from the Logz.io hooks, with trace and span IDs.
# The Telemetry API still supplies platform records and function output written outside an invocation
# (init, crashes); function lines written inside an invocation are dropped here so they are not sent twice,
# and so are Lambda's per-invocation START and END lines.
# Traces only (keep your own log shipping): use config.gateway-traces.yaml instead.
receivers:
otlp:
protocols:
grpc:
endpoint: "localhost:4317"
http:
endpoint: "localhost:4318"
telemetryapireceiver:
types: ["platform", "function"]

processors:
batch:
filter/invocation-output:
error_mode: ignore
logs:
log_record:
# Runtime line format: "<timestamp>\t<request id>\t<LEVEL>\t<message>"; init lines carry "undefined".
- 'attributes["type"] == "function" and IsMatch(body, "^\\S+\\t[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\t")'
# Lambda's START and END lines, one pair per invocation: high volume, no information beyond the trace.
- 'attributes["type"] == "platform.start" or attributes["type"] == "platform.runtimeDone"'

exporters:
otlphttp:
endpoint: "${env:LOGZIO_GATEWAY_ENDPOINT}"
headers:
Authorization: "Bearer ${env:LOGZIO_GATEWAY_TOKEN}"

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp]
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp]
logs/telemetryapi:
receivers: [telemetryapireceiver]
processors: [filter/invocation-output, batch]
exporters: [otlphttp]
55 changes: 55 additions & 0 deletions collector/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"context"
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/provider/envprovider"
"go.opentelemetry.io/collector/confmap/provider/fileprovider"
"go.opentelemetry.io/collector/confmap/xconfmap"
"go.opentelemetry.io/collector/otelcol"

"github.com/open-telemetry/opentelemetry-lambda/collector/lambdacomponents"
)

// The shipped configs must load with this collector's components: an unknown component name
// (for example a receiver registered under a different type) fails here instead of at runtime.
func TestShippedConfigsAreValid(t *testing.T) {
t.Setenv("LOGZIO_GATEWAY_ENDPOINT", "https://gateway.example.com")
t.Setenv("LOGZIO_GATEWAY_TOKEN", "test-token")

factories, err := lambdacomponents.Components("collector")
require.NoError(t, err)

for _, file := range []string{"config.gateway.yaml", "config.gateway-traces.yaml"} {
t.Run(file, func(t *testing.T) {
provider, err := otelcol.NewConfigProvider(otelcol.ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
URIs: []string{"file:" + file},
ProviderFactories: []confmap.ProviderFactory{fileprovider.NewFactory(), envprovider.NewFactory()},
},
})
require.NoError(t, err)

cfg, err := provider.Get(context.Background(), factories)
require.NoError(t, err)
require.NoError(t, xconfmap.Validate(cfg))
})
}
}
4 changes: 0 additions & 4 deletions nodejs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ docs

.nyc_output

#lerna
.changelog
package.json.lerna_backup

# OS generated files
.DS_Store

Expand Down
1 change: 1 addition & 0 deletions nodejs/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.20.2
135 changes: 94 additions & 41 deletions nodejs/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,97 @@
module.exports = {
plugins: [
"@typescript-eslint",
"header"
],
extends: [
"../../node_modules/gts",
],
parser: "@typescript-eslint/parser",
parserOptions: {
"project": "./tsconfig.json"
},
rules: {
"@typescript-eslint/no-this-alias": "off",
"eqeqeq": "off",
"prefer-rest-params": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "memberLike",
"modifiers": ["private", "protected"],
"format": ["camelCase"],
"leadingUnderscore": "require"
}
'use strict';

const gtsConfig = require('gts');
const tseslint = require('typescript-eslint');
const globals = require('globals');

module.exports = [
...gtsConfig,
{
ignores: [
'**/build/**',
'**/node_modules/**',
'sample-apps/aws-sdk/cdk.out/**',
'sample-apps/aws-sdk/bin/**',
'sample-apps/aws-sdk/lib/**',
],
"@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }],
"arrow-parens": ["error", "as-needed"],
"prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }],
"@typescript-eslint/no-require-imports": "off",
},
overrides: [
{
rules: {
'prettier/prettier': [
'error',
{singleQuote: true, arrowParens: 'avoid'},
],
},
},
{
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'no-unused-vars': ['error', {varsIgnorePattern: '^_'}],
},
},
{
"files": ["test/**/*.ts"],
"rules": {
"no-empty": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off"
}
}
]
};
files: ['**/test/**/*.js', '**/test/**/*.mjs', '**/test/**/*.cjs'],
languageOptions: {
globals: {
...globals.mocha,
},
},
rules: {
'no-empty': 'off',
'no-unused-vars': 'off',
},
},
{
files: ['**/*.ts'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true,
},
globals: {
...globals.node,
},
},
rules: {
'@typescript-eslint/no-this-alias': 'off',
'eqeqeq': 'off',
'prefer-rest-params': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'memberLike',
modifiers: ['private', 'protected'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
],
'@typescript-eslint/no-inferrable-types': [
'error',
{ignoreProperties: true},
],
'arrow-parens': ['error', 'as-needed'],
'@typescript-eslint/no-require-imports': 'off',
},
},
{
files: ['**/test/**/*.ts'],
languageOptions: {
globals: {
...globals.mocha,
},
},
rules: {
'no-empty': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
},
];
17 changes: 0 additions & 17 deletions nodejs/lerna.json

This file was deleted.

Loading
Loading