Repository navigation
Node.js combined layer: sync to upstream 0.24.0, Logz.io hooks for route naming and async trace propagation #24
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea0e9fb
Sync nodejs/ to upstream layer-nodejs/0.24.0
amosd92 3fe1a4a
Node.js combined layer: Logz.io hooks, wrapper defaults, gateway config
amosd92 065951a
Cold start span inside the first invocation's trace
amosd92 e27b64f
CI (NodeJS): use nodejs/.nvmrc like upstream
amosd92 7ed903e
Remove files upstream deleted; format hooks with the repo's Prettier …
amosd92 e2a7704
Address review: config name, tests, console logs, event sources
amosd92 393cc76
Add timeout/memory span attributes, traces-only config, drop START/EN…
amosd92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,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] |
|
8naama marked this conversation as resolved.
Resolved
|
This file contains hidden or 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,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] |
This file contains hidden or 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,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)) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -63,10 +63,6 @@ docs | |
|
|
||
| .nyc_output | ||
|
|
||
| #lerna | ||
| .changelog | ||
| package.json.lerna_backup | ||
|
|
||
| # OS generated files | ||
| .DS_Store | ||
|
|
||
|
|
||
This file contains hidden or 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 @@ | ||
| 20.20.2 |
This file contains hidden or 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,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', | ||
| }, | ||
| }, | ||
| ]; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.