admin管理员组文章数量:1398093
i'm trying to set up OpenTelemetry (OTel) for my AWS Lambda function (ts) using the AWS Lambda layer. However, the OTel extension fails to start, and I see the following errors in the logs:
{
"level": "info",
"ts": 1742934396.4294243,
"logger": "telemetryAPI.Client",
"msg": "Subscribing",
"baseURL": "http://127.0.0.1:9001/2022-07-01/telemetry"
}
{
"time": "2025-03-25T20:26:36.430Z",
"type": "platform.telemetrySubscription",
"record": {
"name": "collector",
"state": "Already subscribed",
"types": [
"platform"
]
}
}
{
"level": "info",
"ts": 1742934396.4304833,
"logger": "telemetryAPI.Client",
"msg": "Subscription success",
"response": "\"AlreadySubscribed\""
}
{
"level": "info",
"ts": 1742934396.4305956,
"logger": "NewCollector",
"msg": "Using config URI from environment variable",
"uri": "/var/task/collector.yaml"
}
{
"level": "warn",
"ts": 1742934396.4449484,
"logger": "lifecycle.manager",
"msg": "Failed to start the extension",
"error": "unable to start, otelcol state is Closed"
}
...
}
My Setup including collector.yaml:
Lambda Runtime: Node.js 20
OTel Layer: Using AWS-provided OpenTelemetry Lambda layer.
collector.yaml (placed in the root directory):
receivers:
otlp:
protocols:
grpc:
endpoint: "localhost:4317"
http:
endpoint: "localhost:4318"
exporters:
logging:
loglevel: debug
opensearch:
endpoint: "https://<endpoint>"
region: "us-east-2"
index: "metrics-otel-v1-%{yyyy.MM.dd}"
insecure: true
username: "<username>"
password: "<passowwrd>"
service:
pipelines:
traces:
receivers: [otlp]
exporters: [awsxray]
metrics:
receivers: [otlp]
exporters: [logging]
telemetry:
metrics:
receivers: [otlp]
exporters: [logging, opensearch]
Env variables
config_file is depricated using config_uri
OPENTELEMETRY_COLLECTOR_CONFIG_URI=/var/task/collector.yaml
OTEL_LOG_LEVEL=DEBUG
Since this is a POC I wrote a simple typescript lambda function
import { APIGatewayEvent, APIGatewayProxyResult } from "aws-lambda";
interface Sample {
name: string;
}
export const handler = async (
event: APIGatewayEvent
): Promise<APIGatewayProxyResult> => {
try {
const body: Sample = JSON.parse(event.body || "{}");
if (!body.name) {
return {
statusCode: 400,
body: JSON.stringify({ message: "Missing 'name' in the request body." }),
};
}
return {
statusCode: 202,
body: JSON.stringify({ message: "Accepted" }),
};
} catch (error) {
console.error("Error processing the request:", error);
return {
statusCode: 500,
body: JSON.stringify({ message: "Internal Server Error" }),
};
}
};
Issue that I am facing
I'm using OpenTelemetry (OTel) with AWS Lambda and an OTel layer, but the extension fails to start with the error "otelcol state is Closed". Why is the OpenTelemetry extension failing to start, and why aren't metrics being sent to OpenSearch?
things i tried.
moving from localhost to 0.0.0.0 and that didnt work.
本文标签:
版权声明:本文标题:amazon web services - OpenTelemetry Lambda Extension Failing to Start with "otelcol state is Closed" - Stack O 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744168530a2593666.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论