Skip to content
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

Support explicit exporting of metrics in Lambda/Serverless environment. #3278

Closed
arszen123 opened this issue Sep 28, 2022 · 2 comments · Fixed by #3517
Closed

Support explicit exporting of metrics in Lambda/Serverless environment. #3278

arszen123 opened this issue Sep 28, 2022 · 2 comments · Fixed by #3517
Labels
feature-request sdk:metrics Issues and PRs related to the Metrics SDK

Comments

@arszen123
Copy link

Is your feature request related to a problem?

I am trying to export metrics from AWS Lambda with the PeriodicExportingMetricReader, by calling forceFlush at the end of the handler function. However, after checking out the implementation, I realized that the metrics are not exported here.

Describe the solution you'd like

I would like to modify the PeriodicExportingMetricReader#forceFlush method to export the metrics here as well, before calling forceFlush on the exporter. Also, considering to add exporting to the shutdown function.

Describe alternatives you've considered

An alternative solution could be to add a new on-demand metric reader, that only exports metrics when forceFlush or shutdown is called. This would make sense if someone wants to export metrics at different breakpoints, for example at the end of the Lamda function.

Additional context

Example code:

const meterProvider = new MeterProvider();
const reader = new PeriodicExportingMetricReader({ /** options **/});

meterProvider.addMetricReader(reader);

exports.handler = async () => {
  // do some work

  // force metrics exporting
  await meterProvider.forceFlush();

  return;
}
@legendecas
Copy link
Member

I agree it makes sense for PeriodicExportingMetricReader to expose a method to collect and export metrics.

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request sdk:metrics Issues and PRs related to the Metrics SDK
Projects
None yet
2 participants