open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.67k stars 767 forks source link

Unable to manually create spans in Lambda function on Node v14.x #3173

Open Aneurysm9 opened 2 years ago

Aneurysm9 commented 2 years ago

What happened?

Steps to Reproduce

Expected Result

Actual Result

Additional Details

Using the Node v16 runtime causes the manually-created span to function as expected.

OpenTelemetry Setup Code

// wraper.ts

import { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import {
  BatchSpanProcessor,
  ConsoleSpanExporter,
  SDKRegistrationConfig,
  SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { awsLambdaDetector } from '@opentelemetry/resource-detector-aws';
import {
  detectResources,
  envDetector,
  processDetector,
} from '@opentelemetry/resources';
import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
import {
  diag,
  DiagConsoleLogger,
  DiagLogLevel,
} from "@opentelemetry/api";
import { getEnv } from '@opentelemetry/core';
import { AwsLambdaInstrumentationConfig } from '@opentelemetry/instrumentation-aws-lambda';

// Use require statements for instrumentation to avoid having to have transitive dependencies on all the typescript
// definitions.
const { AwsLambdaInstrumentation } = require('@opentelemetry/instrumentation-aws-lambda');
const { DnsInstrumentation } = require('@opentelemetry/instrumentation-dns');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
const { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql');
const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc');
const { HapiInstrumentation } = require('@opentelemetry/instrumentation-hapi');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis');
const { KoaInstrumentation } = require('@opentelemetry/instrumentation-koa');
const { MongoDBInstrumentation } = require('@opentelemetry/instrumentation-mongodb');
const { MySQLInstrumentation } = require('@opentelemetry/instrumentation-mysql');
const { NetInstrumentation } = require('@opentelemetry/instrumentation-net');
const { PgInstrumentation } = require('@opentelemetry/instrumentation-pg');
const { RedisInstrumentation } = require('@opentelemetry/instrumentation-redis');
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';

declare global {
  // in case of downstream configuring span processors etc
  function configureTracerProvider(tracerProvider: NodeTracerProvider): void
  function configureTracer(defaultConfig: NodeTracerConfig): NodeTracerConfig;
  function configureSdkRegistration(
    defaultSdkRegistration: SDKRegistrationConfig
  ): SDKRegistrationConfig;
  function configureLambdaInstrumentation(config: AwsLambdaInstrumentationConfig): AwsLambdaInstrumentationConfig
}

console.log('Registering OpenTelemetry');

const instrumentations = [
  new AwsInstrumentation({
    suppressInternalInstrumentation: true,
  }),
  new AwsLambdaInstrumentation(typeof configureLambdaInstrumentation === 'function' ? configureLambdaInstrumentation({}) : {}),
  new DnsInstrumentation(),
  new ExpressInstrumentation(),
  new GraphQLInstrumentation(),
  new GrpcInstrumentation(),
  new HapiInstrumentation(),
  new HttpInstrumentation(),
  new IORedisInstrumentation(),
  new KoaInstrumentation(),
  new MongoDBInstrumentation(),
  new MySQLInstrumentation(),
  new NetInstrumentation(),
  new PgInstrumentation(),
  new RedisInstrumentation(),
];

// configure lambda logging
const logLevel = getEnv().OTEL_LOG_LEVEL
diag.setLogger(new DiagConsoleLogger(), logLevel)

// Register instrumentations synchronously to ensure code is patched even before provider is ready.
registerInstrumentations({
  instrumentations,
});

async function initializeProvider() {
  const resource = await detectResources({
    detectors: [awsLambdaDetector, envDetector, processDetector],
  });

  let config: NodeTracerConfig = {
    resource,
  };
  if (typeof configureTracer === 'function') {
    config = configureTracer(config);
  }

  const tracerProvider = new NodeTracerProvider(config);
  if (typeof configureTracerProvider === 'function') {
    configureTracerProvider(tracerProvider)
  } else {
    // defaults
    tracerProvider.addSpanProcessor(
      new BatchSpanProcessor(new OTLPTraceExporter())
    );
  }
  // logging for debug
  if (logLevel === DiagLogLevel.DEBUG) {
    tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
  }

  let sdkRegistrationConfig: SDKRegistrationConfig = {};
  if (typeof configureSdkRegistration === 'function') {
    sdkRegistrationConfig = configureSdkRegistration(sdkRegistrationConfig);
  }
  tracerProvider.register(sdkRegistrationConfig);

  // Re-register instrumentation with initialized provider. Patched code will see the update.
  registerInstrumentations({
    instrumentations,
    tracerProvider,
  });
}
initializeProvider();
console.log('Registered OpenTelemetry');

// adot-extension.ts

import { CompositePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
import { SDKRegistrationConfig } from '@opentelemetry/sdk-trace-base';
import { NodeTracerConfig } from '@opentelemetry/sdk-trace-node';
import { B3InjectEncoding, B3Propagator } from '@opentelemetry/propagator-b3';
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray';
import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray';

declare global {
  function configureSdkRegistration(defaultSdkRegistration: SDKRegistrationConfig): SDKRegistrationConfig;
  function configureTracer(defaultConfig: NodeTracerConfig): NodeTracerConfig;
}

if (!process.env.OTEL_PROPAGATORS) {
  global.configureSdkRegistration = (config: SDKRegistrationConfig) => {
      return{
        ...config,
        propagator: new CompositePropagator({
          propagators: [
            new AWSXRayPropagator(),
            new W3CTraceContextPropagator(),
            new B3Propagator(),
            new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
          ],
        }),
      };
  }
}

global.configureTracer = (config: NodeTracerConfig) => {
  return {
    ...config,
    idGenerator: new AWSXRayIdGenerator(),
  };
};

// handler

import {
  APIGatewayProxyEvent,
  APIGatewayProxyResult,
  Context,
} from 'aws-lambda';

import AWS from 'aws-sdk';

import { trace, context } from '@opentelemetry/api';

const s3 = new AWS.S3();

const tracer = trace.getTracer("otel-lambda/sample-app", "0.1.0");

exports.handler = async (event: APIGatewayProxyEvent, ctx: Context) => {
  console.info('Serving lambda request.');

  const curSpan = trace.getSpan(context.active());
  console.log('##Current Span: ' + curSpan);
  curSpan?.setAttribute("integ-test", true);

  const span = tracer.startActiveSpan("Testing Tracer", (span) => {
    span.setAttribute("testing", true);
    console.log("Test Span created");
    return span;
  })
  const newCurSpan = trace.getSpan(context.active());
  console.log('##New Current Span: ' + newCurSpan);

  const result = await s3.listBuckets().promise();

  const response: APIGatewayProxyResult = {
    statusCode: 200,
    body: `Hello lambda - found ${result.Buckets?.length || 0} buckets`,
  };

  span.end();
  console.log("Test Span ended");

  return response;
};

package.json

// sample-app package.json

{
  "name": "@opentelemetry-samples/lambda-awssdk",
  "version": "0.0.0",
  "private": true,
  "description": "Sample application for AWS Lambda using AWS SDK v2.",
  "main": "build/src/index.js",
  "types": "build/src/index.d.ts",
  "repository": "open-telemetry/opentelemetry-lambda",
  "scripts": {
    "clean": "rimraf build/*",
    "lint": "eslint . --ext .ts",
    "lint:fix": "eslint . --ext .ts --fix",
    "precompile": "tsc --version",
    "prepare": "npm run compile",
    "compile": "tsc -p .",
    "postcompile": "copyfiles 'package*.json' build/src/ && npm install --production --ignore-scripts --prefix build/src/ && cd build/src && bestzip ../function.zip *"
  },
  "keywords": [
    "opentelemetry",
    "awslambda",
    "nodejs",
    "tracing",
    "profiling",
    "instrumentation"
  ],
  "author": "OpenTelemetry Authors",
  "license": "Apache-2.0",
  "engines": {
    "node": ">=10.0.0"
  },
  "files": [
    "build/src/**/*.js",
    "build/src/**/*.d.ts",
    "doc",
    "LICENSE",
    "README.md"
  ],
  "devDependencies": {
    "@types/aws-lambda": "8.10.73",
    "@types/node": "14.0.27",
    "bestzip": "2.2.0",
    "copyfiles": "2.4.1",
    "rimraf": "3.0.2",
    "ts-node": "9.0.0",
    "tslint-consistent-codestyle": "1.16.0",
    "tslint-microsoft-contrib": "6.2.0",
    "typescript": "3.9.7"
  },
  "dependencies": {
    "aws-sdk": "2.875.0",
    "@opentelemetry/api": "^1.1.0"
  }
}

// OTel layer wrapper package.json

{
  "name": "@opentelemetry-lambda/sdk-layer",
  "version": "0.0.1",
  "private": true,
  "description": "Layer including OpenTelemetry SDK for use with AWS Lambda.",
  "repository": "open-telemetry/opentelemetry-lambda",
  "scripts": {
    "clean": "rimraf build/*",
    "lint": "eslint . --ext .ts",
    "lint:fix": "eslint . --ext .ts --fix",
    "prepare": "npm run compile",
    "compile": "tsc -p .",
    "postcompile": "copyfiles 'node_modules/**' build/workspace/nodejs && copyfiles -f 'scripts/*' build/workspace && copyfiles -f 'build/src/*' build/workspace && cd build/workspace && bestzip ../layer.zip *"
  },
  "keywords": [
    "opentelemetry",
    "awslambda",
    "nodejs",
    "tracing",
    "profiling",
    "instrumentation"
  ],
  "author": "OpenTelemetry Authors",
  "license": "Apache-2.0",
  "engines": {
    "node": ">=10.0.0"
  },
  "dependencies": {
    "@opentelemetry/api": "^1.1.0",
    "@opentelemetry/exporter-trace-otlp-proto": "^0.31.0",
    "@opentelemetry/exporter-metrics-otlp-proto": "^0.31.0",
    "@opentelemetry/instrumentation": "^0.31.0",
    "@opentelemetry/instrumentation-aws-lambda": "^0.32.0",
    "@opentelemetry/instrumentation-aws-sdk": "^0.8.0",
    "@opentelemetry/instrumentation-dns": "^0.29.0",
    "@opentelemetry/instrumentation-express": "^0.30.0",
    "@opentelemetry/instrumentation-graphql": "^0.29.0",
    "@opentelemetry/instrumentation-grpc": "^0.31.0",
    "@opentelemetry/instrumentation-hapi": "^0.29.0",
    "@opentelemetry/instrumentation-http": "^0.31.0",
    "@opentelemetry/instrumentation-ioredis": "^0.30.0",
    "@opentelemetry/instrumentation-koa": "^0.30.0",
    "@opentelemetry/instrumentation-mongodb": "^0.31.0",
    "@opentelemetry/instrumentation-mysql": "^0.30.0",
    "@opentelemetry/instrumentation-net": "^0.29.0",
    "@opentelemetry/instrumentation-pg": "^0.30.0",
    "@opentelemetry/instrumentation-redis": "^0.32.0",
    "@opentelemetry/propagator-aws-xray": "^1.1.0",
    "@opentelemetry/resource-detector-aws": "^1.1.1",
    "@opentelemetry/resources": "^1.5.0",
    "@opentelemetry/sdk-trace-base": "^1.5.0",
    "@opentelemetry/sdk-trace-node": "^1.5.0"
  }
}

// ADOT wrapper package.json

{
  "name": "@aws-observability/adot-wrapper",
  "version": "0.0.1",
  "private": true,
  "description": "Layer including aws-otel customization of OpenTelemetry Lambda layer.",
  "repository": "aws-observability/aws-otel-lambda",
  "scripts": {
    "clean": "rimraf build/*",
    "lint": "eslint . --ext .ts",
    "lint:fix": "eslint . --ext .ts --fix",
    "prepare": "npm run compile",
    "compile": "tsc -p ."
  },
  "keywords": [
    "opentelemetry",
    "awslambda",
    "nodejs",
    "tracing",
    "profiling",
    "instrumentation"
  ],
  "author": "OpenTelemetry Authors",
  "license": "Apache-2.0",
  "engines": {
    "node": ">=10.0.0"
  },
  "devDependencies": {
    "@opentelemetry/api": "^1.1.0",
    "@types/node": "14.14.41",
    "@typescript-eslint/eslint-plugin": "5.3.1",
    "@typescript-eslint/parser": "5.3.1",
    "eslint": "7.32.0",
    "eslint-plugin-header": "3.1.1",
    "eslint-plugin-import": "2.26.0",
    "gts": "3.1.0",
    "rimraf": "3.0.2",
    "typescript": "4.1.3"
  },
  "dependencies": {
    "@opentelemetry/core": "^1.5.0",
    "@opentelemetry/id-generator-aws-xray": "^1.1.0",
    "@opentelemetry/sdk-trace-node": "^1.5.0",
    "@opentelemetry/propagator-aws-xray": "^1.1.0",
    "@opentelemetry/propagator-b3": "^1.5.0"
  }
}

Relevant log output

No response

Aneurysm9 commented 2 years ago

Relevant log output


timestamp message
1660607488579 START RequestId: 075ee708-1253-4be7-b7aa-0ddb30593549 Version: $LATEST
1660607488579 {"level":"debug","msg":"Launching OpenTelemetry Lambda extension","version":"v0.1.0"}
1660607489323 {"level":"debug","msg":"Register ","response :":"{\n\t\"functionName\": \"lambda-nodejs-aws-sdk-wrapper-x86_64-1234\",\n\t\"functionVersion\": \"$LATEST\",\n\t\"handler\": \"index.handler\"\n}"}
1660607489340 {"level":"debug","msg":"Waiting for event..."}
1660607489341 Registering OpenTelemetry
1660607489358 @opentelemetry/api: Registered a global for diag v1.1.0.
1660607489534 Registered OpenTelemetry
1660607490273 2022-08-15T23:51:29.357Z undefined DEBUG @opentelemetry/instrumentation-http Applying patch for http@14.19.3
1660607490273 2022-08-15T23:51:29.529Z undefined DEBUG aws-sdk instrumentation: applying patch to aws-sdk
1660607490276 2022-08-15T23:51:30.273Z undefined DEBUG Applying patch for lambda handler
1660607490276 2022-08-15T23:51:30.273Z undefined DEBUG patch handler function
1660607490276 2022-08-15T23:51:30.276Z undefined DEBUG AwsLambdaDetector found resource. Resource { attributes: { 'cloud.provider': 'aws', 'cloud.platform': 'aws_lambda', 'cloud.region': 'us-east-1', 'faas.name': 'lambda-nodejs-aws-sdk-wrapper-x86_64-1234', 'faas.version': '$LATEST' } }
1660607490280 2022-08-15T23:51:30.276Z undefined DEBUG EnvDetector found resource. Resource { attributes: { 'service.name': 'lambda-nodejs-aws-sdk-wrapper-x86_64-1234' } }
1660607490280 2022-08-15T23:51:30.276Z undefined DEBUG ProcessDetector found resource. Resource { attributes: { 'process.pid': 17, 'process.executable.name': '/var/lang/bin/node', 'process.command': '/var/runtime/index.js', 'process.command_line': '/var/lang/bin/node /var/runtime/index.js', 'process.runtime.version': '14.19.3', 'process.runtime.name': 'nodejs', 'process.runtime.description': 'Node.js' } }
1660607490280 2022-08-15T23:51:30.280Z undefined DEBUG @opentelemetry/api: Registered a global for trace v1.1.0.
1660607490302 2022-08-15T23:51:30.280Z undefined DEBUG @opentelemetry/api: Registered a global for context v1.1.0.
1660607490302 2022-08-15T23:51:30.280Z undefined DEBUG @opentelemetry/api: Registered a global for propagation v1.1.0.
1660607490302 EXTENSION Name: collector State: Ready Events: [SHUTDOWN,INVOKE]
1660607490338 {"level":"debug","msg":"Received ","event :":"{\n\t\"eventType\": \"INVOKE\",\n\t\"deadlineMs\": 1660607510319,\n\t\"requestId\": \"075ee708-1253-4be7-b7aa-0ddb30593549\",\n\t\"invokedFunctionArn\": \"arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:lambda-nodejs-aws-sdk-wrapper-x86_64-1234\",\n\t\"tracing\": {\n\t\t\"type\": \"X-Amzn-Trace-Id\",\n\t\t\"value\": \"Root=1-62fadc00-7114a0f12948935a651fde18;Parent=0e09c5911b03f6c3;Sampled=1\"\n\t}\n}"}
1660607490338 {"level":"debug","msg":"Waiting for event..."}
1660607490342 2022-08-15T23:51:30.342Z 075ee708-1253-4be7-b7aa-0ddb30593549 INFO Serving lambda request.
1660607490342 2022-08-15T23:51:30.342Z 075ee708-1253-4be7-b7aa-0ddb30593549 INFO ##Current Span: [object Object]
1660607490343 2022-08-15T23:51:30.343Z 075ee708-1253-4be7-b7aa-0ddb30593549 INFO Test Span created
1660607490343 2022-08-15T23:51:30.343Z 075ee708-1253-4be7-b7aa-0ddb30593549 INFO ##New Current Span: [object Object]
1660607490380 2022-08-15T23:51:30.380Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http Applying patch for https@14.19.3
1660607490382 2022-08-15T23:51:30.382Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG Instrumentation suppressed, returning Noop Span
1660607490440 2022-08-15T23:51:30.440Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http https instrumentation outgoingRequest
1660607490458 2022-08-15T23:51:30.458Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http http.ClientRequest return request
1660607490565 2022-08-15T23:51:30.565Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http outgoingRequest on response()
1660607490567 2022-08-15T23:51:30.567Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http outgoingRequest on end()
1660607490603 {
1660607490603 traceId: '62fadc007114a0f12948935a651fde18',
1660607490603 parentId: '38b9944194e48b2b',
1660607490603 name: 'S3.ListBuckets',
1660607490603 id: '9b0ede6e9c045127',
1660607490603 kind: 2,
1660607490603 timestamp: 1660607490345766,
1660607490603 duration: 256649,
1660607490603 attributes: {
1660607490603 'aws.operation': 'listBuckets',
1660607490603 'aws.signature.version': 's3',
1660607490603 'aws.service.api': 'S3',
1660607490603 'aws.service.identifier': 's3',
1660607490603 'aws.service.name': 'Amazon S3',
1660607490603 'rpc.system': 'aws-api',
1660607490603 'rpc.method': 'ListBuckets',
1660607490603 'rpc.service': 'S3',
1660607490603 'aws.region': 'us-east-1',
1660607490603 'aws.request.id': '3REDGHC9KA4ZAYPT',
1660607490603 'http.status_code': 200
1660607490603 },
1660607490603 status: { code: 0 },
1660607490603 events: [],
1660607490603 links: []
1660607490603 }
1660607490603 2022-08-15T23:51:30.603Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http outgoingRequest on request close()
1660607490604 2022-08-15T23:51:30.604Z 075ee708-1253-4be7-b7aa-0ddb30593549 INFO Test Span ended
1660607490604 {
1660607490604 traceId: '62fadc007114a0f12948935a651fde18',
1660607490604 parentId: '91a2e4db685b3e77',
1660607490604 name: 'lambda-nodejs-aws-sdk-wrapper-x86_64-1234',
1660607490604 id: '38b9944194e48b2b',
1660607490604 kind: 1,
1660607490604 timestamp: 1660607490341365,
1660607490604 duration: 263178,
1660607490604 attributes: {
1660607490604 'faas.execution': '075ee708-1253-4be7-b7aa-0ddb30593549',
1660607490604 'faas.id': 'arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:lambda-nodejs-aws-sdk-wrapper-x86_64-1234',
1660607490604 'cloud.account.id': 'xxxxxxxxxxxx',
1660607490604 'integ-test': true
1660607490604 },
1660607490604 status: { code: 0 },
1660607490604 events: [],
1660607490604 links: []
1660607490604 }
1660607490606 2022-08-15T23:51:30.606Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG items to be sent [ Span { attributes: { 'aws.operation': 'listBuckets', 'aws.signature.version': 's3', 'aws.service.api': 'S3', 'aws.service.identifier': 's3', 'aws.service.name': 'Amazon S3', 'rpc.system': 'aws-api', 'rpc.method': 'ListBuckets', 'rpc.service': 'S3', 'aws.region': 'us-east-1', 'aws.request.id': '3REDGHC9KA4ZAYPT', 'http.status_code': 200 }, links: [], events: [], status: { code: 0 }, endTime: [ 1660607490, 602415030 ], _ended: true, _duration: [ 0, 256649325 ], name: 'S3.ListBuckets', _spanContext: { traceId: '62fadc007114a0f12948935a651fde18', spanId: '9b0ede6e9c045127', traceFlags: 1, traceState: undefined }, parentSpanId: '38b9944194e48b2b', kind: 2, startTime: [ 1660607490, 345765705 ], resource: Resource { attributes: [Object] }, instrumentationLibrary: { name: '@opentelemetry/instrumentation-aws-sdk', version: '0.8.1', schemaUrl: undefined }, _spanLimits: { attributeValueLengthLimit: Infinity, attributeCountLimit: 128, linkCountLimit: 128, eventCountLimit: 128 }, _spanProcessor: MultiSpanProcessor { _spanProcessors: [Array] }, _attributeValueLengthLimit: Infinity }, Span { attributes: { 'faas.execution': '075ee708-1253-4be7-b7aa-0ddb30593549', 'faas.id': 'arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:lambda-nodejs-aws-sdk-wrapper-x86_64-1234', 'cloud.account.id': 'xxxxxxxxxxxx', 'integ-test': true }, links: [], events: [], status: { code: 0 }, endTime: [ 1660607490, 604543326 ], _ended: true, _duration: [ 0, 263178009 ], name: 'lambda-nodejs-aws-sdk-wrapper-x86_64-1234', _spanContext: { traceId: '62fadc007114a0f12948935a651fde18', spanId: '38b9944194e48b2b', traceFlags: 1, traceState: undefined }, parentSpanId: '91a2e4db685b3e77', kind: 1, startTime: [ 1660607490, 341365317 ], resource: Resource { attributes: [Object] }, instrumentationLibrary: { name: '@opentelemetry/instrumentation-aws-lambda', version: '0.32.0', schemaUrl: undefined }, _spanLimits: { attributeValueLengthLimit: Infinity, attributeCountLimit: 128, linkCountLimit: 128, eventCountLimit: 128 }, _spanProcessor: MultiSpanProcessor { _spanProcessors: [Array] }, _attributeValueLengthLimit: Infinity } ]
1660607490639 2022-08-15T23:51:30.639Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG Instrumentation suppressed, returning Noop Span
1660607490640 2022-08-15T23:51:30.640Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http http instrumentation outgoingRequest
1660607490640 2022-08-15T23:51:30.640Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http http.ClientRequest return request
1660607490861 2022-08-15T23:51:30.861Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http outgoingRequest on response()
1660607490862 2022-08-15T23:51:30.862Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http outgoingRequest on end()
1660607490862 2022-08-15T23:51:30.862Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG statusCode: 200
1660607490865 END RequestId: 075ee708-1253-4be7-b7aa-0ddb30593549
1660607490865 REPORT RequestId: 075ee708-1253-4be7-b7aa-0ddb30593549 Duration: 544.63 ms Billed Duration: 545 ms Memory Size: 384 MB Max Memory Used: 163 MB Init Duration: 1930.57 ms XRAY TraceId: 1-62fadc00-7114a0f12948935a651fde18 SegmentId: 0e09c5911b03f6c3 Sampled: true
1660607846200 2022-08-15T23:57:26.173Z 075ee708-1253-4be7-b7aa-0ddb30593549 DEBUG @opentelemetry/instrumentation-http outgoingRequest on request close()
1660607846280 {"level":"debug","msg":"Received ","event :":"{\n\t\"eventType\": \"SHUTDOWN\",\n\t\"deadlineMs\": 1660607848172,\n\t\"requestId\": \"\",\n\t\"invokedFunctionArn\": \"\",\n\t\"tracing\": {\n\t\t\"type\": \"\",\n\t\t\"value\": \"\"\n\t}\n}"}
1660607846280 2022-08-15T23:57:26.280Z info service/collector.go:162 Received shutdown request
1660607846280 2022-08-15T23:57:26.280Z info service/collector.go:231 Starting shutdown...
1660607846280 2022-08-15T23:57:26.280Z info pipelines/pipelines.go:118 Stopping receivers...
1660607846281 2022-08-15T23:57:26.281Z info pipelines/pipelines.go:125 Stopping processors...
1660607846281 2022-08-15T23:57:26.281Z info pipelines/pipelines.go:132 Stopping exporters...
1660607846281 2022-08-15T23:57:26.281Z info extensions/extensions.go:56 Stopping extensions...
1660607846282 {"level":"debug","msg":"Received SHUTDOWN event"}
1660607846282 {"level":"debug","msg":"Exiting"}

eulisesquidel commented 2 years ago

Hello people, I am interested in this topic. My team is trying to trace from AWS Lambda using AWS Distro for OpenTelemetry so far with no success. We arrive at the same error in the situation.

https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/13251

Breadkenty commented 2 years ago

I'm having the same issue here

EDIT: I can verify that it works with Node v16. Not with 14.

jasonwbrown23 commented 2 years ago

Same issue. runtime is nodejs 14.undefined DEBUG @opentelemetry/api: Registered a global for diag v1.1.0.

hugheba commented 1 year ago

I'm getting the same errors.

With debugging on I see this error message at end.

2022-10-09T15:18:09.868Z adc788eb-688b-43fd-9e21-ffd3bfa625fe DEBUG @opentelemetry/instrumentation-http outgoingRequest on request error() Error: socket hang up at connResetException (node:internal/errors:692:14) at Socket.socketCloseListener (node:_http_client:427:25) at Socket.emit (node:events:539:35) at Socket.emit (node:domain:475:12) at TCP. (node:net:709:12) at TCP.callbackTrampoline (node:internal/async_hooks:130:17) { code: 'ECONNRESET' }